generated from michael/webpack-base
configuration for steps before delay in engine constructor
This commit is contained in:
parent
9effbc07b4
commit
769800045f
@ -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 --------------------------------------------------------------
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user