Constructor
new Projectile(startPos, speed, bearing, projectileParam)
Projectile constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
startPos |
p5.Vector | Starting position of the projectile |
speed |
number | The start speed from 0-100 |
bearing |
number | Bearing to fire the projectile 0-180 in degrees. |
projectileParam |
TankGame.ProjectileParam | Struct of projectile parameters. |
- Source:
- See:
Methods
attachTo(gameEngine)
Attach the projectile to the game engine and keep a handle for the
game engine.
Parameters:
| Name | Type | Description |
|---|---|---|
gameEngine |
TankGame.GameEngine | The game engine. |
- Source:
Throws:
-
param gameEngine should be instance of TankGame.GameEngine
- Type
- Error
disableDrag()
Disable the drag calculations on the projectile
- Source:
draw()
Draws the projectile
- Source:
enableDrag()
Enable the drag calculations on the projectile
- Source:
explode()
Set the exploding flag to true to start the animation and produces any
projectiles that are spawned from the explosion. These new projectiles
are directly added to the game engine.
- Source:
- See:
isOffScreen() → {Boolean}
Determines if the projectile is off screen or not. Does not return true
if the projectile is above the screen as it might fall back into view.
- Source:
Returns:
if the projectile is on screen
- Type
- Boolean
update(dt)
updates the projectiles position.
Parameters:
| Name | Type | Description |
|---|---|---|
dt |
number | The time difference between the the current frame and the previous frame. |
- Source: