Instantly share code, notes, and snippets.

Embed
What would you like to do?
8.6 Add Projectile class
Import fantomX
Import projectile_type
Class Projectile
Field box:ftObject
Field projectile_type:ProjectileType
Method New(box:ftObject, projectile_type:ProjectileType)
Self.box = box
Self.projectile_type = projectile_type
End
Method Update()
Local modifier:Float = 1
If (Self.box.GetSpeedX() < 0)
modifier = -1
End
If (Abs(Self.box.GetSpeedX()) <= Self.projectile_type.max_speed)
Self.box.SetSpeedX(Self.box.GetSpeedX() + (Self.projectile_type.acceleration * modifier))
Else
Self.box.SetSpeedX(Self.projectile_type.max_speed * modifier)
End
End
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment