1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#include <assert.h>
#include "game_state.h"
#include "globals.h"
#include "highscore_io.h"
#include "ship.h"
#include "sound.h"
void dead_pause() {
play_tune(1);
initialshield = 150;
xship = 10;
yship = ysize / 2;
xvel = 2;
yvel = 0;
shieldlevel = 3 * W;
laserlevel = 3 * W;
}
void handle_state_timeout(int infoscreen_enabled) {
//Ignore any state timeout in GAME PLAY mode.
if(state == GAME_PLAY) return;
// Count down the game loop timer, and change state when it gets to zero or less;
if((state_timeout -= movementrate * 3) < 0) {
switch (state) {
case DEAD_PAUSE:
// Create a new ship and start all over again
state = GAME_PLAY;
dead_pause();
break;
case GAME_OVER:
state = HIGH_SCORE_ENTRY;
game_over();
break;
case HIGH_SCORE_DISPLAY:
if(infoscreen_enabled) {
state = INFO_SCREEN;
state_timeout = 593.0002;
} else {
state = TITLE_PAGE;
state_timeout = 500.0;
}
break;
case INFO_SCREEN:
state = TITLE_PAGE;
state_timeout = 500.0;
break;
case HIGH_SCORE_ENTRY:
// state = TITLE_PAGE;
// play_tune(1);
// state_timeout=100.0;
break;
case TITLE_PAGE:
state = DEMO;
state_timeout = 400.0;
sfx_enabled = 0;
reset_ship_state();
level = 0;
break;
case DEMO:
state = HIGH_SCORE_DISPLAY;
state_timeout = 242.365;
break;
case SETUP:
state = TITLE_PAGE;
state_timeout = 500.0;
break;
case GAME_PLAY:
case RESTART_GAME:
assert(0); //Never happens.
break;
case GAME_PAUSED:
case QUIT_GAME:
break;
}
}
}
void pausegame() {
switch(state) {
case GAME_PLAY:
state = GAME_PAUSED;
break;
case GAME_PAUSED:
state = GAME_PLAY;
break;
default:
assert(0);
}
}
void reset_ship_state() {
nships = 4;
clear_score();
xvel = 0;
yvel = 0;
xship = 10;
yship = ysize / 2;
shieldlevel = 3 * W;
laserlevel = 3 * W;
initialshield = 150;
}
|