mirror of
https://github.com/sigmasternchen/88x31breakout
synced 2025-03-14 23:49:00 +00:00
feat: Move paddle redraw to tick method
This commit is contained in:
parent
d8d6ba0118
commit
e51307b79b
2 changed files with 3 additions and 3 deletions
|
@ -51,6 +51,8 @@ export class Game {
|
|||
this.handleCollisions(ball);
|
||||
});
|
||||
|
||||
this.paddle.redraw();
|
||||
|
||||
if (this.running) {
|
||||
requestAnimationFrame(this.tick);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ export class Paddle {
|
|||
this.redraw();
|
||||
}
|
||||
|
||||
private readonly redraw = (): void => {
|
||||
public readonly redraw = (): void => {
|
||||
this.element.style.left = this.position + "px";
|
||||
this.element.style.width = this.size + "px";
|
||||
|
||||
|
@ -37,8 +37,6 @@ export class Paddle {
|
|||
Math.min(fieldWidth - this.size / 2,
|
||||
Math.max(this.size / 2, event.offsetX)
|
||||
);
|
||||
|
||||
this.redraw();
|
||||
}
|
||||
|
||||
public readonly setup = (gameElement: HTMLElement, ballLaunchHandler: (ball: Ball) => void): void => {
|
||||
|
|
Loading…
Reference in a new issue