Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
6.4 Add update method to the character class
Import fantomX
Class Character
Field box:ftObject
Method New(box:ftObject)
Self.box = box
End
Method Update()
Local x_speed:Float = Self.box.GetSpeedX()
Local y_speed:Float = Self.box.GetSpeedY()
If (KeyDown(KEY_LEFT))
Self.box.SetSpeedX(x_speed - 1.0)
Else If (KeyDown(KEY_RIGHT))
Self.box.SetSpeedX(x_speed + 1.0)
End
If (KeyDown(KEY_UP))
Self.box.SetSpeedY(y_speed - 1.0)
Else If (KeyDown(KEY_DOWN))
Self.box.SetSpeedY(y_speed + 1.0)
End
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment