xxxxxxxxxx
// Credits
// Coin Sound Effect: https://freesound.org/people/cabled_mess/sounds/350873/
//1. create a default sprite named player:
//1a. position it on the left side of the canvas.
// 2. create a circle sprite named coin:
// 2a. set its initial position to the right side of the canvas.
// 2b. set its color to yellow.
// 3. move player towards the mouse position in every frame.
// 4. check if player overlaps with coin:
// 4a. if they overlap, remove the coin from the canvas.
let player, coin;
let coinSound;
function preload() {
coinSound = loadSound("coin.wav");
}
function setup() {
//no gravity necessary :D
new Canvas(400, 400);
player = new Sprite(0, height/2);
coin = new Sprite(width, height/2);
coin.color = "yellow";
coin.d = 20;
coin.stroke = "none";
coinSound.play();
// x = | y = | w = | h = | collider =
// x = | y = | w = | h = | collider =
}
function draw() {
clear();
background("rgb(127,127,255)")
player.moveTowards(mouse, 0.1);
// if (player.overlaps(coin)) {
// coin.remove();
// }
}