Obstacle of the game. Built from 2 pipes, one at the bottom, one at the top.

Hierarchy

Implements

Constructors

  • Constructs the Obstacle with the given image.

    Parameters

    • position: Position

      starting position of the obstacle

    • obstacleWidth: number

      width of the obstacle

    • obstacleHeight: number

      height of the obstacle

    • pipeImagePath: string

      path to the image to be used

    Returns Obstacle

Properties

padding: number = 150
pipeBottom: Pipe
pipeTop: Pipe
speed: number = 3
_distanceBetweenPipes: number
_startX: number

Accessors

  • get height(): number
  • Get height.

    Returns number

  • set height(value: number): void
  • Set height.

    Parameters

    • value: number

    Returns void

  • get showHitbox(): boolean
  • Get the hitbox's visibility.

    Returns boolean

  • set showHitbox(value: boolean): void
  • Set the hitbox's visibility.

    Parameters

    • value: boolean

    Returns void

  • get width(): number
  • Get width.

    Returns number

  • set width(value: number): void
  • Set width.

    Parameters

    • value: number

    Returns void

  • set distanceBetweenPipes(value: number): void
  • Parameters

    • value: number

    Returns void

  • set startX(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Private

    Creates the pipes.

    Parameters

    • position: Position
    • obstacleHeight: number
    • obstacleWidth: number
    • pipeImagePath: string

    Returns void

  • Creates a random number between the min and max parameter

    Parameters

    • min: number

      minimum number

    • max: number

      maximum number

    Returns number

  • Randomizes the height of the pipes

    Returns void

  • Resets the position of the obstacle to the Obstacle.startX variable Randomises the height of the pipes using the padding variable

    Returns void

Generated using TypeDoc