configuration for steps before delay in engine constructor

This commit is contained in:
Michael Peters 2024-08-03 20:14:33 -07:00
parent 9effbc07b4
commit 769800045f
2 changed files with 4 additions and 3 deletions

View File

@ -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 --------------------------------------------------------------

View File

@ -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;
}