xxxxxxxxxx
32
class player {
constructor(x, y, w, h) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
update() {
if(keyIsPressed) {
if (keyCode == LEFT_ARROW) {
this.x -= 6;
}
if (keyCode == RIGHT_ARROW) {
this.x += 6;
}
if (keyCode == UP_ARROW) {
this.y -= 6;
}
if (keyCode == DOWN_ARROW) {
this.y += 6;
}
}
}
show() {
rectMode(CENTER);
fill(30, 40, 200);
rect(this.x, this.y, this.w, this.h);
}
}