diff --git a/src/components/snake/canvas.ts b/src/components/snake/canvas.ts index ff8c117..3ba7001 100644 --- a/src/components/snake/canvas.ts +++ b/src/components/snake/canvas.ts @@ -89,7 +89,7 @@ function shallowCopySGS(state: SnakeGameState): SnakeGameState { return { dead: state.dead, snake: [...state.snake], - apple: state.apple.copy(), + apple: state.apple, }; } @@ -106,7 +106,7 @@ function getSnakeNextSquare(snake: Snake, dir: Vec2) { export default function runCanvas(canvas: HTMLCanvasElement) { const ui = new UI(canvas); const keys = new Keys(); - const engine = new Engine({ updateDelay: 0 }); + const engine = new Engine({ stepsBeforeDelay: 5, updateDelay: 0 }); // game logic -------------------------------------------------------------- diff --git a/src/components/snake/game-engine.ts b/src/components/snake/game-engine.ts index d3f4588..ac78e88 100644 --- a/src/components/snake/game-engine.ts +++ b/src/components/snake/game-engine.ts @@ -191,7 +191,8 @@ export class Engine { stepsBeforeDelay: number = 1; updateDelay: number; - constructor({ updateDelay }: { updateDelay: number }) { + constructor({ stepsBeforeDelay, updateDelay }: { stepsBeforeDelay: number; updateDelay: number }) { + this.stepsBeforeDelay = stepsBeforeDelay; this.updateDelay = updateDelay; }