From aff55f66291a12945a77dce3db2dc52994565db0 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Tue, 22 Aug 2017 16:32:21 -0400 Subject: [PATCH] tfv: more tweaks to the flying code --- gr-sim/tfv_flying.c | 83 +++++++++++++++++++++++++++++++++++-------- gr-sim/tfv_sprites.c | 74 +++++++++++++++++++++++++++++--------- gr-sim/tfv_sprites.h | 10 +++++- tfv/sprites.png | Bin 1186 -> 1355 bytes 4 files changed, 135 insertions(+), 32 deletions(-) diff --git a/gr-sim/tfv_flying.c b/gr-sim/tfv_flying.c index 8e8ff8d5..fe1fe835 100644 --- a/gr-sim/tfv_flying.c +++ b/gr-sim/tfv_flying.c @@ -39,9 +39,9 @@ static unsigned char flying_map[32][32]= { {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, - {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, - {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, - {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, + {2,2,2,2, 2,9,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, + {2,2,2,2, 9,0,9,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, + {2,2,2,2, 2,9,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, {2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,}, @@ -61,15 +61,17 @@ static int tile_w=32,tile_h=32; /* http://www.helixsoft.nl/articles/circle/sincos.htm */ -static double space_z=2.5; // height of the camera above the plane +static double space_z=0.5; // height of the camera above the plane static int horizon=-2; // number of pixels line 0 is below the horizon -static double scale_x=20, scale_y=20; +static double scale_x=20, scale_y=20; // scale of space coordinates to screen coordinates static double bmp_w=40, bmp_h=40; //void mode_7 (BITMAP *bmp, BITMAP *tile, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params) -double BETA=-0.6; +double BETA=-0.5; + +static int over_water; void draw_background_mode7(double angle, double cx, double cy) { @@ -88,6 +90,9 @@ void draw_background_mode7(double angle, double cx, double cy) { // current space position double space_x, space_y; + int map_color; + + over_water=0; clear_top(0); @@ -115,22 +120,39 @@ void draw_background_mode7(double angle, double cx, double cy) { space_x = cx + (distance * cos(angle)) - bmp_w/2 * line_dx; space_y = cy + (distance * sin(angle)) - bmp_w/2 * line_dy; - space_x+=(BETA*space_z*cos(angle)); - space_y+=(BETA*space_z*sin(angle)); + // Move camera back a bit + + double factor; + + factor=space_z*BETA; + +// factor=2.0*BETA; + + space_x+=factor*cos(angle); + space_y+=factor*sin(angle); // go through all points in this screen line for (screen_x = 0; screen_x < bmp_w; screen_x++) { // get a pixel from the tile and put it on the screen - color_equals(flying_map[(int)space_x & mask_x] + map_color=(flying_map[(int)space_x & mask_x] [(int)space_y&mask_y]); + color_equals(map_color); + if (screen_x==20) { + if (map_color==COLOR_DARKBLUE) over_water=1; + else over_water=0; + } + basic_plot(screen_x,screen_y); // advance to the next position in space space_x += line_dx; space_y += line_dy; + + + } } } @@ -145,13 +167,14 @@ int flying(void) { double flyx=0,flyy=0; double our_angle=0.0; double dy,dx,speed=0; + int draw_splash=0; /************************************************/ /* Flying */ /************************************************/ gr(); - xx=17; yy=26; + xx=15; yy=28; color_equals(COLOR_BLACK); @@ -167,6 +190,8 @@ int flying(void) { } while(1) { + if (draw_splash>0) draw_splash--; + ch=grsim_input(); if ((ch=='q') || (ch==27)) break; @@ -195,10 +220,13 @@ int flying(void) { printf("Z=%lf\n",space_z); } if ((ch=='m') || (ch==APPLE_DOWN)) { - if (yy<30) { + if (yy<28) { yy+=2; space_z-=1; } + else { + draw_splash=10; + } printf("Z=%lf\n",space_z); } if ((ch=='j') || (ch==APPLE_LEFT)) { @@ -211,6 +239,7 @@ int flying(void) { our_angle-=(6.28/32.0); if (our_angle<0.0) our_angle+=6.28; } + // printf("Angle %lf\n",our_angle); } if ((ch=='k') || (ch==APPLE_RIGHT)) { @@ -223,14 +252,15 @@ int flying(void) { if (our_angle>6.28) our_angle-=6.28; } - } if (ch=='z') { + if (speed>0.5) speed=0.5; speed+=0.05; } if (ch=='x') { + if (speed<-0.5) speed=-0.5; speed-=0.05; } @@ -251,14 +281,39 @@ int flying(void) { draw_background_mode7(our_angle, flyx, flyy); - grsim_put_sprite(0,ship_shadow,xx,30); - if (turning==0) grsim_put_sprite(0,ship_forward,xx,yy); + printf("%d %d %d\n",over_water,draw_splash,yy); + + if (turning==0) { + if ((speed>0.0) && (over_water)&&(draw_splash)) { + grsim_put_sprite(0,splash_forward, + xx+1,yy+9); + } + grsim_put_sprite(0,shadow_forward,xx+3,31+space_z); + grsim_put_sprite(0,ship_forward,xx,yy); + } if (turning<0) { + + if ((yy>25) && (speed>0.0)) draw_splash=1; + + if (over_water&&draw_splash) { + grsim_put_sprite(0,splash_left, + xx+1,36); + } + grsim_put_sprite(0,shadow_left,xx+3,31+space_z); grsim_put_sprite(0,ship_left,xx,yy); turning++; } if (turning>0) { + + + if ((yy>25) && (speed>0.0)) draw_splash=1; + + if (over_water&&draw_splash) { + grsim_put_sprite(0,splash_right, + xx+1,36); + } + grsim_put_sprite(0,shadow_right,xx+3,31+space_z); grsim_put_sprite(0,ship_right,xx,yy); turning--; } diff --git a/gr-sim/tfv_sprites.c b/gr-sim/tfv_sprites.c index 74ee45bf..9d42f356 100644 --- a/gr-sim/tfv_sprites.c +++ b/gr-sim/tfv_sprites.c @@ -64,34 +64,74 @@ unsigned char test_sprite[]={ 0xff,0x1f,0x4f,0x2f,0xff,0x22,0x20,0x00, 0x5f,0x5f,0x5f,0x5f,0xff,0xf2,0xf2,0xf2, }; + + + #endif -unsigned char ship_shadow[]={ - 0x5,0x3, - 0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0xaa,0x00,0x00, - 0x00,0x00,0xaa,0x00,0x00, + +unsigned char splash_forward[]={ + 0x7,0x2, + 0x00,0xee,0x00,0x00,0x00,0xee,0x00, + 0xee,0x00,0x00,0x00,0x00,0x00,0xee, +}; + +unsigned char splash_right[]={ + 0x7,0x2, + 0x00,0x00,0x00,0x00,0x00,0xee,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0xee, +}; + +unsigned char splash_left[]={ + 0x7,0x2, + 0x00,0xee,0x00,0x00,0x00,0x00,0x00, + 0xee,0x00,0x00,0x00,0x00,0x00,0x00, +}; + +unsigned char shadow_forward[]={ + 0x3,0x2, + 0x00,0xaa,0x00, + 0xa0,0xaa,0xa0, +}; + +unsigned char shadow_right[]={ + 0x3,0x2, + 0xa0,0x00,0xaa, + 0x00,0x0a,0xa0, +}; + +unsigned char shadow_left[]={ + 0x3,0x2, + 0xaa,0x00,0xa0, + 0xa0,0x0a,0x00, }; unsigned char ship_forward[]={ - 0x5,0x3, - 0x00,0x00,0x77,0x00,0x00, - 0x50,0x55,0x77,0x55,0x50, - 0x01,0x00,0x07,0x00,0x01, + 0x9,0x5, + 0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x66,0xff,0x66,0x00,0x00,0x00, + 0x00,0x00,0x70,0x2f,0x12,0x2f,0x70,0x00,0x00, + 0xf0,0xf7,0xf7,0xf2,0xd9,0xf2,0xf7,0xf7,0xf0, + 0x00,0x00,0x00,0x00,0x0d,0x00,0x00,0x00,0x00, }; unsigned char ship_right[]={ - 0x5,0x3, - 0x50,0x00,0x70,0x77,0x00, - 0x01,0x55,0x77,0x55,0x50, - 0x00,0x77,0x07,0x00,0x15, + 0x9,0x5, + 0x00,0x00,0x00,0x00,0x00,0x60,0x60,0xf0,0x00, + 0x00,0xf0,0x70,0x70,0xf6,0xf6,0x6f,0x66,0x00, + 0x00,0x07,0xff,0x2f,0x12,0x27,0xf6,0x00,0x00, + 0x00,0x00,0x00,0xdd,0xd9,0xf2,0x77,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x0f,0xff,0x70,0x00, + }; unsigned char ship_left[]={ - 0x5,0x3, - 0x00,0x77,0x70,0x00,0x50, - 0x50,0x55,0x77,0x55,0x01, - 0x15,0x00,0x07,0x77,0x00, + 0x9,0x5, + 0x00,0xf0,0x60,0x60,0x00,0x00,0x00,0x00,0x00, + 0x00,0x66,0x6f,0xf6,0xf6,0x70,0x70,0xf0,0x00, + 0x00,0x00,0xf6,0x27,0x12,0x2f,0xff,0x07,0x00, + 0x00,0x00,0x77,0xf2,0xd9,0xdd,0x00,0x00,0x00, + 0x00,0x70,0xff,0x0f,0x00,0x00,0x00,0x00,0x00, }; diff --git a/gr-sim/tfv_sprites.h b/gr-sim/tfv_sprites.h index e79a59e6..9f96bddc 100644 --- a/gr-sim/tfv_sprites.h +++ b/gr-sim/tfv_sprites.h @@ -3,9 +3,17 @@ extern unsigned char tfv_walk_right[]; extern unsigned char tfv_stand_left[]; extern unsigned char tfv_walk_left[]; extern unsigned char tfv_led_sword[]; + extern unsigned char ship_forward[]; extern unsigned char ship_right[]; extern unsigned char ship_left[]; +extern unsigned char shadow_forward[]; +extern unsigned char shadow_right[]; +extern unsigned char shadow_left[]; +extern unsigned char splash_forward[]; +extern unsigned char splash_right[]; +extern unsigned char splash_left[]; + extern unsigned char killer_crab[]; extern unsigned char palm_tree[]; extern unsigned char pine_tree[]; @@ -13,4 +21,4 @@ extern unsigned char snowy_tree[]; extern unsigned char cactus[]; extern unsigned char mountain[]; extern unsigned char lightning[]; -extern unsigned char ship_shadow[]; + diff --git a/tfv/sprites.png b/tfv/sprites.png index 73c12951699d71ef2b10ff06c9be947d9475ac72..9a06693e43b852ee3dd2922a9f075a6ae9acab6a 100644 GIT binary patch delta 1275 zcmV%L_t(&-tF28cdH-_0N`1Cp;q|+zjjU2NO%gO-Fi-Q zPG`$@w{N*IK-o|8LGeTJMSsy>^cVd_e=d4`#0R36>h}^OgD{qgq`VSd9e+;Z9{)({$d)rAQXPT48 zvG3z(AVZX**DY+In`t2$|AjT^$;L5_CbE?4TAFDeP3#C-Ji}aLXej|Lx`xry1mB?R`q_M=bJ4urg~y6(T3YdM(5do}5;G0C zmU4gYk?nR5n|vi&$Ux^6~1FBIjOii0vO zWj#8*G^jvRVHi5b+`H)R6$R*~(b}vHw04#a6`2kdNO&u z=y3${S?H{lX$>0KkY{XNWoQwIeDtwRfTDjN-Se%m zfgT2}hvAA$6FG!7txsj&YHvZOGQE!u-&3qOwgSob-1j1NBbuqjK?B8Yz1v7bXlU}c z8(s_1d`n9KW98GhY24HYQ)rx-riq>vqKQ4vMBYQ|Kv1pVfB81YE0cS20h<2Ry3&8M zV)Q)21A-P+!8v9Zjq{D^g9Z)142@BFC8mIGQ(aLPO13^AIC%>=N`m`{-wNA4bzHNoc&$5DlXzpbgXn%QOxYqS z^HKLOXwyBimP#hmb{xGCz4onkSIvL+=lpLRM&mnzh^6QC=(zAy^f>0Ck8ei8LtW>h zaf(WyDFB^U9)FHDH=;rBO)ix?sOvJ_`f=I&9*5A7?d2KNs~>28b8!(G-@xGLafFcs znsTl6vS__k^kH=QvDINTHZAz*p!w$Fl5@mv3qm7#W2?v}0O}c!lc26~EFXVeaE_Rn zX-1BtfsJ25@(D$I4dJWfKpGh$t)rTkFz{^W89omwy{)98vDULHF1 zcOKdCn8wxcS`srfwNppRKsXOK(RTeX%3)satI{RYcon*7Ml!o-g66Ianm3}GZR>I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