diff --git a/src/pilot.h b/src/pilot.h index 6b9a814..6402422 100644 --- a/src/pilot.h +++ b/src/pilot.h @@ -15,6 +15,7 @@ #define HYPERSPACE_STARS_BLUR 2000 // Time stars blur. #define HYPERSPACE_STARS_LENGTH 1000 // Length the stars blur to at max. #define HYPERSPACE_FADEOUT 1000 // Time fadeout. +#define HYPERSPACE_FUEL 100 // Amount of fuel taken. // Aproximation for pilot size. #define PILOT_SIZE_APROX 0.8 diff --git a/src/player.c b/src/player.c index 401e9cc..1e5fc96 100644 --- a/src/player.c +++ b/src/player.c @@ -603,7 +603,8 @@ void player_render(void) { c, "Hyperspace"); gl_printMid(&gl_smallFont, (int)gui.nav.w, gui.nav.x, - gui.nav.y - 10 - gl_smallFont.h, NULL, "%s", + gui.nav.y - 10 - gl_smallFont.h, + NULL, "%d - %s", (int)(player->fuel) / HYPERSPACE_FUEL, systems_stack[cur_system->jumps[hyperspace_target]].name); } else { @@ -1260,6 +1261,8 @@ void player_jump(void) { player_message("You are too close to gravity centers to initiate hyperspace."); else if(i == -2) player_message("You are moving too fast to enter hyperspace."); + else if(i == -3) + player_message("You do not have enough fuel to hyperspace jump."); else player_message("Preparing for hyperspace"); } @@ -1281,6 +1284,9 @@ void player_brokeHyperspace(void) { // Set position, pilot_update will handle the lowering of velocity. player_warp(-cos(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5, -sin(player->solid->dir) * MIN_HYPERSPACE_DIST * 2.5); + + // Reduce fuel. + player->fuel -= HYPERSPACE_FUEL; // Stop hyperspace. pilot_rmFlag(player, PILOT_HYPERSPACE | PILOT_HYP_BEGIN | PILOT_HYP_PREP); diff --git a/src/space.c b/src/space.c index 8b2b389..bda1c0b 100644 --- a/src/space.c +++ b/src/space.c @@ -377,6 +377,8 @@ static PlanetClass planetclass_get(const char a) { int space_canHyperspace(Pilot* p) { int i; double d; + if(p->fuel < HYPERSPACE_FUEL) return 0; + for(i = 0; i < cur_system->nplanets; i++) { d = vect_dist(&p->solid->pos, &cur_system->planets[i].pos); if(d < MIN_HYPERSPACE_DIST) @@ -387,6 +389,7 @@ int space_canHyperspace(Pilot* p) { // Hyperspace, returns 0 if entering hyperspace, or the distance if not. int space_hyperspace(Pilot* p) { + if(p->fuel < HYPERSPACE_FUEL) return -3; if(!space_canHyperspace(p)) return -1; // Pilot is now going to get automatically ready for hyperspace.