summaryrefslogtreecommitdiff
authorandyq <andyq>2003-01-21 21:09:36 (UTC)
committer andyq <andyq>2003-01-21 21:09:36 (UTC)
commit6b3b53262213e4e4f73ffab2266ea3b4a7813fe4 (patch) (unidiff)
tree896759614d5601570f259525c000a8be4db4d68d
parent0a6563fcc2f49857c581d9def24407a3a4ef526c (diff)
downloadopie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.zip
opie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.tar.gz
opie-6b3b53262213e4e4f73ffab2266ea3b4a7813fe4.tar.bz2
Small bug fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/sfcave-sdl/fly_game.cpp3
-rw-r--r--noncore/games/sfcave-sdl/gates_game.cpp4
-rw-r--r--noncore/games/sfcave-sdl/player.cpp2
-rw-r--r--noncore/games/sfcave-sdl/sfcave_game.cpp4
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
@@ -1,81 +1,80 @@
1#include "SDL_gfxPrimitives.h" 1#include "SDL_gfxPrimitives.h"
2 2
3#include "constants.h" 3#include "constants.h"
4#include "fly_game.h" 4#include "fly_game.h"
5#include "random.h" 5#include "random.h"
6 6
7FlyGame :: FlyGame( SFCave *p, int w, int h, int diff ) 7FlyGame :: FlyGame( SFCave *p, int w, int h, int diff )
8 : Game( p, w, h, diff ) 8 : Game( p, w, h, diff )
9{ 9{
10 gameName = "Fly"; 10 gameName = "Fly";
11 difficulty = MENU_DIFFICULTY_EASY; 11 difficulty = MENU_DIFFICULTY_EASY;
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
18FlyGame :: ~FlyGame() 18FlyGame :: ~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
23void FlyGame :: init() 23void 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
52void FlyGame :: update( int state ) 51void 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();
62 int tmpScore = ((FlyTerrain *)terrain)->getScore( 1, diff ); 61 int tmpScore = ((FlyTerrain *)terrain)->getScore( 1, diff );
63 62
64 if ( !startScoring ) 63 if ( !startScoring )
65 { 64 {
66 if ( tmpScore > 0 ) 65 if ( tmpScore > 0 )
67 startScoring = true; 66 startScoring = true;
68 } 67 }
69 68
70 if ( startScoring ) 69 if ( startScoring )
71 { 70 {
72 // Update score 71 // Update score
73 // get distance between landscape and ship 72 // get distance between landscape and ship
74 73
75 // the closer the difference is to 0 means more points 74 // the closer the difference is to 0 means more points
76 score += tmpScore; 75 score += tmpScore;
77 } 76 }
78 } 77 }
79 78
80 if ( checkCollisions() ) 79 if ( checkCollisions() )
81 { 80 {
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
@@ -1,98 +1,98 @@
1#include "SDL_gfxPrimitives.h" 1#include "SDL_gfxPrimitives.h"
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
7GatesGame :: GatesGame( SFCave *p, int w, int h, int diff ) 7GatesGame :: 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
19GatesGame :: ~GatesGame() 19GatesGame :: ~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
24void GatesGame :: init() 24void 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
69void GatesGame :: update( int state ) 69void 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 }
91 91
92 if ( checkCollisions() ) 92 if ( checkCollisions() )
93 { 93 {
94 parent->changeState( STATE_CRASHING ); 94 parent->changeState( STATE_CRASHING );
95 return; 95 return;
96 } 96 }
97 97
98 terrain->moveTerrain( 5 ); 98 terrain->moveTerrain( 5 );
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
@@ -4,65 +4,65 @@
4#include "constants.h" 4#include "constants.h"
5#include "player.h" 5#include "player.h"
6#include "random.h" 6#include "random.h"
7#include "animatedimage.h" 7#include "animatedimage.h"
8 8
9Player :: Player( int w, int h ) 9Player :: Player( int w, int h )
10{ 10{
11 sWidth = w; 11 sWidth = w;
12 sHeight = h; 12 sHeight = h;
13 13
14 thrust = 0.4; 14 thrust = 0.4;
15 gravity = 0.6; 15 gravity = 0.6;
16 maxUpSpeed = 4.0; 16 maxUpSpeed = 4.0;
17 maxDownSpeed = 5.0; 17 maxDownSpeed = 5.0;
18 18
19 explosion = new AnimatedImage( IMAGES_PATH "explosion.bmp", 15 ); 19 explosion = new AnimatedImage( IMAGES_PATH "explosion.bmp", 15 );
20 init(); 20 init();
21} 21}
22 22
23Player :: ~Player() 23Player :: ~Player()
24{ 24{
25 if ( explosion ) 25 if ( explosion )
26 delete explosion; 26 delete explosion;
27} 27}
28 28
29void Player :: init() 29void 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 );
49 trail[i].w( 2 ); 49 trail[i].w( 2 );
50 trail[i].h( 2 ); 50 trail[i].h( 2 );
51 } 51 }
52} 52}
53 53
54void Player :: draw( SDL_Surface *screen ) 54void Player :: draw( SDL_Surface *screen )
55{ 55{
56 if ( !crashing ) 56 if ( !crashing )
57 { 57 {
58 // Draw Player 58 // Draw Player
59 // ellipseRGBA( screen, pos.x(), pos.y(), pos.x()+ pos.width(), pos.y()+pos.height(), 0, 255, 255, 255 ); 59 // ellipseRGBA( screen, pos.x(), pos.y(), pos.x()+ pos.width(), pos.y()+pos.height(), 0, 255, 255, 255 );
60 filledEllipseRGBA( screen, pos.x() + pos.w(), pos.y(), pos.w(), pos.h(), 0, 255, 255, 255 ); 60 filledEllipseRGBA( screen, pos.x() + pos.w(), pos.y(), pos.w(), pos.h(), 0, 255, 255, 255 );
61 61
62 // Draw Trail 62 // Draw Trail
63 drawTrails( screen ); 63 drawTrails( screen );
64 } 64 }
65 else 65 else
66 { 66 {
67 drawTrails( screen ); 67 drawTrails( screen );
68 68
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,90 +1,90 @@
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
7SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff ) 7SFCaveGame :: 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
19SFCaveGame :: ~SFCaveGame() 19SFCaveGame :: ~SFCaveGame()
20{ 20{
21} 21}
22 22
23void SFCaveGame :: init() 23void 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
61void SFCaveGame :: update( int state ) 61void 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() )
83 { 83 {
84 parent->changeState( STATE_CRASHING ); 84 parent->changeState( STATE_CRASHING );
85 return; 85 return;
86 } 86 }
87 87
88 if ( nrFrames % blockDistance == 0 ) 88 if ( nrFrames % blockDistance == 0 )
89 addBlock(); 89 addBlock();
90 90