xxxxxxxxxx
37
class Player extends Sprite {
constructor(args) {
super(args);
this.onGround = false;
}
update() {
if (this.onGround) {
super.update();
if (this.y + this.height / 2 < 380) {
this.onGround = false
}
} else {
this.acc.add(0, GRAVITY);
super.update();
if (this.y + this.height / 2 >= 380) {
this.y = 380 - this.height / 2;
this.onGround = true;
this.vel.y *= 0;
}
}
this.acc.mult(0.99)
}
edges() {
if (this.x < 0) {
this.x = width
}
if (this.x > width) {
this.x = 0
}
}
move(dir) {
const { axis, mag } = DIRECTION[dir];
console.log(this.vel[axis]);
this.vel[axis] += mag;
}
}