Diffstat (limited to 'noncore/games/sfcave-sdl/gates_game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/gates_game.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/noncore/games/sfcave-sdl/gates_game.cpp b/noncore/games/sfcave-sdl/gates_game.cpp index 1a9bc89..762801d 100644 --- a/noncore/games/sfcave-sdl/gates_game.cpp +++ b/noncore/games/sfcave-sdl/gates_game.cpp | |||
@@ -9,24 +9,25 @@ GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) | |||
9 | { | 9 | { |
10 | gameName = "Gates"; | 10 | gameName = "Gates"; |
11 | difficulty = MENU_DIFFICULTY_EASY; | 11 | difficulty = MENU_DIFFICULTY_EASY; |
12 | blockUpdateRate = 200; | 12 | blockUpdateRate = 200; |
13 | 13 | ||
14 | terrain = new Terrain( w, h ); | 14 | terrain = new Terrain( w, h ); |
15 | player = new Player( w, h ); | 15 | player = new Player( w, h ); |
16 | highScore = 0; | 16 | highScore = 0; |
17 | } | 17 | } |
18 | 18 | ||
19 | GatesGame :: ~GatesGame() | 19 | GatesGame :: ~GatesGame() |
20 | { | 20 | { |
21 | // terrain and player get deleted by parent class | ||
21 | } | 22 | } |
22 | 23 | ||
23 | void GatesGame :: init() | 24 | void GatesGame :: init() |
24 | { | 25 | { |
25 | Game :: init(); | 26 | Game :: init(); |
26 | 27 | ||
27 | blockHeight = 80; | 28 | blockHeight = 80; |
28 | blockWidth = 20; | 29 | blockWidth = 20; |
29 | lastGateBottomY = 0; | 30 | lastGateBottomY = 0; |
30 | 31 | ||
31 | gateDistance = 75; | 32 | gateDistance = 75; |
32 | nextGate = nextInt( 50 ) + gateDistance; | 33 | nextGate = nextInt( 50 ) + gateDistance; |
@@ -37,24 +38,37 @@ void GatesGame :: init() | |||
37 | case MENU_DIFFICULTY_EASY: | 38 | case MENU_DIFFICULTY_EASY: |
38 | gapHeight = 75; | 39 | gapHeight = 75; |
39 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 40 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
40 | break; | 41 | break; |
41 | case MENU_DIFFICULTY_NORMAL: | 42 | case MENU_DIFFICULTY_NORMAL: |
42 | gapHeight = 50; | 43 | gapHeight = 50; |
43 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 44 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
44 | break; | 45 | break; |
45 | case MENU_DIFFICULTY_HARD: | 46 | case MENU_DIFFICULTY_HARD: |
46 | gapHeight = 25; | 47 | gapHeight = 25; |
47 | player->setMovementInfo( 0.6, 0.8, 6, 7 ); | 48 | player->setMovementInfo( 0.6, 0.8, 6, 7 ); |
48 | break; | 49 | break; |
50 | case MENU_DIFFICULTY_CUSTOM: | ||
51 | { | ||
52 | // Read custom difficulty settings for this game | ||
53 | gapHeight = parent->loadIntSetting( "Gates_custom_gapHeight", 75 ); | ||
54 | |||
55 | double thrust = parent->loadDoubleSetting( "Gates_custom_player_thrust", 0.4 ); | ||
56 | double gravity = parent->loadDoubleSetting( "Gates_custom_player_gravity", 0.6 ); | ||
57 | double maxUp = parent->loadDoubleSetting( "Gates_custom_player_maxupspeed", 4.0 ); | ||
58 | double maxDown = parent->loadDoubleSetting( "Gates_custom_player_maxdownspeed", 5.0 ); | ||
59 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | ||
60 | |||
61 | break; | ||
62 | } | ||
49 | } | 63 | } |
50 | 64 | ||
51 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 65 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
52 | blocks[i].y( -1 ); | 66 | blocks[i].y( -1 ); |
53 | } | 67 | } |
54 | 68 | ||
55 | void GatesGame :: update( int state ) | 69 | void GatesGame :: update( int state ) |
56 | { | 70 | { |
57 | Game::update( state ); | 71 | Game::update( state ); |
58 | 72 | ||
59 | // Game logic goes here | 73 | // Game logic goes here |
60 | if ( state == STATE_PLAYING ) | 74 | if ( state == STATE_PLAYING ) |
@@ -68,25 +82,24 @@ void GatesGame :: update( int state ) | |||
68 | gapHeight -= 5; | 82 | gapHeight -= 5; |
69 | } | 83 | } |
70 | 84 | ||
71 | // Slightly random gap distance | 85 | // Slightly random gap distance |
72 | if ( nrFrames >= nextGate ) | 86 | if ( nrFrames >= nextGate ) |
73 | { | 87 | { |
74 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; | 88 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; |
75 | addGate(); | 89 | addGate(); |
76 | } | 90 | } |
77 | 91 | ||
78 | if ( checkCollisions() ) | 92 | if ( checkCollisions() ) |
79 | { | 93 | { |
80 | // printf( "Crashed!\n" ); | ||
81 | parent->changeState( STATE_CRASHING ); | 94 | parent->changeState( STATE_CRASHING ); |
82 | return; | 95 | return; |
83 | } | 96 | } |
84 | 97 | ||
85 | terrain->moveTerrain( 5 ); | 98 | terrain->moveTerrain( 5 ); |
86 | moveBlocks( 5 ); | 99 | moveBlocks( 5 ); |
87 | player->move( press ); | 100 | player->move( press ); |
88 | } | 101 | } |
89 | } | 102 | } |
90 | 103 | ||
91 | void GatesGame :: draw( SDL_Surface *screen ) | 104 | void GatesGame :: draw( SDL_Surface *screen ) |
92 | { | 105 | { |