This commit is contained in:
biglyderv 2024-11-25 14:14:20 -05:00
parent 7fbe113061
commit 8278445e88
4 changed files with 140 additions and 2 deletions

View file

@ -11,6 +11,8 @@ class GameBasic {
this.player = player;
this.entities = entities;
this.width = this.height = 2500;
}
main() {
let { entities } = this;

View file

@ -50,7 +50,7 @@ Player.prototype.bump = function () {
}
Player.prototype.handleTick = function (game) {
let { entities } = game;
let { entities, width, height } = game;
let ent = this;
@ -59,6 +59,9 @@ Player.prototype.handleTick = function (game) {
ent.pos.x += ent.vel.x;
ent.pos.y += ent.vel.y;
ent.pos.x = Math.max(Math.min(ent.pos.x, width / 2), - width / 2);
ent.pos.y = Math.max(Math.min(ent.pos.y, height / 2), - height / 2);
ent.vel.x *= 0.9;
ent.vel.y *= 0.9;