author | andyq <andyq> | 2003-01-21 21:09:36 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-21 21:09:36 (UTC) |
commit | 6b3b53262213e4e4f73ffab2266ea3b4a7813fe4 (patch) (unidiff) | |
tree | 896759614d5601570f259525c000a8be4db4d68d /noncore/games/sfcave-sdl/gates_game.cpp | |
parent | 0a6563fcc2f49857c581d9def24407a3a4ef526c (diff) | |
download | opie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.zip opie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.tar.gz opie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.tar.bz2 |
Small bug fix
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 | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/sfcave-sdl/gates_game.cpp b/noncore/games/sfcave-sdl/gates_game.cpp index 762801d..700a6ec 100644 --- a/noncore/games/sfcave-sdl/gates_game.cpp +++ b/noncore/games/sfcave-sdl/gates_game.cpp | |||
@@ -2,89 +2,89 @@ | |||
2 | 2 | ||
3 | #include "constants.h" | 3 | #include "constants.h" |
4 | #include "gates_game.h" | 4 | #include "gates_game.h" |
5 | #include "random.h" | 5 | #include "random.h" |
6 | 6 | ||
7 | GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) | 7 | GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) |
8 | : Game( p, w, h, diff ) | 8 | : Game( p, w, h, 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 | // terrain and player get deleted by parent class |
22 | } | 22 | } |
23 | 23 | ||
24 | void GatesGame :: init() | 24 | void GatesGame :: init() |
25 | { | 25 | { |
26 | Game :: init(); | ||
27 | |||
28 | blockHeight = 80; | 26 | blockHeight = 80; |
29 | blockWidth = 20; | 27 | blockWidth = 20; |
30 | lastGateBottomY = 0; | 28 | lastGateBottomY = 0; |
31 | 29 | ||
32 | gateDistance = 75; | 30 | gateDistance = 75; |
33 | nextGate = nextInt( 50 ) + gateDistance; | 31 | nextGate = nextInt( 50 ) + gateDistance; |
34 | gapHeight = 75; | 32 | gapHeight = 75; |
35 | 33 | ||
36 | switch( difficulty ) | 34 | switch( difficulty ) |
37 | { | 35 | { |
38 | case MENU_DIFFICULTY_EASY: | 36 | case MENU_DIFFICULTY_EASY: |
39 | gapHeight = 75; | 37 | gapHeight = 75; |
40 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 38 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
41 | break; | 39 | break; |
42 | case MENU_DIFFICULTY_NORMAL: | 40 | case MENU_DIFFICULTY_NORMAL: |
43 | gapHeight = 50; | 41 | gapHeight = 50; |
44 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 42 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
45 | break; | 43 | break; |
46 | case MENU_DIFFICULTY_HARD: | 44 | case MENU_DIFFICULTY_HARD: |
47 | gapHeight = 25; | 45 | gapHeight = 25; |
48 | player->setMovementInfo( 0.6, 0.8, 6, 7 ); | 46 | player->setMovementInfo( 0.6, 0.8, 6, 7 ); |
49 | break; | 47 | break; |
50 | case MENU_DIFFICULTY_CUSTOM: | 48 | case MENU_DIFFICULTY_CUSTOM: |
51 | { | 49 | { |
52 | // Read custom difficulty settings for this game | 50 | // Read custom difficulty settings for this game |
53 | gapHeight = parent->loadIntSetting( "Gates_custom_gapHeight", 75 ); | 51 | gapHeight = parent->loadIntSetting( "Gates_custom_gapHeight", 75 ); |
54 | 52 | ||
55 | double thrust = parent->loadDoubleSetting( "Gates_custom_player_thrust", 0.4 ); | 53 | double thrust = parent->loadDoubleSetting( "Gates_custom_player_thrust", 0.4 ); |
56 | double gravity = parent->loadDoubleSetting( "Gates_custom_player_gravity", 0.6 ); | 54 | double gravity = parent->loadDoubleSetting( "Gates_custom_player_gravity", 0.6 ); |
57 | double maxUp = parent->loadDoubleSetting( "Gates_custom_player_maxupspeed", 4.0 ); | 55 | double maxUp = parent->loadDoubleSetting( "Gates_custom_player_maxupspeed", 4.0 ); |
58 | double maxDown = parent->loadDoubleSetting( "Gates_custom_player_maxdownspeed", 5.0 ); | 56 | double maxDown = parent->loadDoubleSetting( "Gates_custom_player_maxdownspeed", 5.0 ); |
59 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | 57 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); |
60 | 58 | ||
61 | break; | 59 | break; |
62 | } | 60 | } |
63 | } | 61 | } |
64 | 62 | ||
65 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 63 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
66 | blocks[i].y( -1 ); | 64 | blocks[i].y( -1 ); |
65 | |||
66 | Game :: init(); | ||
67 | } | 67 | } |
68 | 68 | ||
69 | void GatesGame :: update( int state ) | 69 | void GatesGame :: update( int state ) |
70 | { | 70 | { |
71 | Game::update( state ); | 71 | Game::update( state ); |
72 | 72 | ||
73 | // Game logic goes here | 73 | // Game logic goes here |
74 | if ( state == STATE_PLAYING ) | 74 | if ( state == STATE_PLAYING ) |
75 | { | 75 | { |
76 | if ( nrFrames % 3 == 0 ) | 76 | if ( nrFrames % 3 == 0 ) |
77 | score ++; | 77 | score ++; |
78 | 78 | ||
79 | if ( nrFrames % 500 == 0 ) | 79 | if ( nrFrames % 500 == 0 ) |
80 | { | 80 | { |
81 | if ( gapHeight > 75 ) | 81 | if ( gapHeight > 75 ) |
82 | gapHeight -= 5; | 82 | gapHeight -= 5; |
83 | } | 83 | } |
84 | 84 | ||
85 | // Slightly random gap distance | 85 | // Slightly random gap distance |
86 | if ( nrFrames >= nextGate ) | 86 | if ( nrFrames >= nextGate ) |
87 | { | 87 | { |
88 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; | 88 | nextGate = nrFrames + nextInt( 50 ) + gateDistance; |
89 | addGate(); | 89 | addGate(); |
90 | } | 90 | } |