Guest User

Untitled

a guest
Apr 14th, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function PlayerStuff()
  2.     things[player,thingThrust] = 0 'stops the ship getting too fast
  3.     If KeyDown(key_up) ' WOOOOOSH, get XY values from thrust using cos/sin
  4.         things[player,thingThrust] = 0.25
  5.         Local ThrustX:Float = things[player,thingThrust]*Cos(things[player,thingDirection])
  6.         Local ThrustY:Float = things[player,thingThrust]*Sin(things[player,thingDirection])
  7.     'then add those values to the ship's XY velocity
  8.         things[player,thingXVelocity]:+ ThrustX
  9.         things[player,thingYVelocity]:+ ThrustY
  10.     EndIf
  11. 'manage other input
  12.     If KeyDown(key_left) Then things[player,thingDirection]:-4
  13.     If KeyDown(key_right) Then things[player,thingDirection]:+4
  14.     If KeyHit(key_space) Then MakeThing(1,things[player,thingX],things[player,thingY],things[player,thingDirection])
  15. 'a bit of friction, for the road // make sure ship doesn't go too fast
  16.     things[player,thingXVelocity]:*friction
  17.     things[player,thingYVelocity]:*friction
  18.     If Abs(things[player,thingXVelocity]) > 8 Then things[player,thingXVelocity]:*0.75
  19.     If Abs(things[player,thingYVelocity]) > 8 Then things[player,thingYVelocity]:*0.75
  20. 'update the ship's position
  21.     things[player,thingX]:+things[player,thingXVelocity]
  22.     things[player,thingY]:+things[player,thingYVelocity]
  23. 'manage screen wrapping
  24.     If things[player,thingX] > 640 Then things[player,thingX] = 0
  25.     If things[player,thingY] > 480 Then things[player,thingY] = 0
  26.     If things[player,thingX] < 0 Then things[player,thingX] = 640
  27.     If things[player,thingY] < 0 Then things[player,thingY] = 480
  28. End Function
Add Comment
Please, Sign In to add comment