author | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-21 20:37:00 (UTC) |
commit | 0a6563fcc2f49857c581d9def24407a3a4ef526c (patch) (unidiff) | |
tree | f1b82a4bd7582ef2cb722cffb87eecff1e1f96e6 /noncore/games/sfcave-sdl/fly_game.cpp | |
parent | 50b5915b48fc5cbacf23e4d2b75d7a266f141a4a (diff) | |
download | opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.zip opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.gz opie-0a6563fcc2f49857c581d9def24407a3a4ef526c.tar.bz2 |
Clean up of code - fixed memory leaks (most of them) and added new custom config menu
Diffstat (limited to 'noncore/games/sfcave-sdl/fly_game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/fly_game.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/noncore/games/sfcave-sdl/fly_game.cpp b/noncore/games/sfcave-sdl/fly_game.cpp index f5ab401..7605c3f 100644 --- a/noncore/games/sfcave-sdl/fly_game.cpp +++ b/noncore/games/sfcave-sdl/fly_game.cpp | |||
@@ -12,16 +12,17 @@ FlyGame :: FlyGame( SFCave *p, int w, int h, int diff ) | |||
12 | 12 | ||
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 | } | 21 | } |
21 | 22 | ||
22 | void FlyGame :: init() | 23 | void FlyGame :: init() |
23 | { | 24 | { |
24 | Game :: init(); | 25 | Game :: init(); |
25 | 26 | ||
26 | switch( difficulty ) | 27 | switch( difficulty ) |
27 | { | 28 | { |
@@ -29,33 +30,42 @@ void FlyGame :: init() | |||
29 | player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 ); | 30 | player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 ); |
30 | break; | 31 | break; |
31 | case MENU_DIFFICULTY_NORMAL: | 32 | case MENU_DIFFICULTY_NORMAL: |
32 | player->setMovementInfo( 0.35, 0.4, 2.5, 3 ); | 33 | player->setMovementInfo( 0.35, 0.4, 2.5, 3 ); |
33 | break; | 34 | break; |
34 | case MENU_DIFFICULTY_HARD: | 35 | case MENU_DIFFICULTY_HARD: |
35 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); | 36 | player->setMovementInfo( 0.4, 0.6, 4, 5 ); |
36 | break; | 37 | break; |
38 | case MENU_DIFFICULTY_CUSTOM: | ||
39 | { | ||
40 | double thrust = parent->loadDoubleSetting( "Fly_custom_player_thrust", 0.3 ); | ||
41 | double gravity = parent->loadDoubleSetting( "Fly_custom_player_gravity", 0.2 ); | ||
42 | double maxUp = parent->loadDoubleSetting( "Fly_custom_player_maxupspeed", 1.5 ); | ||
43 | double maxDown = parent->loadDoubleSetting( "Fly_custom_player_maxdownspeed", 1.5 ); | ||
44 | player->setMovementInfo( thrust, gravity, maxUp, maxDown ); | ||
45 | break; | ||
46 | } | ||
37 | } | 47 | } |
38 | 48 | ||
39 | startScoring = false; | 49 | startScoring = false; |
40 | } | 50 | } |
41 | 51 | ||
42 | void FlyGame :: update( int state ) | 52 | void FlyGame :: update( int state ) |
43 | { | 53 | { |
44 | Game::update( state ); | 54 | Game::update( state ); |
45 | 55 | ||
46 | if ( state == STATE_PLAYING ) | 56 | if ( state == STATE_PLAYING ) |
47 | { | 57 | { |
48 | 58 | ||
49 | if ( nrFrames % 3 == 0 ) | 59 | if ( nrFrames % 3 == 0 ) |
50 | { | 60 | { |
51 | int diff = terrain->getMapBottom( 10 ) - player->getY(); | 61 | int diff = terrain->getMapBottom( 10 ) - player->getY(); |
52 | int tmpScore = ((FlyTerrain *)terrain)->getScore( 1, diff ); | 62 | int tmpScore = ((FlyTerrain *)terrain)->getScore( 1, diff ); |
53 | // printf( "diff - %d score - %d\n", diff, tmpScore ); | 63 | |
54 | if ( !startScoring ) | 64 | if ( !startScoring ) |
55 | { | 65 | { |
56 | if ( tmpScore > 0 ) | 66 | if ( tmpScore > 0 ) |
57 | startScoring = true; | 67 | startScoring = true; |
58 | } | 68 | } |
59 | 69 | ||
60 | if ( startScoring ) | 70 | if ( startScoring ) |
61 | { | 71 | { |
@@ -64,17 +74,16 @@ void FlyGame :: update( int state ) | |||
64 | 74 | ||
65 | // the closer the difference is to 0 means more points | 75 | // the closer the difference is to 0 means more points |
66 | score += tmpScore; | 76 | score += tmpScore; |
67 | } | 77 | } |
68 | } | 78 | } |
69 | 79 | ||
70 | if ( checkCollisions() ) | 80 | if ( checkCollisions() ) |
71 | { | 81 | { |
72 | // printf( "Crashed!\n" ); | ||
73 | parent->changeState( STATE_CRASHING ); | 82 | parent->changeState( STATE_CRASHING ); |
74 | return; | 83 | return; |
75 | } | 84 | } |
76 | 85 | ||
77 | // Game logic goes here | 86 | // Game logic goes here |
78 | terrain->moveTerrain( 5 ); | 87 | terrain->moveTerrain( 5 ); |
79 | player->move( press ); | 88 | player->move( press ); |
80 | } | 89 | } |