147 lines
3.7 KiB
Plaintext
147 lines
3.7 KiB
Plaintext
|
||
|
||
|
||
|
||
$PI,"",2$
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
$PI,"",4$
|
||
|
||
|
||
|
||
|
||
$PI,"",5$
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
U8 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=GrNew(grbase2);
|
||
|
||
#define NUM_STARS 100
|
||
I8 stars_x[NUM_STARS],stars_y[NUM_STARS];
|
||
|
||
void PhasorTsk()
|
||
{
|
||
I2 i;
|
||
for (i=2000;i>100;i=i-3) {
|
||
Sound(i);
|
||
Sleep(1);
|
||
}
|
||
Sound(0);
|
||
}
|
||
|
||
void BoomTsk()
|
||
{
|
||
I2 i;
|
||
for (i=2000;i>100;i=i-3) {
|
||
Sound(100+100*(i&1));
|
||
Sleep(1);
|
||
}
|
||
Sound(0);
|
||
}
|
||
|
||
|
||
void DrawIt()
|
||
{
|
||
U8 i;
|
||
|
||
ClearWindowText;
|
||
|
||
base->color=GR_WHITE;
|
||
for (i=0;i<NUM_STARS;i++)
|
||
GrPlot0(base,stars_x[i],stars_y[i]);
|
||
|
||
GrElemsPlot(base,ipx,ipy,0,img1,GR_BLACK);
|
||
if (destroyed_time) {
|
||
GrElemsPlot(base,x,y,0,img3,GR_BLACK);
|
||
if (jiffies>=destroyed_time)
|
||
destroyed_time=0;
|
||
} else
|
||
GrElemsPlot(base,x,y,0,img2,GR_BLACK);
|
||
if (phasor_time) {
|
||
base->color=GR_BLUE;
|
||
GrLine(base,ipx+130,ipy+45,ipx+400,ipy+45);
|
||
if (jiffies>=phasor_time)
|
||
phasor_time=0;
|
||
}
|
||
}
|
||
|
||
I8 PopUpJoystickMouse()
|
||
{
|
||
I8 i;
|
||
Ltf *l=LtfNew;
|
||
LtfPutS(l,"$$CM +LX, 2,4$$$$BT, \"Mouse\" 1$$");
|
||
LtfPutS(l,"$$CM +LX, 18,0$$$$BT, \"JoyStick\" 0$$");
|
||
i=PopUpMenu(l);
|
||
LtfDel(l);
|
||
return i;
|
||
}
|
||
|
||
|
||
|
||
void StarTrek1()
|
||
{
|
||
U8 i;
|
||
U8 old_ip=ip_pointer_type;
|
||
U4 *old_update_window=Fs->update_window;
|
||
U4 old_text_attr=Fs->text_attribute;
|
||
|
||
if (PopUpJoystickMouse)
|
||
ip_pointer_type=IP_MOUSE;
|
||
else {
|
||
ip_pointer_type=IP_JOYSTICK0;
|
||
LoadJoystickCalibration;
|
||
}
|
||
|
||
ip_inhibit_win_operations=TRUE;
|
||
Fs->text_attribute=0;
|
||
Fs->update_window=&DrawIt;
|
||
MaximizeWindow;
|
||
|
||
for (i=0;i<NUM_STARS;i++) {
|
||
stars_x[i]=RandU2%grwidth;
|
||
stars_y[i]=RandU2%grheight;
|
||
}
|
||
while (!ip_rb) { //not right button
|
||
x=x+3; y=y-2;
|
||
if (x>grwidth) x=0;
|
||
if (y<0) y=grheight;
|
||
if (ip_lb) { //left button?
|
||
Spawn(&PhasorTsk);
|
||
phasor_time=jiffies+JIFFY_FREQ/2; //half second
|
||
if (AbsI8(ipx+400-x)<100 && AbsI8(ipy+45-y)<100) {
|
||
destroyed_time=jiffies+JIFFY_FREQ; //one second
|
||
Spawn(&BoomTsk);
|
||
}
|
||
}
|
||
Sleep(50);
|
||
}
|
||
Sound(0);
|
||
Fs->update_window=old_update_window;
|
||
Fs->text_attribute=old_text_attr;
|
||
ip_pointer_type=old_ip;
|
||
ip_inhibit_win_operations=FALSE;
|
||
LtfBottom(Fs->cur_ltf);
|
||
}
|
||
|
||
StarTrek1;
|
||
|