To start the game, we must call the game
function with the default state, draw function, time handler, and event handler. In lib/game/index.ts
, we write the following code to start the game:
import { game } from "../framework/game"; import { defaultState } from "./model"; import { draw } from "./view"; import { step } from "./step"; import { eventHandler } from "./event"; const canvas = <HTMLCanvasElement> document.getElementById("game"); game(canvas, document.body, 60, defaultState, draw, step, eventHandler);
We can compile the game by executing gulp
. You can play the game by opening static/index.html
.
As you will see, nothing happens when you have eaten all of the dots, or when you get hit by an enemy. In the next section, we will implement a menu. When the player wins or loses, we will show this menu.