/* $Revision$ */ #include #include #include #include "SDL.h" #include "sdl.h" #include "map.h" #define MEERESSPIEGEL 48 #define BLICKWEITE 55 #define FLUGHOEHE 100 #define MAPSIZE 256 int sintab[360]; int costab[360]; char map[MAPSIZE*MAPSIZE]; SDL_Surface *screen; void init_tabs() { int x; for (x=0;x<360; x++) sintab[x] = (int) (127.0 * sin(x*M_PI/180)); for (x=0; x < 90; x++) costab[x] = sintab[x+90]; for (x=90; x < 360; x++) costab[x] = -sintab[x-90]; } void fly(SDL_Surface *screen) { static int posx = 0, posy = 0, richtung = 0, flughoehe = 0; int iy, ix, iy1, iyp, ixp; int x, y, z, s, i, j; int map_color; int rng[WIDTH]; if(SDL_MUSTLOCK(screen)) if(SDL_LockSurface(screen) < 0) { fprintf(stderr, "Can't lock screen: %s\n", SDL_GetError()); return; } /* Richtung wechseln? */ if (rand()= 357) { richtung = 0; } else { richtung += 3; } } } /* Bewegen ... */ posy = posy + costab[richtung] / 32; posx = posx + sintab[richtung] / 32; posy %= MAPSIZE; if(posy<0) posy+=MAPSIZE; posx %= MAPSIZE; if(posx<0) posx+=MAPSIZE; /* Absolute Höhe berechnen */ flughoehe = FLUGHOEHE + map[posy*MAPSIZE+posx]/2; /* FIXME */ for (i=0;i=0) && (x+s<=WIDTH-2) && ((MAPSIZE*iyp+ixp) > 0) && ((MAPSIZE*iyp+ixp) < MAPSIZE*MAPSIZE) ) { map_color = map[MAPSIZE*iyp+ixp]; z = map[MAPSIZE*iyp+ixp]; if(z=0) && (y<=HEIGHT-1)) { for (j=x;j<=x+s;j++) for (i=rng[j];i>=y;i--) { if ((WIDTH*i+j>=0) && (WIDTH*i+j