Previous 15 Next

Controls

We want to support different input devices like keyboard on PCs and touch on mobile. Therefore we start by creating an conceptual controller that all the different input devices will map to.

Controller with 4 buttons
4 button controller

The controller has 4 buttons that can be pressed or released.

src/Controller.ts
export interface Controller {
  pressLeft(): void
  releaseLeft(): void

  pressRight(): void
  releaseRight(): void

  pressActionButton1(): void
  releaseActionButton1(): void

  pressActionButton2(): void
  releaseActionButton2(): void
}
Previous 15 Next