Class Game

Handles the game logic.

Hierarchy

  • Game

Constructors

  • Parameters

    • initialscore: number = 0

      Starting score. Defaults to 0.

    Returns Game

Properties

cells: Cell[]
currentPill: Pill = null
futurePill: Pill = null
gameover: boolean = false
glass: Glass
handAnimationFrame: number = 0
highscore: number = 0
pills: Pill[]
score: number = 0
virusCounts: number[] = ...
virusPrevCounts: number[] = ...
viruses: Cell[]
win: boolean = false

Methods

  • Adds a score to the current score and updates highscore if needed

    Parameters

    • score: number

      Score to add

    Returns void

  • Deletes cells that are marked for deletion If a virus is deleted, adds points to the score

    Returns void

  • Checks if a cell would collide with another cell if it was moved by a vector

    Parameters

    • cell: Cell

      Cell to check

    • vector: Vector

      Vector to move the cell by

    • ignoreList: Cell[]

      List of cells to ignore

    Returns boolean

  • Checks if given coordinates collide with a cell

    Parameters

    • x: number

      X position

    • y: number

      Y position

    • ignoreList: Cell[]

      List of cells to ignore

    Returns boolean

  • Speeds up the current pill's gravity

    Returns void

  • searches for a cell at a given position

    Parameters

    • x: number

      X position

    • y: number

      Y position

    • color: CellColor = -1

      Color of the cell to search for (optional)

    Returns Cell

  • moves the current pill left or right if possible

    Parameters

    • direction: boolean

      true for left, false for right

    Returns void

  • Checks if new pill is needed

    Returns boolean

  • Spawns a new pill in Mario's hands

    Returns void

  • rotates the current pill if possible

    Parameters

    • direction: boolean

      true for clockwise, false for counterclockwise

    Returns void

  • Searches for arrays of 4 or more cells of the same color and marks them for deletion

    Returns void

  • For any given cell returns an array of cells of the same color that are connected to it

    Parameters

    • startCell: Cell

      Cell to start the search from

    • vector: Vector

      Vector to search in (e.g. {x: 1, y: 0} will search to the right)

    Returns Cell[]

  • Spawns a virus in a random position

    Parameters

    • color: CellColor = CellColor.Any

      Color of the virus to spawn. Defaults to random.

    Returns void

  • Spawns specified number of viruses in random positions

    Parameters

    • count: number

      Number of viruses to spawn

    Returns void

  • Makes Mario throw the pill into the bottle

    Returns void

  • Update game logic

    Returns void

  • Checks if game is over and if player won

    Returns void

  • Updates the animation of throwing a pill into the bottle and spawns a new pill if needed

    See

    this.prepareFuturePill

    Returns void

  • Basically all the gravity logic for a given pill

    Parameters

    • pill: Pill

      Pill to update

    Returns void

  • Update viruses' sprites

    Returns void

Generated using TypeDoc