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
Local deltax:Float = Abs(target.x - position.x) | |
Local deltay:Float = Abs(target.y - position.y) | |
Local sum_delta:Float = deltax + deltay | |
If (target.x > position.x) | |
velocity.x = speed * (deltax / sum_delta) | |
Else If (target.x < position.x) | |
velocity.x = -speed * (deltax / sum_delta) | |
End |
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
#FantomX_UsePhysics = True | |
Import fantomX | |
Class Game Extends App | |
Field engine:ftEngine | |
Method OnCreate:Int() | |
engine = New ftEngine |
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
#FantomX_UsePhysics = True | |
Import fantomX | |
Class Game Extends App | |
Field engine:ftEngine | |
Field default_layer:ftLayer | |
Field default_scene:ftScene | |
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
#FantomX_UsePhysics = True | |
Import fantomX | |
Class Game Extends App | |
Field engine:ftEngine | |
Field default_layer:ftLayer | |
Field default_scene:ftScene | |
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
' character.monkey | |
Import fantomX | |
Class Character | |
Method New() | |
End | |
End |
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
' main.monkey OnCreate class | |
Method OnCreate() | |
engine = New ftEngine | |
default_scene = engine.GetDefaultScene() | |
default_layer = engine.GetDefaultLayer() | |
' create a box ftObject | |
Local box:ftObject = engine.CreateBox(120, 20, engine.GetCanvasWidth()/2, engine.GetCanvasHeight()/2) | |
box.SetColor(0, 70, 70) |
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
' main.monkey OnRender function | |
Method OnRender() | |
engine.Clear(255, 0, 0) | |
engine.Render() | |
engine.SetColor(0, 70, 70) | |
engine.GetCanvas().DrawText("Last Touch: " + engine.GetTouchX() + ", " + engine.GetTouchY(), | |
engine.GetLocalX(10), engine.GetLocalY(10)) | |
engine.RenderFlush() | |
End |
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 | |
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
' main.monkey | |
Method OnUpdate() | |
Local time_delta:Float = Float(engine.CalcDeltaTime())/60.0 | |
' Call the player's Character class update method | |
player.Update() | |
If engine.GetPaused() = False | |
engine.Update(time_delta) | |
End |
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
' character.monkey | |
Method Update(game_width:Float, game_height:Float) | |
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 |
OlderNewer