December 2016
Intermediate to advanced
841 pages
17h
English
The time handler requires some more work. First, we import other types and functions.
import { State, Level, Object, Enemy, Wall, Movement, isOppositeMovement, onGrid, Difficulty } from "./model";
import { update, randomInt, chance, distance, isInt } from "./utils";
We define a step function so that we can add the menu later on.
export function step(state: State) {
return stepLevel(state);
}
In stepLevel, we can update the objects in the level. First, we update the location of the enemies. We use stepEnemy, which we define later on.
function stepLevel(state: State): State {
const level = state.level;
const enemies = level.enemies.map(enemy => stepEnemy(enemy, level.player, level.walls, level.difficulty));
We update the location ...
Read now
Unlock full access