summaryrefslogtreecommitdiff
path: root/noncore/games/sfcave-sdl
Side-by-side diff
Diffstat (limited to 'noncore/games/sfcave-sdl') (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,73 +1,72 @@
#include "SDL_gfxPrimitives.h"
#include "constants.h"
#include "fly_game.h"
#include "random.h"
FlyGame :: FlyGame( SFCave *p, int w, int h, int diff )
: Game( p, w, h, diff )
{
gameName = "Fly";
difficulty = MENU_DIFFICULTY_EASY;
terrain = new FlyTerrain( w, h );
player = new Player( w, h );
highScore = 0;
}
FlyGame :: ~FlyGame()
{
// terrain and player get deleted by parent class
}
void FlyGame :: init()
{
- Game :: init();
-
switch( difficulty )
{
case MENU_DIFFICULTY_EASY:
player->setMovementInfo( 0.3, 0.2, 1.5, 1.5 );
break;
case MENU_DIFFICULTY_NORMAL:
player->setMovementInfo( 0.35, 0.4, 2.5, 3 );
break;
case MENU_DIFFICULTY_HARD:
player->setMovementInfo( 0.4, 0.6, 4, 5 );
break;
case MENU_DIFFICULTY_CUSTOM:
{
double thrust = parent->loadDoubleSetting( "Fly_custom_player_thrust", 0.3 );
double gravity = parent->loadDoubleSetting( "Fly_custom_player_gravity", 0.2 );
double maxUp = parent->loadDoubleSetting( "Fly_custom_player_maxupspeed", 1.5 );
double maxDown = parent->loadDoubleSetting( "Fly_custom_player_maxdownspeed", 1.5 );
player->setMovementInfo( thrust, gravity, maxUp, maxDown );
break;
}
}
startScoring = false;
+ Game :: init();
}
void FlyGame :: update( int state )
{
Game::update( state );
if ( state == STATE_PLAYING )
{
if ( nrFrames % 3 == 0 )
{
int diff = terrain->getMapBottom( 10 ) - player->getY();
int tmpScore = ((FlyTerrain *)terrain)->getScore( 1, diff );
if ( !startScoring )
{
if ( tmpScore > 0 )
startScoring = true;
}
if ( startScoring )
{
// Update score
// get distance between landscape and ship
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
@@ -2,89 +2,89 @@
#include "constants.h"
#include "gates_game.h"
#include "random.h"
GatesGame :: GatesGame( SFCave *p, int w, int h, int diff )
: Game( p, w, h, diff )
{
gameName = "Gates";
difficulty = MENU_DIFFICULTY_EASY;
blockUpdateRate = 200;
terrain = new Terrain( w, h );
player = new Player( w, h );
highScore = 0;
}
GatesGame :: ~GatesGame()
{
// terrain and player get deleted by parent class
}
void GatesGame :: init()
{
- Game :: init();
-
blockHeight = 80;
blockWidth = 20;
lastGateBottomY = 0;
gateDistance = 75;
nextGate = nextInt( 50 ) + gateDistance;
gapHeight = 75;
switch( difficulty )
{
case MENU_DIFFICULTY_EASY:
gapHeight = 75;
player->setMovementInfo( 0.4, 0.6, 4, 5 );
break;
case MENU_DIFFICULTY_NORMAL:
gapHeight = 50;
player->setMovementInfo( 0.4, 0.6, 4, 5 );
break;
case MENU_DIFFICULTY_HARD:
gapHeight = 25;
player->setMovementInfo( 0.6, 0.8, 6, 7 );
break;
case MENU_DIFFICULTY_CUSTOM:
{
// Read custom difficulty settings for this game
gapHeight = parent->loadIntSetting( "Gates_custom_gapHeight", 75 );
double thrust = parent->loadDoubleSetting( "Gates_custom_player_thrust", 0.4 );
double gravity = parent->loadDoubleSetting( "Gates_custom_player_gravity", 0.6 );
double maxUp = parent->loadDoubleSetting( "Gates_custom_player_maxupspeed", 4.0 );
double maxDown = parent->loadDoubleSetting( "Gates_custom_player_maxdownspeed", 5.0 );
player->setMovementInfo( thrust, gravity, maxUp, maxDown );
break;
}
}
for ( int i = 0 ; i < BLOCKSIZE ; ++i )
blocks[i].y( -1 );
+
+ Game :: init();
}
void GatesGame :: update( int state )
{
Game::update( state );
// Game logic goes here
if ( state == STATE_PLAYING )
{
if ( nrFrames % 3 == 0 )
score ++;
if ( nrFrames % 500 == 0 )
{
if ( gapHeight > 75 )
gapHeight -= 5;
}
// Slightly random gap distance
if ( nrFrames >= nextGate )
{
nextGate = nrFrames + nextInt( 50 ) + gateDistance;
addGate();
}
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
@@ -12,49 +12,49 @@ Player :: Player( int w, int h )
sHeight = h;
thrust = 0.4;
gravity = 0.6;
maxUpSpeed = 4.0;
maxDownSpeed = 5.0;
explosion = new AnimatedImage( IMAGES_PATH "explosion.bmp", 15 );
init();
}
Player :: ~Player()
{
if ( explosion )
delete explosion;
}
void Player :: init()
{
// Set player position
pos.x( 50 );
pos.y( sWidth/2 );
pos.h( 2 );
pos.w( 4 );
- thrust = 0;
+ currentThrust = 0;
crashing = false;
crashLineLength = 0;
crashed = false;
explosion->reset();
allFaded = false;
expNextFrame = false;
// Reset Trail
for ( int i = 0 ; i < TRAILSIZE ; ++i )
{
trail[i].x( -1 );
trail[i].y( 0 );
trail[i].w( 2 );
trail[i].h( 2 );
}
}
void Player :: draw( SDL_Surface *screen )
{
if ( !crashing )
{
// Draw Player
// ellipseRGBA( screen, pos.x(), pos.y(), pos.x()+ pos.width(), pos.y()+pos.height(), 0, 255, 255, 255 );
filledEllipseRGBA( screen, pos.x() + pos.w(), pos.y(), pos.w(), pos.h(), 0, 255, 255, 255 );
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 @@
#include "SDL_gfxPrimitives.h"
#include "constants.h"
#include "sfcave_game.h"
#include "random.h"
SFCaveGame :: SFCaveGame( SFCave *p, int w, int h, int diff )
: Game( p, w, h, diff )
{
gameName = "SFCave";
difficulty = MENU_DIFFICULTY_EASY;
blockUpdateRate = 200;
terrain = new Terrain( w, h );
player = new Player( w, h );
highScore = 0;
}
SFCaveGame :: ~SFCaveGame()
{
}
void SFCaveGame :: init()
{
- Game :: init();
-
blockDistance = 50;
blockHeight = 80;
blockWidth = 20;
switch( difficulty )
{
case MENU_DIFFICULTY_EASY:
blockDistance = 50;
break;
case MENU_DIFFICULTY_NORMAL:
blockDistance = 40;
break;
case MENU_DIFFICULTY_HARD:
blockDistance = 30;
break;
case MENU_DIFFICULTY_CUSTOM:
{
// Read custom difficulty settings for this game
blockDistance = parent->loadIntSetting( "SFCave_custom_blockdistance", 50 );
double thrust = parent->loadDoubleSetting( "SFCave_custom_player_thrust", 0.4 );
double gravity = parent->loadDoubleSetting( "SFCave_custom_player_gravity", 0.6 );
double maxUp = parent->loadDoubleSetting( "SFCave_custom_player_maxupspeed", 4.0 );
double maxDown = parent->loadDoubleSetting( "SFCave_custom_player_maxdownspeed", 5.0 );
player->setMovementInfo( thrust, gravity, maxUp, maxDown );
break;
}
}
for ( int i = 0 ; i < BLOCKSIZE ; ++i )
blocks[i].y( -1 );
+
+ Game :: init();
}
void SFCaveGame :: update( int state )
{
Game::update( state );
if ( state == STATE_PLAYING )
{
if ( nrFrames % 3 == 0 )
score ++;
if ( nrFrames % 200 == 0 )
{
if ( terrain->getMaxHeight() < sHeight - 100 )
{
terrain->increaseMaxHeight( 10 );
// Reduce block height
if ( terrain->getMaxHeight() > sHeight - 150 )
blockHeight -= 5;
}
}
if ( checkCollisions() )