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
Method OnUpdate() | |
Local time_delta:Float = Float(engine.CalcDeltaTime())/60.0 | |
If (player.box.GetText() = "DESTROYED" And play_scene.isActive) | |
play_scene.SetActive(False) | |
game_over_scene.SetActive(True) | |
game_over_scene.SetVisible(True) | |
game_over_scene.SetAlpha(1.0) | |
Else If (game_over_scene.isActive) | |
If (KeyDown(KEY_ENTER)) |
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 | |
Import character | |
Import projectile | |
Import custom_engine | |
Class Game Extends App | |
Field engine: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
Method CreatePlayer() | |
Local box:ftObject = Self.engine.CreateBox(120, 20, engine.GetCanvasWidth()/2, engine.GetCanvasHeight()/2) | |
box.SetColor(0, 70, 70) | |
box.SetMaxSpeed(20.0) | |
box.SetMinSpeed(-20.0) | |
box.SetColGroup(PLAYER_GROUP) | |
box.SetColType(Self.engine.ctBox) | |
box.SetText("PLAYER") | |
Local projectile_type:ProjectileType = New ProjectileType() | |
' Update the constructor to use the new string identifier |
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 | |
Import projectile_type | |
Class Character | |
Field box:ftObject | |
Field current_health:Int | |
Field max_health:Int | |
' changing is_player to character_type | |
Field character_type:String |
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 CustomEngine Extends ftEngine | |
' Add player and projectile collision to the final boss | |
Method OnObjectCollision:Int(obj_one:ftObject, obj_two:ftObject) | |
If (obj_one.GetText() = "PLAYER" And (obj_two.GetText() = "ENEMY" Or obj_two.GetText() = "FINALBOSS")) | |
CharacterCollision(obj_one, obj_two) | |
Else If (obj_two.GetText() = "PLAYER" And (obj_one.GetText() = "ENEMY" Or obj_one.GetText() = "FINALBOSS")) | |
CharacterCollision(obj_two, obj_one) |
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 Class | |
Method Update(game_width:Float, game_height:Float) | |
Local x_speed:Float = Self.box.GetSpeedX() | |
Local y_speed:Float = Self.box.GetSpeedY() | |
If (Self.is_player) | |
If (KeyDown(KEY_LEFT)) | |
Self.box.SetSpeedX(x_speed - 1.0) | |
Else If (KeyDown(KEY_RIGHT)) | |
Self.box.SetSpeedX(x_speed + 1.0) |
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 | |
Import character | |
Import projectile | |
Import custom_engine | |
Class Game Extends App | |
Field engine: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
Class Game Extends App | |
Field engine:ftEngine | |
Field play_layer:ftLayer | |
Field play_scene:ftScene | |
Field game_over_scene:ftScene | |
Field game_over_layer:ftLayer | |
Field player:Character | |
Field enemies:List<Character> | |
Field last_enemy_time:Float |
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
Method OnUpdate() | |
Local time_delta:Float = Float(engine.CalcDeltaTime())/60.0 | |
If (player.box.GetText() = "DESTROYED" And play_scene.isActive) | |
play_scene.SetActive(False) | |
game_over_scene.SetActive(True) | |
' Manage the visibility of the game over scene | |
game_over_scene.SetVisible(True) | |
game_over_scene.SetAlpha(1.0) | |
' Reset the game if the player hits ENTER during game over |
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
' Game class | |
Method OnCreate() | |
Self.engine = New CustomEngine | |
play_scene = engine.GetDefaultScene() | |
play_layer = engine.GetDefaultLayer() | |
play_scene.AddLayer(play_layer) | |
' Create our player | |
CreatePlayer() |