game: paddle can move

This commit is contained in:
starnakin 2024-01-17 14:47:53 +01:00
parent 2bd0624100
commit 3dc07803eb
2 changed files with 4 additions and 9 deletions

View File

@ -47,23 +47,18 @@ class Game
this.time = new Time(); this.time = new Time();
this.last_pos = null this.last_pos = null
this._inited = false; this._inited = false;
this._wall_drew = false;
return 0; return 0;
} }
draw_sides(ctx) draw_sides(ctx)
{ {
if (this._wall_drew !== true) this.walls.forEach(wall => {
{ wall.draw(ctx);
this.walls.forEach(wall => { });
wall.draw(ctx);
});
}
this.players.forEach(player => { this.players.forEach(player => {
player.draw(ctx); player.draw(ctx);
}); });
this._wall_drew = true;
} }
draw(ctx) draw(ctx)

View File

@ -48,7 +48,7 @@ export default class extends AbstractView
this.my_player.update_paddle(this.keys_pressed); this.my_player.update_paddle(this.keys_pressed);
this.draw(); this.draw();
this.game.time.new_frame(); this.game.time.new_frame();
clearInterval(loop_id); //clearInterval(loop_id);
// 1 sec fps // 1 sec fps
}, 1000 / 60); }, 1000 / 60);
} }