home *** CD-ROM | disk | FTP | other *** search
/ AMOS PD CD / amospdcd.iso / totallyamos / issue4 / source_progs / inertia / inertia.amos / inertia.amosSourceCode < prev    next >
Encoding:
AMOS Source Code  |  1992-04-25  |  1.0 KB  |  47 lines

  1. '
  2. 'If you move this prog off the ta disk remove the line below or  
  3. 'change it to the name of the new disk.
  4. '
  5. Dir$="Totally_amos_may_92:source_progs/inertia"
  6. '
  7. Rem
  8. Rem ** Controlling a sprite with inertia by David Boucher ** 
  9. Rem ** Grap a Joystick **
  10. Rem
  11. Global X#,Y#,XM#,YM#,PSPEED#,PIN#
  12. Procedure CTRL_PLR
  13.    If Jup(1) and YM#>-PSPEED# : YM#=YM#-PIN# : End If 
  14.    If Jdown(1) and YM#<PSPEED# : YM#=YM#+PIN# : End If 
  15.    If Jleft(1) and XM#>-PSPEED# : XM#=XM#-PIN# : End If 
  16.    If Jright(1) and XM#<PSPEED# : XM#=XM#+PIN# : End If 
  17. End Proc
  18. Procedure MOVE_PLR
  19.    Shared XT#,YT#
  20.    X#=X#+XM#
  21.    Y#=Y#+YM#
  22.    If Abs(XM#)<PIN# Then XM#=0
  23.    If Abs(YM#)<PIN# Then YM#=0
  24.    XM#=XM#-(Sgn(XM#)*(PIN#*0.1))
  25.    YM#=YM#-(Sgn(YM#)*(PIN#*0.1))
  26.    If X#<0 Then XM#=-XM#/2 : X#=0
  27.    If X#>309 Then XM#=-XM#/2 : X#=309
  28.    If Y#<0 Then YM#=-YM#/2 : Y#=0
  29.    If Y#>185 Then YM#=-YM#/2 : Y#=185
  30. End Proc
  31. Curs Off 
  32. Flash Off 
  33. Paper 0
  34. Cls 
  35. Double Buffer 
  36. Autoback 1
  37. Hide 
  38. X#=100 : Y#=100
  39. XM#=0 : YM#=0
  40. PSPEED#=2
  41. PIN#=0.1
  42. Do 
  43.    CTRL_PLR
  44.    MOVE_PLR
  45.    Bob 1,X#,Y#,1
  46.    Exit If Inkey$<>""
  47. Loop