dont. this isnt finished!! come back when this is finished. anyways use left click or space to attack, right click or B to defend, and use mouse to move your flower.
xxxxxxxxxx
const smoothingFactor = 10;
let keysHeld = "";
let player;
document.addEventListener("contextmenu", function (e){
e.preventDefault();
}, false);
function setup() {
createCanvas(windowWidth, windowHeight);
background(46, 163, 76);
player = new Flower();
player.loadout.PRIMARY = [
new Petal(PETALS["blue"], "common"),
new Petal(PETALS["green"], "common"),
new Petal(PETALS["rose"], "common"),
new Petal(PETALS["yellow"], "common"),
new Petal(PETALS["white"], "common"),
]
}
function draw() {
background(46, 163, 76);
player.render();
player.update();
if (dist(mouseX, mouseY, player.position.x + width / 2, player.position.y + height / 2) > 10)
player.move(atan2(mouseY - player.position.y - height / 2, mouseX - player.position.x - width / 2));
}
function isHeld(_key) {
return keysHeld.includes(_key.toString());
}
function keyPressed() {
if (key.toString().length === 1)
keysHeld += key.toString();
}
function keyReleased() {
keysHeld = keysHeld.replace(key.toString(), "");
}