Diffstat (limited to 'noncore/games/sfcave-sdl/sfcave_game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/sfcave_game.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/sfcave-sdl/sfcave_game.cpp b/noncore/games/sfcave-sdl/sfcave_game.cpp index 1b00e14..8fdbbe5 100644 --- a/noncore/games/sfcave-sdl/sfcave_game.cpp +++ b/noncore/games/sfcave-sdl/sfcave_game.cpp | |||
@@ -1,82 +1,82 @@ | |||
1 | #include "SDL_gfxPrimitives.h" | 1 | #include "SDL_gfxPrimitives.h" |
2 | 2 | ||
3 | #include "constants.h" | 3 | #include "constants.h" |
4 | #include "sfcave_game.h" | 4 | #include "sfcave_game.h" |
5 | #include "random.h" | 5 | #include "random.h" |
6 | 6 | ||
7 | SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) | 7 | SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) |
8 | : Game( p, w, h, diff ) | 8 | : Game( p, w, h, diff ) |
9 | { | 9 | { |
10 | gameName = "SFCave"; | 10 | gameName = "SFCave"; |
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 | SFCaveGame :: ~SFCaveGame() | 19 | SFCaveGame :: ~SFCaveGame() |
20 | { | 20 | { |
21 | } | 21 | } |
22 | 22 | ||
23 | void SFCaveGame :: init() | 23 | void SFCaveGame :: init() |
24 | { | 24 | { |
25 | Game :: init(); | ||
26 | |||
27 | blockDistance = 50; | 25 | blockDistance = 50; |
28 | blockHeight = 80; | 26 | blockHeight = 80; |
29 | blockWidth = 20; | 27 | blockWidth = 20; |
30 | 28 | ||
31 | switch( difficulty ) | 29 | switch( difficulty ) |
32 | { | 30 | { |
33 | case MENU_DIFFICULTY_EASY: | 31 | case MENU_DIFFICULTY_EASY: |
34 | blockDistance = 50; | 32 | blockDistance = 50; |
35 | break; | 33 | break; |
36 | case MENU_DIFFICULTY_NORMAL: | 34 | case MENU_DIFFICULTY_NORMAL: |
37 | blockDistance = 40; | 35 | blockDistance = 40; |
38 | break; | 36 | break; |
39 | case MENU_DIFFICULTY_HARD: | 37 | case MENU_DIFFICULTY_HARD: |
40 | blockDistance = 30; | 38 | blockDistance = 30; |
41 | break; | 39 | break; |
42 | case MENU_DIFFICULTY_CUSTOM: | 40 | case MENU_DIFFICULTY_CUSTOM: |
43 | { | 41 | { |
44 | // Read custom difficulty settings for this game | 42 | // Read custom difficulty settings for this game |
45 | blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 ); | 43 | blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 ); |
46 | 44 | ||
47 | double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 ); | 45 | double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 ); |
48 | double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 ); | 46 | double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 ); |
49 | double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 ); | 47 | double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 ); |
50 | double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 ); | 48 | double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 ); |
51 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | 49 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); |
52 | 50 | ||
53 | break; | 51 | break; |
54 | } | 52 | } |
55 | } | 53 | } |
56 | 54 | ||
57 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 55 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
58 | blocks[i].y( -1 ); | 56 | blocks[i].y( -1 ); |
57 | |||
58 | Game :: init(); | ||
59 | } | 59 | } |
60 | 60 | ||
61 | void SFCaveGame :: update( int state ) | 61 | void SFCaveGame :: update( int state ) |
62 | { | 62 | { |
63 | Game::update( state ); | 63 | Game::update( state ); |
64 | 64 | ||
65 | if ( state == STATE_PLAYING ) | 65 | if ( state == STATE_PLAYING ) |
66 | { | 66 | { |
67 | if ( nrFrames % 3 == 0 ) | 67 | if ( nrFrames % 3 == 0 ) |
68 | score ++; | 68 | score ++; |
69 | 69 | ||
70 | if ( nrFrames % 200 == 0 ) | 70 | if ( nrFrames % 200 == 0 ) |
71 | { | 71 | { |
72 | if ( terrain->getMaxHeight() < sHeight - 100 ) | 72 | if ( terrain->getMaxHeight() < sHeight - 100 ) |
73 | { | 73 | { |
74 | terrain->increaseMaxHeight( 10 ); | 74 | terrain->increaseMaxHeight( 10 ); |
75 | 75 | ||
76 | // Reduce block height | 76 | // Reduce block height |
77 | if ( terrain->getMaxHeight() > sHeight - 150 ) | 77 | if ( terrain->getMaxHeight() > sHeight - 150 ) |
78 | blockHeight -= 5; | 78 | blockHeight -= 5; |
79 | } | 79 | } |
80 | } | 80 | } |
81 | 81 | ||
82 | if ( checkCollisions() ) | 82 | if ( checkCollisions() ) |