CTFTNKS Project Documentation - v1.3.0
    Preparing search index...

    Class Player

    Represents a Player in the game. Keeps the players score, color, name, keymap and the tank to be controlled

    Hierarchy (View Summary)

    Index

    Constructors

    • Creates a new Player.

      Parameters

      • id: number

        The player ID.

      • name: string

        The player name.

      • team: Team

        The team of the player

      • keys: string[]

        The key mapping.

      Returns Player

    Properties

    base?: Base

    The home base of the player's team (if applicable to the game mode).

    game?: Game

    The current game instance this player is associated with.

    id: number

    The player ID.

    keys: string[]

    The key mapping.

    name: string

    The player name.

    score: number = 0

    Cumulative score for the current round.

    spree: number = 0

    Number of kills without dying. Triggers "Killing Spree" sound at certain thresholds.

    stats: { deaths: number; kills: number; miles: number; shots: number } = ...

    Persistent statistics for the player across games.

    team: Team

    The team of the player

    Methods

    • Is the player a bot or a user?

      Returns boolean

    • Kill the player, called when tank is shot.

      Returns void

    • Spawn at some point.

      Parameters

      • game: Game

        the game in which the tank should spawn

      Returns void

    • Steer a tank: check if keys pressed and act accordingly.

      Parameters

      • tank: Tank

        the tank to be steered by the player

      • dt: number

        the time elapsed since the last frame in milliseconds

      Returns void