i only one have ever made a shop and this is what it looked like
//shop
function draw(){
shoppe();
}
function shoppe() {
textSize(12);
fill("yellow");
text("upgrade ship " + ("costs: " + cost), 70, text_y);
text("upgrade attack " + ("costs: " + cost2), 200, text_y);
if (mousePressedOver(shop)) {
speed = 0;
shopb.x = 200;
shopb.y = 200;
exit.y = 300;
enemie.x = 500;
enemie2.x = 500;
enemie3.x = 500;
text_y = 200;
upgrade_y = 150;
}
if (mousePressedOver(exit)) {
speed = speed2;
shopb.x = -600;
shopb.y = -600;
exit.y = -2000;
text_y = -2000;
upgrade_y = -2000;
}
if ((mouseWentDown("leftButton") && mouseIsOver(ship_upgrade)) && coins >= cost) {
ship.nextFrame();
ship_upgrade.nextFrame();
coins = coins - cost;
cost = cost + 5;
ship_level = ship_level + 1;
}
if ((mouseWentDown("leftButton") && mouseIsOver(attack_upgrade)) && coins >= cost2) {
attack.nextFrame();
attack_upgrade.nextFrame();
coins = coins - cost2;
cost2 = cost2 + 5;
attack_level = attack_level + 1;
}
if (ship_level == 1) {
ship.setAnimation("ship1");
ship_speed = 10;
ship_speed2 = -10;
}
if (ship_level == 2) {
ship.setAnimation("ship2");
ship_speed = 11;
ship_speed2 = -11;
}
if (ship_level == 3) {
ship.setAnimation("ship3");
ship_speed = 12;
ship_speed2 = -12;
}
if (ship_level == 4) {
ship.setAnimation("ship4");
ship_speed = 13;
ship_speed2 = -13;
}
if (ship_level == 5) {
ship.setAnimation("ship5");
ship_speed = 14;
ship_speed2 = -14;
}
if (ship_level == 6) {
ship.setAnimation("ship6");
ship_speed = 15;
ship_speed2 = -15;
}
if (ship_level == 7) {
ship.setAnimation("ship7");
ship_speed = 16;
ship_speed2 = -16;
}
if (ship_level == 8) {
ship.setAnimation("ship8");
ship_upgrade.x = -3000;
ship_speed = 17;
ship_speed2 = -17;
}
if (attack_level == 1) {
attack.setFrame(0);
bullet = 5;
}
if (attack_level == 2) {
attack.setFrame(1);
bullet = 6;
}
if (attack_level == 3) {
attack.setFrame(2);
attack_upgrade.x = -3000;
bullet = 7;
}
ship_upgrade.y = upgrade_y;
attack_upgrade.y = upgrade_y;
}
there is probable easier way lol