author | andyq <andyq> | 2003-01-20 23:11:56 (UTC) |
---|---|---|
committer | andyq <andyq> | 2003-01-20 23:11:56 (UTC) |
commit | 92419b025aa5d82bb7592281af5505ff931c2e58 (patch) (side-by-side diff) | |
tree | 374ee9ca86ef716ce388c8a28e38261f6a04ce7a /noncore/games/sfcave-sdl/flyterrain.cpp | |
parent | 02090d2e63ad8398c0a8a9f1fb895a9c6e42514b (diff) | |
download | opie-92419b025aa5d82bb7592281af5505ff931c2e58.zip opie-92419b025aa5d82bb7592281af5505ff931c2e58.tar.gz opie-92419b025aa5d82bb7592281af5505ff931c2e58.tar.bz2 |
Initial Revision
Diffstat (limited to 'noncore/games/sfcave-sdl/flyterrain.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/flyterrain.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/noncore/games/sfcave-sdl/flyterrain.cpp b/noncore/games/sfcave-sdl/flyterrain.cpp new file mode 100644 index 0000000..b1b8db5 --- a/dev/null +++ b/noncore/games/sfcave-sdl/flyterrain.cpp @@ -0,0 +1,103 @@ + +#include "SDL_gfxPrimitives.h" + +#include "constants.h" +#include "flyterrain.h" +#include "random.h" + + +int FlyTerrain :: flyScoreZones[][3] = { { 0, 20, 5 }, + { 20, 30, 2 }, + { 30, 40, 0 }, + { 40, 100, -1 }, + { 100, 300, -2 }, + { -1, -1, -1 } }; + +FlyTerrain :: FlyTerrain( int w, int h ) + : Terrain( w, h, false, true ) +{ + showScoreZones = true; +} + +FlyTerrain :: ~FlyTerrain() +{ +} + +void FlyTerrain :: setPoint( int point ) +{ + static int fly_difficulty_levels[] = { 5, 10, 15 }; + if ( nextInt(100) >= 75 ) + dir *= -1; + + int prevPoint = mapBottom[point-1]; + + int nextPoint = prevPoint + (dir * nextInt( fly_difficulty_levels[0] ) ); + + if ( nextPoint > sHeight ) + { + nextPoint = sHeight; + dir *= -1; + } + else if ( nextPoint < maxHeight ) + { + nextPoint = maxHeight; + dir *= 1; + } + + mapBottom[point] = nextPoint; +} + +void FlyTerrain :: drawTerrain( SDL_Surface *screen ) +{ + Terrain::drawTerrain( screen ); + int tmpOffset = offset + speed*segSize; + + for ( int i = 0 ; i < MAPSIZE -1; ++i ) + { + + if ( showScoreZones ) + { + int r = 0; + int g = 0; + int b = 0; + for ( int j = 1 ; flyScoreZones[j][0] != -1 ; ++j ) + { + if ( flyScoreZones[j][2] == 0 ) + { + g = 255; + b = r = 0; + } + else if ( flyScoreZones[j][2] < 0 ) + { + r = 255; + b = g = 0; + } + else + { + b = 255; + r = g = 0; + } + + lineRGBA( screen, (i*segSize) - tmpOffset, mapBottom[i]-flyScoreZones[j][0], ((i+1)*segSize)-tmpOffset, mapBottom[i+1]-flyScoreZones[j][0], r, g, b, 255 ); + + } + + } + } +} + +int FlyTerrain :: getScore( int difficulty, int dist ) +{ + int score = 0; + for ( int i = 0 ; flyScoreZones[i][0] != -1 ; ++i ) + { + if ( flyScoreZones[i][0] <= dist && flyScoreZones[i][1] > dist ) + { + score = flyScoreZones[i][2]; + break; + } + } + + return score; +} + |