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 | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/noncore/games/sfcave-sdl/sfcave_game.cpp b/noncore/games/sfcave-sdl/sfcave_game.cpp index 72c5ce3..1b00e14 100644 --- a/noncore/games/sfcave-sdl/sfcave_game.cpp +++ b/noncore/games/sfcave-sdl/sfcave_game.cpp | |||
@@ -18,78 +18,90 @@ SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) | |||
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(); | 25 | Game :: init(); |
26 | 26 | ||
27 | blockDistance = 50; | 27 | blockDistance = 50; |
28 | blockHeight = 80; | 28 | blockHeight = 80; |
29 | blockWidth = 20; | 29 | blockWidth = 20; |
30 | 30 | ||
31 | switch( difficulty ) | 31 | switch( difficulty ) |
32 | { | 32 | { |
33 | case MENU_DIFFICULTY_EASY: | 33 | case MENU_DIFFICULTY_EASY: |
34 | blockDistance = 50; | 34 | blockDistance = 50; |
35 | break; | 35 | break; |
36 | case MENU_DIFFICULTY_NORMAL: | 36 | case MENU_DIFFICULTY_NORMAL: |
37 | blockDistance = 40; | 37 | blockDistance = 40; |
38 | break; | 38 | break; |
39 | case MENU_DIFFICULTY_HARD: | 39 | case MENU_DIFFICULTY_HARD: |
40 | blockDistance = 30; | 40 | blockDistance = 30; |
41 | break; | 41 | break; |
42 | case MENU_DIFFICULTY_CUSTOM: | ||
43 | { | ||
44 | // Read custom difficulty settings for this game | ||
45 | blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 ); | ||
46 | |||
47 | double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 ); | ||
48 | double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 ); | ||
49 | double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 ); | ||
50 | double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 ); | ||
51 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | ||
52 | |||
53 | break; | ||
54 | } | ||
42 | } | 55 | } |
43 | 56 | ||
44 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) | 57 | for ( int i = 0 ; i < BLOCKSIZE ; ++i ) |
45 | blocks[i].y( -1 ); | 58 | blocks[i].y( -1 ); |
46 | } | 59 | } |
47 | 60 | ||
48 | void SFCaveGame :: update( int state ) | 61 | void SFCaveGame :: update( int state ) |
49 | { | 62 | { |
50 | Game::update( state ); | 63 | Game::update( state ); |
51 | 64 | ||
52 | if ( state == STATE_PLAYING ) | 65 | if ( state == STATE_PLAYING ) |
53 | { | 66 | { |
54 | if ( nrFrames % 3 == 0 ) | 67 | if ( nrFrames % 3 == 0 ) |
55 | score ++; | 68 | score ++; |
56 | 69 | ||
57 | if ( nrFrames % 200 == 0 ) | 70 | if ( nrFrames % 200 == 0 ) |
58 | { | 71 | { |
59 | if ( terrain->getMaxHeight() < sHeight - 100 ) | 72 | if ( terrain->getMaxHeight() < sHeight - 100 ) |
60 | { | 73 | { |
61 | terrain->increaseMaxHeight( 10 ); | 74 | terrain->increaseMaxHeight( 10 ); |
62 | 75 | ||
63 | // Reduce block height | 76 | // Reduce block height |
64 | if ( terrain->getMaxHeight() > sHeight - 150 ) | 77 | if ( terrain->getMaxHeight() > sHeight - 150 ) |
65 | blockHeight -= 5; | 78 | blockHeight -= 5; |
66 | } | 79 | } |
67 | } | 80 | } |
68 | 81 | ||
69 | if ( checkCollisions() ) | 82 | if ( checkCollisions() ) |
70 | { | 83 | { |
71 | // printf( "Crashed!\n" ); | ||
72 | parent->changeState( STATE_CRASHING ); | 84 | parent->changeState( STATE_CRASHING ); |
73 | return; | 85 | return; |
74 | } | 86 | } |
75 | 87 | ||
76 | if ( nrFrames % blockDistance == 0 ) | 88 | if ( nrFrames % blockDistance == 0 ) |
77 | addBlock(); | 89 | addBlock(); |
78 | 90 | ||
79 | // Game logic goes here | 91 | // Game logic goes here |
80 | terrain->moveTerrain( 5 ); | 92 | terrain->moveTerrain( 5 ); |
81 | moveBlocks( 5 ); | 93 | moveBlocks( 5 ); |
82 | player->move( press ); | 94 | player->move( press ); |
83 | } | 95 | } |
84 | } | 96 | } |
85 | 97 | ||
86 | void SFCaveGame :: draw( SDL_Surface *screen ) | 98 | void SFCaveGame :: draw( SDL_Surface *screen ) |
87 | { | 99 | { |
88 | Game::preDraw( screen ); | 100 | Game::preDraw( screen ); |
89 | 101 | ||
90 | if ( parent->getState() == STATE_PLAYING ) | 102 | if ( parent->getState() == STATE_PLAYING ) |
91 | { | 103 | { |
92 | // Screen drawing goes here | 104 | // Screen drawing goes here |
93 | terrain->drawTerrain( screen ); | 105 | terrain->drawTerrain( screen ); |
94 | 106 | ||
95 | player->draw( screen ); | 107 | player->draw( screen ); |