new PlayScene()
Setting up the default values for the class variables
- Source:
Methods
create()
This method is used to call all the appropriate create methods from all the needed managers and objects
- Source:
handleCollisions()
this method is only called once and will iterate through every pipe inside the pipe manager, and
will assign a collision between the pipe and the bird. This also will assign an overlap event and
callback to the bird and the checkpoint to give the player points
- Source:
handleDeath()
Called whenever the bird collides with the ground or a pipe. This will stop or slow all moving game-objects
to give the illusion of movement. And changes the game state.
- Source:
handleInputDown()
This will check if the spacebar key is currently being pressed down. If true, it will call onSpaceDown()
and will set spaceDown to true, so it won't call onSpaceDown() again until the spacebar has been released.
- Source:
onSpaceDown()
Called whenever the space key is pressed and handles making the bird jump and starting the game
- Source:
onSpaceUp()
Called whenever the space key is released and calls onJumpRelease() from the bird object.
- Source:
preload()
This function is called before anything is drawn on the canvas.
This allows for asset preloading which prevents anything from drawing without
it first loading the asset.
- Source:
restart()
Resetting everything that needs to be reset. Will basically set up everything back to
how they all started to complete the game loop.
- Source:
setupPipeManager(e)
This method will setup the PipeManager object, created in the preloader method, and will set settings for it
based on the difficulty passed with the difficulty parameter passed in.
Parameters:
| Name | Type | Description |
|---|---|---|
e |
Difficulty that's passed from init or sceneloader |
- Source:
startGame()
Starting the game by calling all the start methods needed
- Source:
update(time, delta)
The update method is called every frame and is used here to call all the update methods from all the
managers and objects that need it. It also determines when the game restarts after death and handles
the jumping input checking.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
the time passed in milliseconds since the game started. | |
delta |
the time in-between each frame. |
- Source:
updateVelocity()
This will update the velocity to the velocity class variable for every object that needs to be updated.
- Source: