![]() HomePage |
The guys at SiMPle codeworks told me that if I put some of my SiMPLE programs on my website, they would include a link to my homepage. So, here is a "shooting gallery" program where you have to see how many ducks and targets you can hit in one minute.
(To run the program on your own computer, just use your mouse to highlight the listing and then copy it into the clipboard. You can then paste it as a text file into one of your SIMPLE projects.)
Int dloc[]={ 0,100,200,300,400,500,600}
Int tloc[]={50,150,250,350,450,550,650}
Int dup[]={ 1, 1, 1, 1, 1, 1, 1}
Int tup[]={ 1, 1, 1, 1, 1, 1, 1}
Int xm, ym, button
Do
graphon; cls
tabxy (33, 6); Display "SHOOTING GALLERY"
score=0; hit=0; start timer
Do
Do k=0,50
If (hit) sound (1000-15*k)
delay (1); no sound
Loop k
time=(60500L-elapsed time())/1000
tabxy (27,25); Display "TIME: ",time,,
tabxy (47,25); Display "SCORE: ",score,,
If time<=0 Break
Do j=0,6
erase (dloc[j]) @
If (dup[j]=1) draw duck (dloc[j]) @
dloc[j]=(dloc[j]+5)%700
If (dloc[j]=0) dup[j]=1
erase (tloc[j]) @
If (tup[j]=1) draw target (tloc[j]) @
tloc[j]=(tloc[j]+5)%700
If (tloc[j]=0) tup[j]=1
read quit key (27)
Loop j
solid color (8); solid rectangle (0,240,640,245)
read mouse (xm, ym, button) @
hit=0; draw gun (xm, ym) @
If button=0 Continue
Do k=1000,100
sound (k)
Loop k
no sound; score=score-1
move mouse (xm+random(101)-50, ym+random(101)-50)
If ym>239 Or ym<200 Continue
If getpixel(xm,ym)=0 Continue
Do i=0,6
If (iabs(dloc[i]-xm)<20) dup[i]=0
If (iabs(tloc[i]-xm)<20) tup[i]=0
Loop i
hit=1; score=score+2
Loop
tabxy (37, 15); framed text ("GAME OVER")
key=wait key(); If (key=27) quit
Loop
Task draw duck (Int x)
solid color (14); solid ellipse (x+15, 226, 6, 1)
solid color (6); solid ellipse (x, 233, 13, 6)
solid color (2); solid ellipse (x+11, 225, 5, 5)
put pixel (x+13, 225, 8); put pixel (x+13, 224, 8)
Task draw target (Int x)
solid color (4); solid circle (x, 229, 10)
solid color (7); solid circle (x, 229, 8)
solid color (4); solid circle (x, 229, 6)
solid color (7); solid circle (x, 229, 4)
solid color (4); solid circle (x, 229, 2)
Task draw gun (Int x, Int y)
Common Int oldx=0, oldy=0
line color (0)
line (oldx-15,oldy,oldx-5,oldy)
line (oldx,oldy-15,oldx,oldy-5)
line (oldx+5,oldy,oldx+15,oldy)
line (oldx,oldy+15,oldx,oldy+5)
line color (3)
line (x-15,y,x-5,y)
line (x,y-15,x,y-5)
line (x+5,y,x+15,y)
line (x,y+15,x,y+5)
oldx=x; oldy=y
Task erase (Int x)
solid color (0); solid rectangle (x-20, 219, x+10, 239)
Task read mouse (Int xm, Int ym, Int button)
Int but
read mouse (xm, ym, button)
If (ym<125) ym=125
If (ym>355) ym=355
move mouse (xm, ym)
Do
read mouse (0, 0, but)
If but=0 Break
Loop
If you'd like to find out more about SiMPLE, here is the link to their website:
www.simplecodeworks.com
This site built and hosted for free by FreeWebs.com. Click here to get your own free website.