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

    Class Canvas

    Manages the game canvas and rendering loop.

    Index

    Constructors

    • Creates a new Canvas manager.

      Parameters

      • canvas: HTMLCanvasElement

        The game canvas element.

      • effectsCanvas: HTMLCanvasElement

        The effects canvas element.

      Returns Canvas

    Properties

    canvas: HTMLCanvasElement

    The main game world HTML canvas element.

    context: CanvasRenderingContext2D

    The 2D rendering context for the main canvas.

    effectsCanvas: HTMLCanvasElement

    The overlay HTML canvas element for temporary visual effects (fog, etc.).

    height: number

    The height of the drawing area in CSS pixels.

    scale: number = 1

    Current zoom/scaling factor applied to the context. Used for window resizing.

    width: number

    The width of the drawing area in CSS pixels.

    Methods

    • Clears all visual effects from the overlay canvas.

      Returns void

    • Clear canvas and draw all objects.

      Parameters

      • game: Game

        The game instance to render.

      Returns void

    • Zoom into the canvas.

      Parameters

      • factor: number

        The scale factor.

      Returns void

    • Update sizes of canvas and map for window.onresize.

      Returns void

    • Shakes the canvas visually using CSS animation.

      Returns void