Player

ClubCrawler.Objects. Player

A class for representing the Player in the game world.

Constructor

new Player(config)

Source:
See:

Constructs the player, gives it a physics body, selects a random Discord avatar to use as the image.

Parameters:
Name Type Description
config Object

The configuration object

Properties
Name Type Attributes Default Description
scene Phaser.Scene

The Phaser.Scene creating the Player

x number

The x location to place the player initially. If the map has a player spawn, this won't matter.

y number

The y location to place the player initially. If the map has a player spawn, this won't matter.

velocityIncrement number <optional>
25

The amount the player speed increases when a directional button is pressed

drag number <optional>
100

The amount to slow the player down when no directional is pressed

Extends

  • Phaser.GameObjects.Image

Methods

(static) preload()

Source:

Preloads assets needed for player. Currently only looks to 'images/discord-avatars.png' and 'atlas/discord-avatars.json' for player image data. Picks a random avatar from the Phaser.Scene each time the game is run.

See Phaser docs for more info about atlases.

Parameters:
Name Type Description
config.scene Phaser.Scene

The Phaser.Scene doing the pre-loading.

die()

Source:
To Do:
  • Set up a death animation, event handling

Player death. Currently immediately stops the scene and starts gameover. Should instead unhook controls and fire a player death event.

Fires:

move(direction)

Source:

Applies velocity to the player, such as in response to keyboard input

Parameters:
Name Type Description
direction string

One of "e","w","s","n"