tfv: start cleaning up flying code

This commit is contained in:
Vince Weaver 2017-08-23 14:01:40 -04:00
parent a7d707da9c
commit 86167a1245

View File

@ -12,50 +12,6 @@
#include "tfv_sprites.h"
#if 0
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,},
{14,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,5,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, 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,15,15,15, 15,15,15, 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, 13,12,12, 8, 4, 4, 0,13, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,},
{2,2,2,2, 13,12,12,12, 8, 4, 4,13, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,},
{2,2,2,2, 13,12,12, 8, 4, 4, 4,13, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2, 2,2,2,2,},
{2,2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, 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,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,},
};
#endif
static unsigned char flying_map[64]= {
2,15,15,15, 15,15,15, 2,
13,12,12, 8, 4, 4, 0,13,
@ -138,14 +94,19 @@ void draw_background_mode7(double angle, double cx, double cy) {
clear_top(0);
/* Draw Sky */
/* Originally wanted to be fancy and have sun too, but no */
color_equals(COLOR_MEDIUMBLUE);
for(screen_y=0;screen_y<6;screen_y+=2) {
hlin_double(0, 0, 40, screen_y);
}
/* Draw hazy horizon */
color_equals(COLOR_GREY);
hlin_double(0, 0, 40, 6);
printf("%lf %lf\n",cx,cy);
// printf("%lf %lf\n",cx,cy);
for (screen_y = 8; screen_y < bmp_h; screen_y++) {
// first calculate the distance of the line we are drawing
@ -205,7 +166,6 @@ void draw_background_mode7(double angle, double cx, double cy) {
int flying(void) {
int i;
unsigned char ch;
int xx,yy;
int turning=0;
@ -220,19 +180,6 @@ int flying(void) {
gr();
xx=15; yy=20;
color_equals(COLOR_BLACK);
color_equals(COLOR_MEDIUMBLUE);
for(i=0;i<20;i++) {
hlin(1, 0, 40, i);
}
color_equals(COLOR_DARKBLUE);
for(i=20;i<48;i++) {
hlin(1, 0, 40, i);
}
while(1) {
if (draw_splash>0) draw_splash--;
@ -241,6 +188,7 @@ int flying(void) {
if ((ch=='q') || (ch==27)) break;
#if 0
if (ch=='g') {
BETA+=0.1;
printf("Horizon=%lf\n",BETA);
@ -255,8 +203,9 @@ int flying(void) {
scale_y++;
printf("Scale=%lf\n",scale_x);
}
#endif
if ((ch=='i') || (ch==APPLE_UP)) {
if ((ch=='w') || (ch==APPLE_UP)) {
if (yy>16) {
yy-=2;
space_z+=1;
@ -264,7 +213,7 @@ int flying(void) {
printf("Z=%lf\n",space_z);
}
if ((ch=='m') || (ch==APPLE_DOWN)) {
if ((ch=='s') || (ch==APPLE_DOWN)) {
if (yy<28) {
yy+=2;
space_z-=1;
@ -274,7 +223,7 @@ int flying(void) {
}
printf("Z=%lf\n",space_z);
}
if ((ch=='j') || (ch==APPLE_LEFT)) {
if ((ch=='a') || (ch==APPLE_LEFT)) {
if (turning>0) {
turning=0;
}
@ -287,7 +236,7 @@ int flying(void) {
// printf("Angle %lf\n",our_angle);
}
if ((ch=='k') || (ch==APPLE_RIGHT)) {
if ((ch=='d') || (ch==APPLE_RIGHT)) {
if (turning<0) {
turning=0;
}
@ -314,21 +263,14 @@ int flying(void) {
}
{
dx = speed * cos (our_angle);
dy = speed * sin (our_angle);
dx = speed * cos (our_angle);
dy = speed * sin (our_angle);
flyx += dx;
flyy += dy;
}
// gr_copy(0x800,0x400);
flyx += dx;
flyy += dy;
draw_background_mode7(our_angle, flyx, flyy);
// 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,