xxxxxxxxxx
38
let player;
let crate;
function setup() {
createCanvas(500, 400);
player = new Sprite(50, 50);
crate = new Sprite(350, height / 2);
brick = new Sprite(width / 2, height / 2, "static");
}
function draw() {
crate.color = 'red'
player.color = 'blue'
background(220);
if (kb.pressing("up")) {
player.vel.y = -4;
} else if (kb.pressing("down")) {
player.vel.y = 4;
} else {
player.vel.y = 0;
}
if (kb.pressing("left")) {
player.vel.x = -4;
} else if (kb.pressing("right")) {
player.vel.x = 4;
} else {
player.vel.x = 0;
}
if (player.colliding(crate)) {
crate.rotation = 0;
crate.rotationSpeed = 0;
player.rotation = 0;
player.rotationSpeed = 0;
}
if (player.colliding(brick)) {
player.rotation = 0;
player.rotationSpeed = 0;
}
}