home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
w
/
wgt3_ex.zip
/
FLY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-15
|
3KB
|
160 lines
#include <conio.h>
#include "wgt.h"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
color p[256];
int back[21];
int starx[20],stary[20];
int i,y,bottom,c,ctr,c2;
int speed=5,ofs=0;
block sc;
block sprites[201];
int numg;
int ox,turns,turn=5;
int shootx[20],shooty[20],shootoy[20],shooton[20],numshots=0;
void resizepill(int);
void setupground(void);
void main(void)
{
vga256();
wloadsprites(&p,"fly.spr",sprites);
sc=wnewblock(0,0,319,199);
resizepill(19);
resizepill(29);
resizepill(39);
minit();
setupground();
wbutt(0,0,319,50);
wsetscreen(sc);
y=0;
wsetcolor(0);
wbar(0,0,319,50);
do {
mread();
if ((but==1) & (numshots<19)) // shoot with left mouse button
{
for (i=0; i<20; i++)
{
if (shooton[i]==0)
{
sound(300);
shootx[i]=mx+24;
shooty[i]=180;
shootoy[i]=my+7;
shooton[i]=1;
numshots++;
break;
}
}
}
wsetcolor(0);
wbar(0,0,319,50);
wsetcolor(17);
wbar(0,50,319,150);
nosound();
for (i=0; i<20; i++)
{
starx[i]-=(turn-5)*2;
if (starx[i]<0) starx[i]=319;
else if (starx[i]>319) starx[i]=0;
shootx[i]-=(turn-5)*4;
if (shootx[i]<0) shootx[i]=319;
else if (shootx[i]>319) shootx[i]=0;
wsetcolor(1);
wfastputpixel(starx[i],stary[i]);
}
for (i=numg; i>=0; i--)
{
c2=(float)((float)back[i]/(600-back[i]))*back[i];
c=back[i]/30;
if (c2<100)
{
wsetcolor(12);
wbar(0,50+c2,319,c2+c+50);
}
back[i]+=speed;
if (back[i]>200)
back[i]=back[i]-200;
}
turns=(mx-ox)/5;
if (turns==0)
{
if (turn<5) turn++;
if (turn>5) turn--;
}
if (turns<0) turn--;
if (turns>0) turn++;
if (turn<1) turn=1;
if (turn>9) turn=9;
for (i=0; i<20; i++)
{
if (shooton[i]==1)
{
shooty[i]-=10;
if (shooty[i]<0)
{
shooton[i]=0;
shooty[i]=0;
numshots--;
}
}
}
wputblock(mx,105,sprites[turn+9],1);
for (i=0; i<20; i++)
{
if (shooton[i]==1)
wputblock(shootx[i],(float)((float)shooty[i]/(600-shooty[i]))*shooty[i]+shootoy[i]-50,sprites[38-(shooty[i]/20)],1);
}
wputblock(mx,my,sprites[turn],1);
ox=mx;
wcopyscreen(0,0,319,150,sc,0,50,NULL);
} while (but !=2);
wfreeblock(sc);
textmode(C80);
}
void setupground(void)
{
for (i=0; i<21; i++)
back[i]=i*15;
i=0;
numg=12;
for (i=0; i<20; i++)
{
starx[i]=rand() % 319;
stary[i]=rand() % 50;
}
}
void resizepill(int num)
{
int g,h,nx,ny;
g=wgetblockwidth(sprites[num]);
h=wgetblockheight(sprites[num]);
for (i=9; i>=1; i--)
{
wcls(0);
nx=(float)i/10*g;
ny=(float)i/10*h;
wresize(0,0,nx,ny,sprites[num]);
sprites[num+1+(9-i)]=wnewblock(0,0,nx,ny);
}
}