Skip to content

Instantly share code, notes, and snippets.

@codetravis
Created February 11, 2017 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetravis/9c60cb01c78d6aa183568fffa1c535f2 to your computer and use it in GitHub Desktop.
Save codetravis/9c60cb01c78d6aa183568fffa1c535f2 to your computer and use it in GitHub Desktop.
14.3 New file to hold AI movement patterns
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