Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function PlayerStuff()
- things[player,thingThrust] = 0 'stops the ship getting too fast
- If KeyDown(key_up) ' WOOOOOSH, get XY values from thrust using cos/sin
- things[player,thingThrust] = 0.25
- Local ThrustX:Float = things[player,thingThrust]*Cos(things[player,thingDirection])
- Local ThrustY:Float = things[player,thingThrust]*Sin(things[player,thingDirection])
- 'then add those values to the ship's XY velocity
- things[player,thingXVelocity]:+ ThrustX
- things[player,thingYVelocity]:+ ThrustY
- EndIf
- 'manage other input
- If KeyDown(key_left) Then things[player,thingDirection]:-4
- If KeyDown(key_right) Then things[player,thingDirection]:+4
- If KeyHit(key_space) Then MakeThing(1,things[player,thingX],things[player,thingY],things[player,thingDirection])
- 'a bit of friction, for the road // make sure ship doesn't go too fast
- things[player,thingXVelocity]:*friction
- things[player,thingYVelocity]:*friction
- If Abs(things[player,thingXVelocity]) > 8 Then things[player,thingXVelocity]:*0.75
- If Abs(things[player,thingYVelocity]) > 8 Then things[player,thingYVelocity]:*0.75
- 'update the ship's position
- things[player,thingX]:+things[player,thingXVelocity]
- things[player,thingY]:+things[player,thingYVelocity]
- 'manage screen wrapping
- If things[player,thingX] > 640 Then things[player,thingX] = 0
- If things[player,thingY] > 480 Then things[player,thingY] = 0
- If things[player,thingX] < 0 Then things[player,thingX] = 640
- If things[player,thingY] < 0 Then things[player,thingY] = 480
- End Function
Add Comment
Please, Sign In to add comment