Created
February 11, 2017 19:32
-
-
Save codetravis/9c60cb01c78d6aa183568fffa1c535f2 to your computer and use it in GitHub Desktop.
14.3 New file to hold AI movement patterns
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 | |
' Added this file to hold our various AI movement patterns | |
Function SimpleBossPattern(box:ftObject, game_width:Float, game_height:Float) | |
Local y_speed:Float = box.GetSpeedY() | |
Local x_speed:Float = box.GetSpeedX() | |
If (box.GetPosY() < 0) | |
box.SetSpeedY(y_speed + 0.5) | |
Else If (box.GetPosY() > game_height) | |
box.SetSpeedY(y_speed - 0.5) | |
Else If (y_speed > 0) | |
box.SetSpeedY(y_speed + 0.5) | |
Else If (y_speed < 0) | |
box.SetSpeedY(y_speed - 0.5) | |
Else If (y_speed = 0) | |
box.SetSpeedY(y_speed + 0.5) | |
End | |
End | |
' Simple up and down movement for enemies | |
Function SimpleWavePattern(box:ftObject, game_width:Float, game_height:Float, start_y:Float, y_change:Float=50.0, max_y_speed:Float=5.0) | |
Local y_speed:Float = box.GetSpeedY() | |
If (y_speed < 0) | |
If (box.GetPosY() < start_y - y_change) | |
box.SetSpeedY(y_speed * -1) | |
End | |
Else If (y_speed > 0) | |
If (box.GetPosY() > start_y + y_change) | |
box.SetSpeedY(y_speed * -1) | |
End | |
Else | |
box.SetSpeedY(max_y_speed) | |
End | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment