xxxxxxxxxx
77
//by osminee (c)
let i;
let scene = 0;
let tree;
let scam;
let score = 0;
let upgrade_cost = 100;
let mult = 1;
let rebirth = 0;
let reb_cost = 10000;
let reb_mult = 1;
function preload() {
tree = loadImage('moneytree.png');
scam = loadImage('scam.png');
}
let mainScene = function() {
fill('#ebe5da');
rect(400, 320, 500, 350);
rect(400, 360, 500, 390);
textSize(14);
fill('#000');
text('Upgrade', 423, 340);
text('Invert Score', 413, 380);
fill('#000');
textSize(30);
text('Score: '+score+' Rebirths: '+rebirth, 40, 40);
image(tree, 390, 190);
image(scam, 840, 20);
}
function setup() {
createCanvas(1000, 500);
noStroke();
rectMode(CORNERS);
}
function draw() {
background('#ded3bd');
if (scene === 0) {
mainScene();
}
}
function keyPressed() {
if (keyCode === 32) {
score -= mult*reb_mult;
}
}
function mouseClicked() {
if (mouseX>=400 && mouseX<=500 && mouseY>=320 && mouseY<=350) {
if (score>=upgrade_cost) {
score -= upgrade_cost;
mult *= 2;
upgrade_cost *=2;
}
} else if (mouseX>=400 && mouseX<=500 && mouseY>=360 && mouseY<=390) {
if (score<0) {
score = abs(score);
score = round(score * 90 / 100);
} else {
score = -(score);
score = round(score * 90 / 100);
}} else if (mouseX>=840 && mouseX<=1000 && mouseY>=20 && mouseY<=140) {
if (score>=reb_cost) {
score = 0;
mult = 1;
upgrade_cost = 100;
rebirth += 1;
reb_cost *= 2;
reb_mult += 1;
}
}
}