Constructor
new GameEngine(startingMode)
Creates a new instance of GameEngine
Parameters:
| Name | Type | Description |
|---|---|---|
startingMode |
TankGame.Mode | The game mode that the game engine will run at startup |
- Source:
- See:
Methods
addPlayer(player)
Add new player to the game engine
Parameters:
| Name | Type | Description |
|---|---|---|
player |
TankGame.Player | The new player |
- Source:
Throws:
-
param player should be instance of TankGame.Player
- Type
- Error
addProjectile(newProjectile)
Inserts a projectile into the game engine projectile list
Parameters:
| Name | Type | Description |
|---|---|---|
newProjectile |
TankGame.Projectile | an instance of TankGame.Projectile |
- Source:
Throws:
-
param newProjectile should be instance of TankGame.Projectile
- Type
- Error
addTank(terrain)
Add new tank to the game engine.
Parameters:
| Name | Type | Description |
|---|---|---|
terrain |
TankGame.Tank | the ground |
- Source:
Throws:
-
param newTank should be instance of TankGame.Tank
- Type
- Error
addTerrain(terrain)
Add the terrain to the game engine.
Parameters:
| Name | Type | Description |
|---|---|---|
terrain |
TankGame.World.Terrain | the ground |
- Source:
Throws:
-
param terrain should be instance of TankGame.World.Terrain
- Type
- Error
currentPlayer() → {TankGame.Player}
Returns a reference to the current active player
- Source:
Returns:
- The current player
- Type
- TankGame.Player
drawProjectiles()
Draws all the projectiles
- Source:
drawTanks()
Draw the tanks
- Source:
getCurrentWind() → {P5.Vector}
Passes the current global wind vector to the calling function.
- Source:
Returns:
- The wind vector
- Type
- P5.Vector
handleKeyPress()
Handle key press
- Source:
nextPlayer() → {Boolean}
Moves to the next player with a live tank.
- Source:
Returns:
success of operation
- Type
- Boolean
pause()
Pause the game engine updates
- Source:
projectileHitsTank(projectile, tank)
Determines if a projectile hits a tank and applies the correct damage
based on how far away the tank is from the center of the explosion.
Parameters:
| Name | Type | Description |
|---|---|---|
projectile |
TankGame.Projectile | The projectile |
tank |
TankGame.Tank | The tank |
- Source:
projectileHitsTerrain(projectile) → {Boolean}
Calculate if a given projectile hits the ground
Parameters:
| Name | Type | Description |
|---|---|---|
projectile |
TankGame.Projectile | The projectile to test. |
- Source:
Returns:
- If projectile hits the ground
- Type
- Boolean
reset()
reset game engine data
- Source:
setMode(newMode)
Set the mode of the game engine. Will return early and set the mode to
debug empty if the mode is not a valid instance of TankGame.Mode.
Parameters:
| Name | Type | Description |
|---|---|---|
newMode |
TankGame.Mode | the new mode |
- Source:
unpause()
Resume game engine updates
- Source:
update()
Updates the game engine and all of the components. this includes running
a rendering operation after all updates are complete.
- Source:
updateFrameData()
update the current frame data
- Source:
updateProjectiles()
Update the position of all the projectiles and delete them if they are
off screen or collide with the ground
- Source:
updateTanks()
Update the tanks according to the game physics
- Source: