|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
|
|
|
|
|
#define MEERESSPIEGEL 48
|
|
|
|
|
#define BLICKWEITE 55
|
|
|
|
|
#define FLUGHOEHE 30
|
|
|
|
|
#define MAPSIZE 256
|
|
|
|
|
|
|
|
|
|
int sintab[360];
|
|
|
|
@ -27,91 +28,107 @@ void init_tabs() {
|
|
|
|
|
costab[x] = -sintab[x-90];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
|
init_tabs();
|
|
|
|
|
map_init(map,MAPSIZE,MAPSIZE);
|
|
|
|
|
map_generate(map,0,0,MAPSIZE-1,MAPSIZE-1);
|
|
|
|
|
|
|
|
|
|
screen = sdl_init();
|
|
|
|
|
map_setpalette(screen);
|
|
|
|
|
|
|
|
|
|
sleep(30); SDL_Quit(); exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
int posx = 0;
|
|
|
|
|
int posy = 0;
|
|
|
|
|
int richtung = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int flughoehe;
|
|
|
|
|
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[] = new int[320];
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
|
|
|
|
// Schnarch...
|
|
|
|
|
try {Thread.sleep(100);} catch (InterruptedException e) {}
|
|
|
|
|
int rng[320];
|
|
|
|
|
|
|
|
|
|
if(SDL_MUSTLOCK(screen))
|
|
|
|
|
if(SDL_LockSurface(screen) < 0) {
|
|
|
|
|
fprintf(stderr, "Can't lock screen: %s\n",
|
|
|
|
|
SDL_GetError());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Richtung wechseln?
|
|
|
|
|
if (java.lang.Math.random()<0.5)
|
|
|
|
|
/* 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;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vorwärts?
|
|
|
|
|
/* Bewegen ... */
|
|
|
|
|
posy = posy + costab[richtung] / 32;
|
|
|
|
|
posx = posx + sintab[richtung] / 32;
|
|
|
|
|
|
|
|
|
|
if (posy<=0) posy += 256;
|
|
|
|
|
if (posx<=0) posx += 256;
|
|
|
|
|
posy %= MAPSIZE;
|
|
|
|
|
posx %= MAPSIZE;
|
|
|
|
|
|
|
|
|
|
Absolute Höhe berechnen
|
|
|
|
|
/* Absolute Höhe berechnen */
|
|
|
|
|
flughoehe = 100;
|
|
|
|
|
/* flughoehe = FLUGHOEHE + ... */
|
|
|
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
|
for (i=0;i<320;i++) rng[i] = 200;
|
|
|
|
|
System.arraycopy(emptyscreen,0,screen,0,320*200);
|
|
|
|
|
|
|
|
|
|
for (iy=posy; iy<=posy+blickweite; iy++) {
|
|
|
|
|
|
|
|
|
|
SDL_FillRect(screen, NULL, 0);
|
|
|
|
|
|
|
|
|
|
for (iy=posy; iy<=posy+BLICKWEITE; iy++) {
|
|
|
|
|
iy1 = 2 * (iy-posy) + 1;
|
|
|
|
|
s = 4 + 300 / iy1;
|
|
|
|
|
|
|
|
|
|
for (ix=posx-(iy-posy); ix<=posx+(iy-posy); ix++) {
|
|
|
|
|
|
|
|
|
|
ixp = posx + ((ix-posx) * costab[richtung] + (iy-posy) * sintab[richtung])
|
|
|
|
|
/ 128;
|
|
|
|
|
iyp = posy + ((iy-posy) * costab[richtung] - (ix-posx) * sintab[ri
|
|
|
|
|
chtung]) / 128;
|
|
|
|
|
ixp = posx
|
|
|
|
|
+ ((ix-posx) * costab[richtung]
|
|
|
|
|
+ (iy-posy) * sintab[richtung]) / 128;
|
|
|
|
|
iyp = posy
|
|
|
|
|
+ ((iy-posy) * costab[richtung]
|
|
|
|
|
- (ix-posx) * sintab[richtung]) / 128;
|
|
|
|
|
|
|
|
|
|
x = 160 + 360*(ix-posx) / iy1;
|
|
|
|
|
|
|
|
|
|
if ((x>=0) && (x+s<=318) && ((256*iyp+ixp) > 0) && ((256*iyp+ixp)
|
|
|
|
|
< 256*256) ) {
|
|
|
|
|
if(
|
|
|
|
|
(x>=0) && (x+s<=318)
|
|
|
|
|
&& ((256*iyp+ixp) > 0)
|
|
|
|
|
&& ((256*iyp+ixp) < 256*256)
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
map_color = map[256*iyp+ixp];
|
|
|
|
|
z = map[256*iyp+ixp];
|
|
|
|
|
|
|
|
|
|
if (z < meeresspiegel) z = meeresspiegel;
|
|
|
|
|
|
|
|
|
|
if(z<MEERESSPIEGEL) z = MEERESSPIEGEL;
|
|
|
|
|
y = 100 + 30 * (flughoehe-z) / iy1;
|
|
|
|
|
|
|
|
|
|
if ((y>=0) && (y<=199)) {
|
|
|
|
|
|
|
|
|
|
for (j=x;j<=x+s;j++)
|
|
|
|
|
|
|
|
|
|
for (i=rng[j];i>=y;i--) {
|
|
|
|
|
|
|
|
|
|
if ((320*i+j>=0) && (320*i+j<320*200))
|
|
|
|
|
screen[320*i+j] = (byte)map_color;
|
|
|
|
|
sdl_putpixel(screen, j, i, map_color);
|
|
|
|
|
if (y<rng[j]) rng[j] = y;
|
|
|
|
|
}}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
|
|
|
|
|
SDL_UpdateRect(screen, 0, 0, 320, 200);
|
|
|
|
|
|
|
|
|
|
usleep(1000/25);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int main(void) {
|
|
|
|
|
init_tabs();
|
|
|
|
|
map_init(map,MAPSIZE,MAPSIZE);
|
|
|
|
|
map_generate(map,0,0,MAPSIZE-1,MAPSIZE-1);
|
|
|
|
|
|
|
|
|
|
screen = sdl_init();
|
|
|
|
|
map_setpalette(screen);
|
|
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
|
fly(screen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sleep(30); SDL_Quit(); exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|