Created
November 26, 2016 18:39
-
-
Save codetravis/67fa80dbeea3069918a3ae6ce2451d1e to your computer and use it in GitHub Desktop.
6.4 Add update method to the character class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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