Files
TempleOS-Rijn/LT/DEMO/Graphics/StarTrek1.CPZ
T
2018-09-08 21:45:17 +02:00

147 lines
3.7 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
$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;
­6çÿÿÿðÿÿÿ[gÛ®m’d’$IÛvÛFaûö:@LÕÿÿÿ$ýÛ¶m{^‚ @’$±}ÿ÷“$Ù’$q=×¶Móô“Ùÿÿÿ$I’$I’äù“<I’¤(’$I’”HŠ$EŠJ’$‰’mݶuÛ¼­ÛºÍÛ¶mÛ¶mÛ¶mÛ†¶mŠçÿÿÿøÿÿÿ$I’$I’$I’$I’$I’$I’$I’$™D‰%I¶µ]»mÛ¶Û¶mÛ¶mÛ¶mÛ¶­Ý¶m!÷ÿÿÿüÿÿÿÿÿÿÿÿÿÿÿ5
üI’'I“'Ïÿ?žIIIQ$»=¶íÿÿÿ“çyÒ$I’4I’$Iž$I’$M’$Ož$IIEQ’$EIÀ0 Ã`¶aÛ°mö
ضµmÛnë¶¶]·®ë¶n+säÿÛ¶×u]·nõÿÿÿÿÿÿÿ ùÿÿÿ ùÿÿÿõÿÿÿõÿÿÿëÿÿÿëÿÿÿ åÿÿÿ åÿÿÿ5æÿÿÿ5æÿÿÿWòÿÿÿWòÿÿÿW÷ÿÿÿW÷ÿÿÿ2üÿÿÿ2üÿÿÿ úÿÿÿ5ûÿÿÿ555WÿÿÿÿWÿÿÿÿXñÿÿÿXñÿÿÿhãÿÿÿhãÿÿÿ\\Uîÿÿÿ\^^R`mîÿÿÿmîÿÿÿiãÿÿÿïÿÿÿ.Üÿÿÿ.Üÿÿÿ<ïÿÿÿfõÿÿÿiëÿÿÿiëÿÿÿjñÿÿÿiñÿÿÿgøÿÿÿ`_ _ býÿÿÿbýÿÿÿ`Q%%,,GG@@UøÿÿÿTøÿÿÿ7þÿÿÿ7þÿÿÿæÿÿÿæÿÿÿÿÿÿÿÿÿÿÿóÿÿÿóÿÿÿ&ûÿÿÿ$<$0þÿÿÿd &ýÿÿÿ@æÿÿÿýÿÿÿèÿÿÿ