[Add] Perfected hyperspace visuals. ^.^
This commit is contained in:
parent
409dbff310
commit
45d75779dd
@ -9,8 +9,10 @@
|
|||||||
|
|
||||||
#define PLAYER_ID 1
|
#define PLAYER_ID 1
|
||||||
|
|
||||||
#define HYPERSPACE_FLY_DELAY 5000
|
#define HYPERSPACE_ENGINE_DELAY 3000 // Warm up the engines.
|
||||||
#define HYPERSPACE_ENGINE_DELAY 3000
|
#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.
|
// Aproximation for pilot size.
|
||||||
#define PILOT_SIZE_APROX 0.8
|
#define PILOT_SIZE_APROX 0.8
|
||||||
|
@ -476,11 +476,11 @@ void player_render(void) {
|
|||||||
}
|
}
|
||||||
// Hyperspace FLASH BANG!!!
|
// Hyperspace FLASH BANG!!!
|
||||||
if(pilot_isFlag(player, PILOT_HYPERSPACE)) {
|
if(pilot_isFlag(player, PILOT_HYPERSPACE)) {
|
||||||
i = (int)player->ptimer - HYPERSPACE_FLY_DELAY/4.;
|
i = (int)player->ptimer - HYPERSPACE_FADEOUT;
|
||||||
j = (int)SDL_GetTicks();
|
j = (int)SDL_GetTicks();
|
||||||
if(i < j) {
|
if(i < j) {
|
||||||
x = (double)(j-i) / (HYPERSPACE_FLY_DELAY/4.);
|
x = (double)(j-i) / HYPERSPACE_FADEOUT;
|
||||||
glColor4d(1.,1.,1.,pow(x,4)); // We'll | I'll, make this more effiecent later.
|
glColor4d(1.,1.,1., x); // We'll | I'll, make this more effiecent later.
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2d(-gl_screen.w/2., -gl_screen.h/2.);
|
glVertex2d(-gl_screen.w/2., -gl_screen.h/2.);
|
||||||
glVertex2d(-gl_screen.w/2., gl_screen.h/2.);
|
glVertex2d(-gl_screen.w/2., gl_screen.h/2.);
|
||||||
|
69
src/space.c
69
src/space.c
@ -521,24 +521,57 @@ int space_load(void) {
|
|||||||
// Render the system. -- Just playing god now.
|
// Render the system. -- Just playing god now.
|
||||||
void space_render(double dt) {
|
void space_render(double dt) {
|
||||||
int i;
|
int i;
|
||||||
glBegin(GL_POINTS);
|
unsigned int t, timer;
|
||||||
for(i = 0; i < nstars; i++) {
|
double x, y, m;
|
||||||
if(!paused && !toolkit) {
|
|
||||||
// Update the position.
|
glMatrixMode(GL_MODELVIEW);
|
||||||
stars[i].x -= VX(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
|
glPushMatrix(); // Translation matrix.
|
||||||
stars[i].y -= VY(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
|
glTranslated(-(double)gl_screen.w/2., -(double)gl_screen.h/2., 0);
|
||||||
// Scroll those stars bitch!
|
|
||||||
if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF;
|
t = SDL_GetTicks();
|
||||||
else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF;
|
timer = player->ptimer - HYPERSPACE_STARS_BLUR;
|
||||||
if(stars[i].y > gl_screen.h + STAR_BUF) stars[i].y = -STAR_BUF;
|
if(pilot_isFlag(player, PILOT_HYPERSPACE) && (timer < t)) {
|
||||||
else if(stars[i].y < -STAR_BUF) stars[i].y = gl_screen.h + STAR_BUF;
|
// Fancy hyperspace effects.
|
||||||
}
|
glShadeModel(GL_SMOOTH);
|
||||||
// Render.
|
|
||||||
glColor4d(1., 1., 1., stars[i].brightness);
|
glBegin(GL_LINES);
|
||||||
glVertex2d(stars[i].x - (double)gl_screen.w/2.,
|
|
||||||
stars[i].y - (double)gl_screen.h/2.);
|
// Lines will be based on velocity.
|
||||||
}
|
m = 250*(double)(t-timer)/(HYPERSPACE_STARS_BLUR);
|
||||||
glEnd();
|
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.
|
// Render the planets.
|
||||||
|
Loading…
Reference in New Issue
Block a user