home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1992-04-25 | 1.0 KB | 47 lines |
- '
- 'If you move this prog off the ta disk remove the line below or
- 'change it to the name of the new disk.
- '
- Dir$="Totally_amos_may_92:source_progs/inertia"
- '
- Rem
- Rem ** Controlling a sprite with inertia by David Boucher **
- Rem ** Grap a Joystick **
- Rem
- Global X#,Y#,XM#,YM#,PSPEED#,PIN#
- Procedure CTRL_PLR
- If Jup(1) and YM#>-PSPEED# : YM#=YM#-PIN# : End If
- If Jdown(1) and YM#<PSPEED# : YM#=YM#+PIN# : End If
- If Jleft(1) and XM#>-PSPEED# : XM#=XM#-PIN# : End If
- If Jright(1) and XM#<PSPEED# : XM#=XM#+PIN# : End If
- End Proc
- Procedure MOVE_PLR
- Shared XT#,YT#
- X#=X#+XM#
- Y#=Y#+YM#
- If Abs(XM#)<PIN# Then XM#=0
- If Abs(YM#)<PIN# Then YM#=0
- XM#=XM#-(Sgn(XM#)*(PIN#*0.1))
- YM#=YM#-(Sgn(YM#)*(PIN#*0.1))
- If X#<0 Then XM#=-XM#/2 : X#=0
- If X#>309 Then XM#=-XM#/2 : X#=309
- If Y#<0 Then YM#=-YM#/2 : Y#=0
- If Y#>185 Then YM#=-YM#/2 : Y#=185
- End Proc
- Curs Off
- Flash Off
- Paper 0
- Cls
- Double Buffer
- Autoback 1
- Hide
- X#=100 : Y#=100
- XM#=0 : YM#=0
- PSPEED#=2
- PIN#=0.1
- Do
- CTRL_PLR
- MOVE_PLR
- Bob 1,X#,Y#,1
- Exit If Inkey$<>""
- Loop