162 lines
4.6 KiB
Plaintext
162 lines
4.6 KiB
Plaintext
$FD,15$$BD,0$
|
|
|
|
|
|
$PI,"",2$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$PI,"",4$
|
|
|
|
|
|
|
|
|
|
$PI,"",5$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
U8 enemy_destroyed_time=0;
|
|
U8 player_destroyed_time=0;
|
|
U8 phasor_time=0;
|
|
I8 x=100,y=100;
|
|
U1 *img1=$IB,"<P2>",2$;
|
|
U1 *img2=$IB,"<P4>",4$;
|
|
U1 *img3=$IB,"<P5>",5$;
|
|
GrBitMap *base=GrAlias(grbase2,Fs);
|
|
|
|
#define NUM_STARS 100
|
|
I8 stars_x[NUM_STARS],stars_y[NUM_STARS];
|
|
|
|
void PhasorTsk()
|
|
{
|
|
I8 i;
|
|
for (i=2000;i>100;i-=3) {
|
|
Sound(i);
|
|
Sleep(1);
|
|
}
|
|
Sound(0);
|
|
}
|
|
|
|
void BoomTsk()
|
|
{
|
|
I8 i;
|
|
for (i=2000;i>100;i-=3) {
|
|
Sound(100+100*(i&1));
|
|
Sleep(1);
|
|
}
|
|
Sound(0);
|
|
}
|
|
|
|
|
|
void DrawIt(TssStruct *tss)
|
|
{
|
|
U8 i;
|
|
|
|
ClearWinText(tss);
|
|
|
|
base->color=WHITE;
|
|
for (i=0;i<NUM_STARS;i++)
|
|
GrPlot(base,stars_x[i],stars_y[i]);
|
|
|
|
base->bkcolor=BLACK;
|
|
if (enemy_destroyed_time) {
|
|
GrElemsPlot(base,x,y,0,img3);
|
|
if (Jiffies>=enemy_destroyed_time)
|
|
enemy_destroyed_time=0;
|
|
} else
|
|
GrElemsPlot(base,x,y,0,img2);
|
|
|
|
if (!player_destroyed_time) {
|
|
base->collision_cnt=0;
|
|
base->bkcolor=ROP_COLLISION+BLACK;
|
|
GrElemsPlot(base,ipx,ipy,0,img1);
|
|
if (base->collision_cnt>0x20) {
|
|
player_destroyed_time=Jiffies+JIFFY_FREQ; //one second
|
|
Spawn(&BoomTsk);
|
|
}
|
|
}
|
|
base->bkcolor=BLACK;
|
|
if (player_destroyed_time) {
|
|
GrElemsPlot(base,ipx,ipy,0,img3);
|
|
if (Jiffies>=player_destroyed_time)
|
|
player_destroyed_time=0;
|
|
} else
|
|
GrElemsPlot(base,ipx,ipy,0,img1);
|
|
|
|
if (phasor_time) {
|
|
base->collision_cnt=0;
|
|
base->color=ROP_COLLISION;
|
|
base->bkcolor=ROP_COLLISION+BLACK;
|
|
GrLine(base,ipx+20,ipy-9,ipx+300,ipy-9);
|
|
if (!enemy_destroyed_time && base->collision_cnt>8){
|
|
enemy_destroyed_time=Jiffies+JIFFY_FREQ; //one second
|
|
Spawn(&BoomTsk);
|
|
}
|
|
|
|
base->color=BLUE;
|
|
GrLine(base,ipx+20,ipy-9,ipx+300,ipy-9);
|
|
if (Jiffies>=phasor_time)
|
|
phasor_time=0;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SpaceShip()
|
|
{
|
|
U8 i;
|
|
U8 old_ip=ip_pointer_type;
|
|
BoolU4 old_ip_double=Bts(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK);
|
|
void *old_update=Fs->update_win;
|
|
U8 old_text_attr=Fs->text_attribute;
|
|
BoolU4 old_inhibit=ip_inhibit_win_operations;
|
|
BoolU4 old_preempt=Preempt(OFF);
|
|
BoolU4 old_wordstat=WordStat(OFF);
|
|
BoolU4 old_border=WinBorder(OFF);
|
|
PopUpInputPointer;
|
|
ip_inhibit_win_operations=TRUE;
|
|
Fs->text_attribute=BLACK+BLACK<<4;
|
|
Fs->update_win=&DrawIt;
|
|
WinMax;
|
|
for (i=0;i<NUM_STARS;i++) {
|
|
stars_x[i]=RandU2%GR_WIDTH;
|
|
stars_y[i]=RandU2%GR_HEIGHT;
|
|
}
|
|
while (!ip_rb && !ScanKey) { //not right button
|
|
x=x+3; y=y-2;
|
|
if (x>GR_WIDTH) x=0;
|
|
if (y<0) y=GR_HEIGHT;
|
|
if (ip_lb) { //left button?
|
|
phasor_time=Jiffies+JIFFY_FREQ/2; //half second
|
|
Spawn(&PhasorTsk);
|
|
}
|
|
Sleep(50);
|
|
}
|
|
Sound(0);
|
|
Fs->text_attribute=old_text_attr;
|
|
Fs->update_win=old_update;
|
|
ip_pointer_type=old_ip;
|
|
AssignBit(&Fs->crt_flags,CRTf_NO_DOUBLE_CLICK,old_ip_double);
|
|
ip_inhibit_win_operations=old_inhibit;
|
|
LtfBottom(Fs->cur_ltf);
|
|
Preempt(old_preempt);
|
|
WinBorder(old_border);
|
|
WordStat(old_wordstat);
|
|
}
|
|
|
|
SpaceShip;
|
|
|