[Change] Improved transition into hyperspace a little.

This commit is contained in:
Allanis 2013-02-20 20:10:36 +00:00
parent 44c6ea6ed6
commit b2a887ba45
2 changed files with 20 additions and 9 deletions

View File

@ -275,13 +275,24 @@ static void pilot_hyperspace(Pilot* p) {
pilot_setFlag(p, PILOT_HYPERSPACE); pilot_setFlag(p, PILOT_HYPERSPACE);
} }
} else { } else {
double diff = pilot_face(p, VANGLE(player->solid->pos)); // Pilot is getting ready for hyperspace.
double diff;
if(diff < MAX_DIR_ERR) { if(VMOD(p->solid->vel) > MIN_VEL_ERR) {
// We can now prepare the jump. diff = pilot_face(p, VANGLE(player->solid->vel) + M_PI);
p->solid->dir_vel = 0.;
p->ptimer = SDL_GetTicks() + HYPERSPACE_ENGINE_DELAY; if(ABS(diff) < MAX_DIR_ERR) // Brake.
pilot_setFlag(p, PILOT_HYP_BEGIN); vect_pset(&p->solid->force, p->ship->thrust, p->solid->dir);
} else {
vectnull(&p->solid->force); // Stop accelerating.
diff = pilot_face(p, VANGLE(player->solid->pos));
if(ABS(diff) < MAX_DIR_ERR) {
// We should prepare for the jump now.
p->solid->dir_vel = 0.;
p->ptimer = SDL_GetTicks() + HYPERSPACE_ENGINE_DELAY;
pilot_setFlag(p, PILOT_HYP_BEGIN);
}
} }
} }
} }

View File

@ -168,7 +168,7 @@ int space_canHyperspace(Pilot* p) {
int space_hyperspace(Pilot* p) { int space_hyperspace(Pilot* p) {
if(!space_canHyperspace(p)) return -1; if(!space_canHyperspace(p)) return -1;
// Too fast. // Too fast.
if(VMOD(p->solid->vel) > MAX_HYPERSPACE_VEL) return -2; //if(VMOD(p->solid->vel) > MAX_HYPERSPACE_VEL) return -2;
// Pilot is now going to get automatically ready for hyperspace. // Pilot is now going to get automatically ready for hyperspace.
pilot_setFlag(p, PILOT_HYP_PREP); pilot_setFlag(p, PILOT_HYP_PREP);
@ -527,8 +527,8 @@ void space_render(double dt) {
for(i = 0; i < nstars; i++) { for(i = 0; i < nstars; i++) {
if(!paused && !toolkit) { if(!paused && !toolkit) {
// Update the position. // Update the position.
stars[i].x -= VX(player->solid->vel)/(15.-10.*stars[i].brightness)*dt; stars[i].x -= VX(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
stars[i].y -= VY(player->solid->vel)/(15.-10.*stars[i].brightness)*dt; stars[i].y -= VY(player->solid->vel)/(13.-10.*stars[i].brightness)*dt;
// Scroll those stars bitch! // Scroll those stars bitch!
if(stars[i].x > gl_screen.w + STAR_BUF) stars[i].x = -STAR_BUF; 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; else if(stars[i].x < -STAR_BUF) stars[i].x = gl_screen.w + STAR_BUF;