[Change] Some cosmetic changes to Hyperspace.

This commit is contained in:
Allanis 2013-03-16 16:47:49 +00:00
parent dd79adb0af
commit eb98a0deaf
3 changed files with 26 additions and 6 deletions

View File

@ -37,6 +37,7 @@ extern void ai_think(Pilot* pilot); // Ai.c
extern void ai_create(Pilot* pilot); // ai.c extern void ai_create(Pilot* pilot); // ai.c
extern void player_think(Pilot* pilot); // Player.c extern void player_think(Pilot* pilot); // Player.c
extern void player_brokeHyperspace(void); // Player.c extern void player_brokeHyperspace(void); // Player.c
extern double player_faceHyperspace(void); // Player.c
extern int gui_load(const char* name); // Player.c extern int gui_load(const char* name); // Player.c
// Internal. // Internal.
static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t); static void pilot_shootWeapon(Pilot* p, PilotOutfit* w, const unsigned int t);
@ -368,6 +369,8 @@ static void pilot_update(Pilot* pilot, const double dt) {
// Pilot is getting ready or is in, hyperspace. // Pilot is getting ready or is in, hyperspace.
static void pilot_hyperspace(Pilot* p) { static void pilot_hyperspace(Pilot* p) {
double diff;
if(pilot_isFlag(p, PILOT_HYPERSPACE)) { if(pilot_isFlag(p, PILOT_HYPERSPACE)) {
// Pilot is actually in hyperspace. // Pilot is actually in hyperspace.
if(SDL_GetTicks() > p->ptimer) { if(SDL_GetTicks() > p->ptimer) {
@ -387,7 +390,6 @@ static void pilot_hyperspace(Pilot* p) {
} }
} else { } else {
// Pilot is getting ready for hyperspace. // Pilot is getting ready for hyperspace.
double diff;
if(VMOD(p->solid->vel) > MIN_VEL_ERR) { if(VMOD(p->solid->vel) > MIN_VEL_ERR) {
diff = pilot_face(p, VANGLE(p->solid->vel) + M_PI); diff = pilot_face(p, VANGLE(p->solid->vel) + M_PI);
@ -396,7 +398,10 @@ static void pilot_hyperspace(Pilot* p) {
vect_pset(&p->solid->force, p->ship->thrust, p->solid->dir); vect_pset(&p->solid->force, p->ship->thrust, p->solid->dir);
} else { } else {
vectnull(&p->solid->force); // Stop accelerating. vectnull(&p->solid->force); // Stop accelerating.
diff = pilot_face(p, VANGLE(p->solid->pos));
// Player should actually face the system she's headed to.
if(p == player) diff = player_faceHyperspace();
else diff = pilot_face(p, VANGLE(p->solid->pos));
if(ABS(diff) < MAX_DIR_ERR) { if(ABS(diff) < MAX_DIR_ERR) {
// We should prepare for the jump now. // We should prepare for the jump now.

View File

@ -20,9 +20,9 @@
#define PILOT_DISABLED_ARMOUR 0.2 // Based on armour percentage. #define PILOT_DISABLED_ARMOUR 0.2 // Based on armour percentage.
// Flags. // Flags.
#define pilot_isFlag(p,f) (p->flags & f) #define pilot_isFlag(p,f) (p->flags & (f))
#define pilot_setFlag(p,f) (p->flags |= f) #define pilot_setFlag(p,f) (p->flags |= (f))
#define pilot_rmFlag(p,f) (p->flags ^= f) #define pilot_rmFlag(p,f) (p->flags ^= (f))
// Creation. // Creation.
#define PILOT_PLAYER (1<<0) // Pilot is a player. #define PILOT_PLAYER (1<<0) // Pilot is a player.
#define PILOT_HASTURRET (1<<20) // Pilit has turrets. #define PILOT_HASTURRET (1<<20) // Pilit has turrets.

View File

@ -983,7 +983,11 @@ void player_targetHyperspace(void) {
// Actually attempt to jump into hyperspace. // Actually attempt to jump into hyperspace.
void player_jump(void) { void player_jump(void) {
if(hyperspace_target == -1) return; if((hyperspace_target == -1) ||
pilot_isFlag(player, PILOT_HYP_PREP) ||
pilot_isFlag(player, PILOT_HYP_BEGIN) ||
pilot_isFlag(player, PILOT_HYPERSPACE))
return;
int i = space_hyperspace(player); int i = space_hyperspace(player);
@ -1010,6 +1014,17 @@ void player_brokeHyperspace(void) {
player_message("BANG!"); player_message("BANG!");
} }
// Make the player face her hyperspace target.
double player_faceHyperspace(void) {
double a;
a = ANGLE(systems_stack[cur_system->jumps[hyperspace_target]].pos.x -
cur_system->pos.x,
systems_stack[cur_system->jumps[hyperspace_target]].pos.y -
cur_system->pos.y);
return pilot_face(player, a);
}
// Take a screenshot. // Take a screenshot.
static int screenshot_cur = 0; static int screenshot_cur = 0;
void player_screenshot(void) { void player_screenshot(void) {