From 055f7a0c767a202e6b2711c57f7a792a69c129f1 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 20 May 2002 16:45:17 +0000 Subject: [PATCH] - b0rk --- cscape.c | 56 ++++++++++++++++++++++++++++---------------------------- sdl.c | 3 ++- sdl.h | 2 ++ 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/cscape.c b/cscape.c index 6edb43d..9dabbc2 100644 --- a/cscape.c +++ b/cscape.c @@ -9,7 +9,7 @@ #define MEERESSPIEGEL 48 #define BLICKWEITE 55 -#define FLUGHOEHE 30 +#define FLUGHOEHE 100 #define MAPSIZE 256 int sintab[360]; @@ -37,7 +37,7 @@ void fly(SDL_Surface *screen) { int iy, ix, iy1, iyp, ixp; int x, y, z, s, i, j; int map_color; - int rng[320]; + int rng[WIDTH]; if(SDL_MUSTLOCK(screen)) if(SDL_LockSurface(screen) < 0) { @@ -47,62 +47,62 @@ void fly(SDL_Surface *screen) { } /* Richtung wechseln? */ - /* if (java.lang.Math.random()<0.5) - if (java.lang.Math.random()<1.0) - if (richtung <= 0) richtung = 357; - else richtung -= 3; - else - if (richtung >= 357) richtung = 0; - else richtung += 3; - */ + if (rand()= 357) { richtung = 0; } + else { richtung += 3; } + } + } /* Bewegen ... */ posy = posy + costab[richtung] / 32; posx = posx + sintab[richtung] / 32; - posy %= MAPSIZE; - posx %= MAPSIZE; + posy %= MAPSIZE; if(posy<0) posy+=MAPSIZE; + posx %= MAPSIZE; if(posx<0) posx+=MAPSIZE; /* Absolute Höhe berechnen */ - flughoehe = 100; - /* flughoehe = FLUGHOEHE + ... */ + flughoehe = FLUGHOEHE + map[posy*MAPSIZE+posx]/2; /* FIXME */ - for (i=0;i<320;i++) rng[i] = 200; + for (i=0;i=0) && (x+s<=318) - && ((256*iyp+ixp) > 0) - && ((256*iyp+ixp) < 256*256) + (x>=0) && (x+s<=WIDTH-2) + && ((MAPSIZE*iyp+ixp) > 0) + && ((MAPSIZE*iyp+ixp) < MAPSIZE*MAPSIZE) ) { - map_color = map[256*iyp+ixp]; - z = map[256*iyp+ixp]; + map_color = map[MAPSIZE*iyp+ixp]; + z = map[MAPSIZE*iyp+ixp]; if(z=0) && (y<=199)) { + if ((y>=0) && (y<=HEIGHT-1)) { for (j=x;j<=x+s;j++) for (i=rng[j];i>=y;i--) { - if ((320*i+j>=0) && (320*i+j<320*200)) + if ((WIDTH*i+j>=0) && (WIDTH*i+j #include +#include "sdl.h" SDL_Surface* sdl_init() { SDL_Surface* screen; - screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE); + screen = SDL_SetVideoMode(WIDTH, HEIGHT, 8, SDL_SWSURFACE); if(screen == NULL) { fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError()); diff --git a/sdl.h b/sdl.h index ed3e06f..d4c05ab 100644 --- a/sdl.h +++ b/sdl.h @@ -1,4 +1,6 @@ /* $Revision$ */ +#define WIDTH 640 +#define HEIGHT 480 SDL_Surface* sdl_init(); void sdl_putpixel(SDL_Surface *surface, int x, int y, Uint32 pixel);