-rw-r--r-- | noncore/games/sfcave-sdl/fly_game.cpp | 3 | ||||
-rw-r--r-- | noncore/games/sfcave-sdl/gates_game.cpp | 4 | ||||
-rw-r--r-- | noncore/games/sfcave-sdl/player.cpp | 2 | ||||
-rw-r--r-- | noncore/games/sfcave-sdl/sfcave_game.cpp | 4 |
4 files changed, 6 insertions, 7 deletions
diff --git a/noncore/games/sfcave-sdl/fly_game.cpp b/noncore/games/sfcave-sdl/fly_game.cpp index 7605c3f..8b05d8f 100644 --- a/noncore/games/sfcave-sdl/fly_game.cpp +++ b/noncore/games/sfcave-sdl/fly_game.cpp | |||
@@ -13,49 +13,48 @@ FlyGame :: FlyGame( SFCave *p, int w, int h, int diff ) | |||
13 | terrain = new FlyTerrain( w, h ); | 13 | terrain = new FlyTerrain( w, h ); |
14 | player = new Player( w, h ); | 14 | player = new Player( w, h ); |
15 | highScore = 0; | 15 | highScore = 0; |
16 | } | 16 | } |
17 | 17 | ||
18 | FlyGame :: ~FlyGame() | 18 | FlyGame :: ~FlyGame() |
19 | { | 19 | { |
20 | // terrain and player get deleted by parent class | 20 | // terrain and player get deleted by parent class |
21 | } | 21 | } |
22 | 22 | ||
23 | void FlyGame :: init() | 23 | void FlyGame :: init() |
24 | { | 24 | { |
25 | Game :: init(); | ||
26 | |||
27 | switch( difficulty ) | 25 | switch( difficulty ) |
28 | { | 26 | { |
29 | case MENU_DIFFICULTY_EASY: | 27 | case MENU_DIFFICULTY_EASY: |
30 | player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 ); | 28 | player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 ); |
31 | break; | 29 | break; |
32 | case MENU_DIFFICULTY_NORMAL: | 30 | case MENU_DIFFICULTY_NORMAL: |
33 | player->setMovementInfo( 0.35, 0.4, 2.5, 3 ); | 31 | player->setMovementInfo( 0.35, 0.4, 2.5, 3 ); |
34 | break; | 32 | break; |
35 | case MENU_DIFFICULTY_HARD: | 33 | case MENU_DIFFICULTY_HARD: |
36 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 34 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
37 | break; | 35 | break; |
38 | case MENU_DIFFICULTY_CUSTOM: | 36 | case MENU_DIFFICULTY_CUSTOM: |
39 | { | 37 | { |
40 | double thrust = parent->loadDoubleSetting( "Fly_custom_player_thrust", 0.3 ); | 38 | double thrust = parent->loadDoubleSetting( "Fly_custom_player_thrust", 0.3 ); |
41 | double gravity = parent->loadDoubleSetting( "Fly_custom_player_gravity", 0.2 ); | 39 | double gravity = parent->loadDoubleSetting( "Fly_custom_player_gravity", 0.2 ); |
42 | double maxUp = parent->loadDoubleSetting( "Fly_custom_player_maxupspeed", 1.5 ); | 40 | double maxUp = parent->loadDoubleSetting( "Fly_custom_player_maxupspeed", 1.5 ); |
43 | double maxDown = parent->loadDoubleSetting( "Fly_custom_player_maxdownspeed", 1.5 ); | 41 | double maxDown = parent->loadDoubleSetting( "Fly_custom_player_maxdownspeed", 1.5 ); |
44 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | 42 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); |
45 | break; | 43 | break; |
46 | } | 44 | } |
47 | } | 45 | } |
48 | 46 | ||
49 | startScoring = false; | 47 | startScoring = false; |
48 | Game :: init(); | ||
50 | } | 49 | } |
51 | 50 | ||
52 | void FlyGame :: update( int state ) | 51 | void FlyGame :: update( int state ) |
53 | { | 52 | { |
54 | Game::update( state ); | 53 | Game::update( state ); |
55 | 54 | ||
56 | if ( state == STATE_PLAYING ) | 55 | if ( state == STATE_PLAYING ) |
57 | { | 56 | { |
58 | 57 | ||
59 | if ( nrFrames % 3 == 0 ) | 58 | if ( nrFrames % 3 == 0 ) |
60 | { | 59 | { |
61 | int diff = terrain->getMapBottom( 10 ) - player->getY(); | 60 | int diff = terrain->getMapBottom( 10 ) - player->getY(); |
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 | |||
@@ -14,26 +14,24 @@ GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) | |||
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; |
@@ -55,24 +53,26 @@ void GatesGame :: init() | |||
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 | ||
diff --git a/noncore/games/sfcave-sdl/player.cpp b/noncore/games/sfcave-sdl/player.cpp index 2d52ae2..f024d6b 100644 --- a/noncore/games/sfcave-sdl/player.cpp +++ b/noncore/games/sfcave-sdl/player.cpp | |||
@@ -24,25 +24,25 @@ Player :: ~Player() | |||
24 | { | 24 | { |
25 | if ( explosion ) | 25 | if ( explosion ) |
26 | delete explosion; | 26 | delete explosion; |
27 | } | 27 | } |
28 | 28 | ||
29 | void Player :: init() | 29 | void Player :: init() |
30 | { | 30 | { |
31 | // Set player position | 31 | // Set player position |
32 | pos.x( 50 ); | 32 | pos.x( 50 ); |
33 | pos.y( sWidth/2 ); | 33 | pos.y( sWidth/2 ); |
34 | pos.h( 2 ); | 34 | pos.h( 2 ); |
35 | pos.w( 4 ); | 35 | pos.w( 4 ); |
36 | thrust = 0; | 36 | currentThrust = 0; |
37 | crashing = false; | 37 | crashing = false; |
38 | crashLineLength = 0; | 38 | crashLineLength = 0; |
39 | crashed = false; | 39 | crashed = false; |
40 | explosion->reset(); | 40 | explosion->reset(); |
41 | allFaded = false; | 41 | allFaded = false; |
42 | expNextFrame = false; | 42 | expNextFrame = false; |
43 | 43 | ||
44 | // Reset Trail | 44 | // Reset Trail |
45 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) | 45 | for ( int i = 0 ; i < TRAILSIZE ; ++i ) |
46 | { | 46 | { |
47 | trail[i].x( -1 ); | 47 | trail[i].x( -1 ); |
48 | trail[i].y( 0 ); | 48 | trail[i].y( 0 ); |
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 | |||
@@ -13,26 +13,24 @@ SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) | |||
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; |
@@ -47,24 +45,26 @@ void SFCaveGame :: init() | |||
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 ) |