home *** CD-ROM | disk | FTP | other *** search
- 10 ! *********************************************************************
- 20 ! Example: Hammer Game
- 30 !
- 40 ! The object of this game is to click the pushbutton before it moves.
- 50 ! How often the button moves and how large it is are adjustable with
- 60 ! sliders. Every time the button is successfully clicked, the score
- 70 ! increases by one point.
- 80 !
- 90 ! *********************************************************************
- 100 !
- 110 ! Move the button every two seconds
- 120 !
- 130 Speed=2
- 140 ASSIGN @Speed TO WIDGET "SLIDER";SET ("ORIENTATION":"HORIZONTAL","X":415,"Y":10,"TITLE":" Speed ","LOGARITHMIC":1,"VALUE":Speed,"WIDTH":250,"HEIGHT":60)
- 150 CONTROL @Speed;SET ("MAXIMUM":2,"MINIMUM":.2)
- 160 ON EVENT @Speed,"DONE",3 GOSUB Speed_change
- 170 !
- 180 ! Set button size to 25 pixels on a side
- 190 !
- 200 Size=25
- 210 ASSIGN @Size TO WIDGET "SLIDER";SET ("ORIENTATION":"HORIZONTAL","X":150,"Y":10,"TITLE":" Size ","LOGARITHMIC":1,"VALUE":Size,"WIDTH":250,"HEIGHT":60)
- 220 CONTROL @Size;SET ("MAXIMUM":100,"MINIMUM":10)
- 230 ON EVENT @Size,"DONE",3 GOSUB Size_change
- 240 !
- 250 ! Set up the score
- 260 !
- 270 Score=0
- 280 ASSIGN @Score TO WIDGET "LABEL";SET ("VALUE":VAL$(Score),"TITLE":" Hits","X":10,"Y":10,"WIDTH":125,"HEIGHT":60)
- 290 !
- 300 ! Draw the moving widget
- 310 !
- 320 ASSIGN @Button TO WIDGET "PUSHBUTTON";SET ("WIDTH":50,"HEIGHT":30,"LABEL":"","TITLE":"","X":300)
- 330 !
- 340 ! When the button is pushed, score a hit
- 350 !
- 360 ON EVENT @Button,"ACTIVATED",3 GOSUB Hit
- 370 !
- 380 ! Provide a button to stop the game
- 390 !
- 400 ASSIGN @Stop TO WIDGET "PUSHBUTTON";SET ("RESIZABLE":0,"WIDTH":125,"HEIGHT":30,"LABEL":"Quit","TITLE":"","X":10,"Y":80)
- 410 ON EVENT @Stop,"ACTIVATED",3 GOTO Stop_game
- 420 !
- 430 ! Move the button on a regular basis
- 440 !
- 450 ON CYCLE Speed GOSUB Move_button
- 460 LOOP
- 470 WAIT FOR EVENT
- 480 END LOOP
- 490 Hit: ! Button was hit
- 500 Score=Score+1
- 510 CONTROL @Score;SET ("VALUE":VAL$(Score))
- 520 GOSUB Move_button ! Too easy to hit again
- 530 RETURN
- 540 Move_button: ! Move the button to new location
- 550 !
- 560 ! The scaling should depend on the size of the display
- 570 !
- 580 CONTROL @Button;SET ("X":RND*500+60,"Y":RND*400)
- 590 RETURN
- 600 Speed_change: ! Speed slider was moved
- 610 !
- 620 STATUS @Speed;RETURN ("VALUE":Speed)
- 630 ON CYCLE Speed GOSUB Move_button
- 640 RETURN
- 650 Size_change: ! Size slider was moved
- 660 STATUS @Size;RETURN ("VALUE":Size)
- 670 CONTROL @Button;SET ("WIDTH":Size,"HEIGHT":Size)
- 680 RETURN
- 690 Stop_game: !
- 700 OFF CYCLE
- 710 ASSIGN @Button TO *
- 720 ASSIGN @Size TO *
- 730 ASSIGN @Speed TO *
- 740 ASSIGN @Score TO *
- 750 ASSIGN @Stop TO *
- 760 STOP
- 770 END
-