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/terrain.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/terrain.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/sfcave-sdl/terrain.cpp | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/noncore/games/sfcave-sdl/terrain.cpp b/noncore/games/sfcave-sdl/terrain.cpp index c001a56..b243f45 100644 --- a/noncore/games/sfcave-sdl/terrain.cpp +++ b/noncore/games/sfcave-sdl/terrain.cpp | |||
@@ -47,6 +47,7 @@ void Terrain :: initTerrain() | |||
47 | setPoint( i ); | 47 | setPoint( i ); |
48 | 48 | ||
49 | SDL_FillRect( terrainSurface, 0, 0 ); | 49 | SDL_FillRect( terrainSurface, 0, 0 ); |
50 | |||
50 | // Draw Terrain into surface | 51 | // Draw Terrain into surface |
51 | Sint16 px[5]; | 52 | Sint16 px[5]; |
52 | Sint16 py[5]; | 53 | Sint16 py[5]; |
@@ -91,7 +92,6 @@ void Terrain :: moveTerrain( int amountToMove ) | |||
91 | offset += amountToMove; | 92 | offset += amountToMove; |
92 | speed = offset/segSize; | 93 | speed = offset/segSize; |
93 | 94 | ||
94 | //printf( "offset - %d, speed - %d\n", offset, speed ); | ||
95 | if ( offset >= segSize ) | 95 | if ( offset >= segSize ) |
96 | { | 96 | { |
97 | for ( int i = 0 ; i < (MAPSIZE)-speed ; ++i ) | 97 | for ( int i = 0 ; i < (MAPSIZE)-speed ; ++i ) |
@@ -195,7 +195,6 @@ void Terrain :: drawTerrain( SDL_Surface *screen ) | |||
195 | dst.y = 0; | 195 | dst.y = 0; |
196 | dst.w = sWidth; | 196 | dst.w = sWidth; |
197 | dst.h = sHeight; | 197 | dst.h = sHeight; |
198 | //dst.h = maxHeight; | ||
199 | 198 | ||
200 | SDL_Rect dst2; | 199 | SDL_Rect dst2; |
201 | dst2.x = 0; | 200 | dst2.x = 0; |
@@ -204,28 +203,13 @@ void Terrain :: drawTerrain( SDL_Surface *screen ) | |||
204 | SDL_BlitSurface(terrainSurface, &dst, screen, &dst2 ); | 203 | SDL_BlitSurface(terrainSurface, &dst, screen, &dst2 ); |
205 | 204 | ||
206 | stars->draw( screen ); | 205 | stars->draw( screen ); |
207 | |||
208 | //dst.y = sHeight - maxHeight; | ||
209 | //dst2.y = sHeight - maxHeight; | ||
210 | //SDL_BlitSurface(terrainSurface, &dst, screen, &dst2 ); | ||
211 | |||
212 | /* | ||
213 | for ( int i = 0 ; i < MAPSIZE ; ++i ) | ||
214 | { | ||
215 | int x1 = (i*segSize) - (offset*speed); | ||
216 | int x2 = ((i+1)*segSize)-(offset*speed); | ||
217 | if ( x2 >= sWidth ) | ||
218 | x2 = sWidth-1; | ||
219 | aalineRGBA( screen, x1, mapTop[i], x2, mapTop[i+1], 0, 220, 0, 255 ); | ||
220 | aalineRGBA( screen, x1, mapBottom[i], x2, mapBottom[i+1], 0, 220, 0, 255 ); | ||
221 | } | ||
222 | */ | ||
223 | } | 206 | } |
224 | 207 | ||
225 | bool Terrain :: checkCollision( int x, int y, int h ) | 208 | bool Terrain :: checkCollision( int x, int y, int h ) |
226 | { | 209 | { |
227 | if ( y < 0 || y > sHeight ) | 210 | if ( y < 0 || y > sHeight ) |
228 | return true; | 211 | return true; |
212 | |||
229 | // First get segment that matches x | 213 | // First get segment that matches x |
230 | SDL_LockSurface( terrainSurface ); | 214 | SDL_LockSurface( terrainSurface ); |
231 | 215 | ||
@@ -247,7 +231,7 @@ Terrain *terrain; | |||
247 | 231 | ||
248 | void go() | 232 | void go() |
249 | { | 233 | { |
250 | /* Initialize SDL */ | 234 | // Initialize SDL |
251 | if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) | 235 | if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) |
252 | { | 236 | { |
253 | fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); | 237 | fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); |