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

    Represents a Tank controlled by a player.

    Receives a player in its constructor contains position, angle, speed of the tank and provides methods to move it contains methods for collision detection with walls and bullets contains a weapon and a method to shoot it

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    age: number = 0

    time (in milliseconds) for how long the object already exists in the game

    angle: number = ...

    Current rotation in radians. 0 is pointing up.

    carriedFlag: Flag | null = null

    Reference to a Flag entity if the tank is currently carrying one.

    color: string

    Hex color code or CSS color name for the tank body.

    game: Game

    The game instance.

    height: number = Settings.TankHeight

    Dimensional height in world pixels.

    invincibleDuration: number = 0

    Remaining time (ms) of invincibility. If > 0, tank is immune to bullets.

    maxAge?: number

    optional duration in milliseconds for how long the object should still exist in the game

    player: Player

    The player owning this tank.

    rapidfire: boolean = false

    If true, weapon cooldowns are significantly reduced.

    speed: number = Settings.TankSpeed

    Base movement speed in pixels per second. Can be modified by power-ups.

    tile?: Tile
    weapon: Weapon

    The currently equipped weapon logic.

    weapons: Weapon[] = []

    Optional inventory for future multi-weapon support.

    width: number = Settings.TankWidth

    Dimensional width in world pixels. Affects hitboxes.

    x: number = 0
    y: number = 0

    Methods

    • Get x,y-coordinates of the tanks corners. Needed for collision detection and weapon firing.

      Returns { x: number; y: number }[]

      List of corners {x, y}.

    • Draws the tank (rotated) on map.

      Parameters

      • context: CanvasRenderingContext2D

        The context.

      Returns void

    • Properties: is invincible?

      Returns boolean

      True if invincible.

    • Move the tank forward/backwards.

      Parameters

      • direction: number

        1 for forward, -1 for backward.

      • dt: number

        The time elapsed since the last frame in milliseconds.

      Returns void

    • Use the weapon.

      Parameters

      • dt: number

        The time elapsed since the last frame in milliseconds.

      Returns void

    • Is the spawnshield active?

      Returns boolean

      True if spawnshield active.

    • Let player class check for key presses and move tank. Check for collisions and handle them.

      Parameters

      • dt: number

        The time elapsed since the last frame in milliseconds.

      Returns void

    • Rotate the tank.

      Parameters

      • direction: number

        1 for right, -1 for left.

      • dt: number

        The time elapsed since the last frame in milliseconds.

      Returns void