diff --git a/src/pilot.h b/src/pilot.h index 155659d..98a7d1b 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -9,8 +9,10 @@ #define PLAYER_ID 1 -#define HYPERSPACE_FLY_DELAY 5000 -#define HYPERSPACE_ENGINE_DELAY 3000 +#define HYPERSPACE_ENGINE_DELAY 3000 // Warm up the engines. +#define HYPERSPACE_FLY_DELAY 5000 // Time taken to hyperspace. +#define HYPERSPACE_STARS_BLUR 3000 // Time stars blur. +#define HYPERSPACE_FADEOUT 1000 // Time fadeout. // Aproximation for pilot size. #define PILOT_SIZE_APROX 0.8 diff --git a/src/player.c b/src/player.c index 8ec70aa..ae72d1c 100644 --- a/src/player.c +++ b/src/player.c @@ -476,11 +476,11 @@ void player_render(void) { } // Hyperspace FLASH BANG!!! if(pilot_isFlag(player, PILOT_HYPERSPACE)) { - i = (int)player->ptimer - HYPERSPACE_FLY_DELAY/4.; + i = (int)player->ptimer - HYPERSPACE_FADEOUT; j = (int)SDL_GetTicks(); if(i < j) { - x = (double)(j-i) / (HYPERSPACE_FLY_DELAY/4.); - glColor4d(1.,1.,1.,pow(x,4)); // We'll | I'll, make this more effiecent later. + x = (double)(j-i) / HYPERSPACE_FADEOUT; + glColor4d(1.,1.,1., x); // We'll | I'll, make this more effiecent later. glBegin(GL_QUADS); glVertex2d(-gl_screen.w/2., -gl_screen.h/2.); glVertex2d(-gl_screen.w/2., gl_screen.h/2.); diff --git a/src/space.c b/src/space.c index 063f229..1643d1f 100644 --- a/src/space.c +++ b/src/space.c @@ -521,24 +521,57 @@ int space_load(void) { // Render the system. -- Just playing god now. void space_render(double dt) { int i; - glBegin(GL_POINTS); - for(i = 0; i < nstars; i++) { - if(!paused && !toolkit) { - // Update the position. - stars[i].x -= VX(player->solid->vel)/(13.-10.*stars[i].brightness)*dt; - stars[i].y -= VY(player->solid->vel)/(13.-10.*stars[i].brightness)*dt; - // Scroll those stars bitch! - if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF; - else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF; - if(stars[i].y > gl_screen.h + STAR_BUF) stars[i].y = -STAR_BUF; - else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF; - } - // Render. - glColor4d(1., 1., 1., stars[i].brightness); - glVertex2d(stars[i].x - (double)gl_screen.w/2., - stars[i].y - (double)gl_screen.h/2.); - } - glEnd(); + unsigned int t, timer; + double x, y, m; + + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); // Translation matrix. + glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0); + + t = SDL_GetTicks(); + timer = player->ptimer - HYPERSPACE_STARS_BLUR; + if(pilot_isFlag(player, PILOT_HYPERSPACE) && (timer < t)) { + // Fancy hyperspace effects. + glShadeModel(GL_SMOOTH); + + glBegin(GL_LINES); + + // Lines will be based on velocity. + m = 250*(double)(t-timer)/(HYPERSPACE_STARS_BLUR); + x = m*cos(VANGLE(player->solid->vel)+M_PI); + y = m*sin(VANGLE(player->solid->vel)+M_PI); + + for(i = 0; i < nstars; i++) { + glColor4d(1., 1., 1., stars[i].brightness); + glVertex2d(stars[i].x, stars[i].y); + glColor4d(1., 1., 1., 0.); + glVertex2d(stars[i].x + x*stars[i].brightness, stars[i].y + y*stars[i].brightness); + } + glEnd(); + + glShadeModel(GL_FLAT); + + } else { + glBegin(GL_POINTS); + + for(i = 0; i < nstars; i++) { + if(!paused && !toolkit) { + // Update position. + stars[i].x -= VX(player->solid->vel)/(13.-10.*stars[i].brightness)*dt; + stars[i].y -= VY(player->solid->vel)/(13.-10.*stars[i].brightness)*dt; + // Scroll those stars bitch! + if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF; + else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF; + if(stars[i].y > gl_screen.h + STAR_BUF) stars[i].y = -STAR_BUF; + else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF; + } + // Render. + glColor4d(1., 1., 1., stars[i].brightness); + glVertex2d(stars[i].x, stars[i].y); + } + glEnd(); + } + glPopMatrix(); // Translation matrix. } // Render the planets.