my set key values not working right now is it cdo or is it a really bad design?
`
var username = prompt("enter a username (type nothing and click ok to become guest)");
var clicks = 0;
var click_power = 1;
var mouse_owned = 0;
var mmouse_owned = 0;
var mouse_give = 10;
var mouse_price = 0;
var mmouse_give = 50;
var mmouse_price = 0;
var sprite = createSprite(200, 250);
sprite.setAnimation("retro_coin_1");
var mouse_buy = createSprite(100, 50);
var pic1 = createSprite(100, 50);
pic1.setAnimation("mouse");
pic1.scale = 0.1;
mouse_buy.scale = 0.5;
var mmouse_buy = createSprite(200, 50);
var pic2 = createSprite(200, 50);
pic2.setAnimation("mega mouse ");
pic2.scale = 0.1;
mmouse_buy.scale = 0.5;
var upgrades = createSprite(300, 50);
var pic3 = createSprite(300, 50);
pic3.setAnimation("retro_powerup_coin_2");
pic3.scale = 0.1;
upgrades.scale = 0.5;
getKeyValue(encodeURIComponent(getUserId())+ "click",function(click){
if(click == undefined){
setKeyValue(encodeURIComponent(getUserId())+ "click",0);
} else {
clicks = click;
}
} );
getKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",function(mouse_prices){
if(mouse_prices == undefined){
setKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",50);
} else {
mouse_price = mouse_prices;
}
} );
getKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",function(mmouse_prices){
if(mmouse_prices == undefined){
setKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",200);
} else {
mmouse_price = mmouse_prices;
}
} );
function draw() {
getKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",function(mouse_prices){
setKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",mouse_price);
} );
getKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",function(mmouse_prices){
setKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",mmouse_price);
} );
background("white");
drawSprites();
sprite.rotationSpeed = 1;
if (mouseIsOver(sprite)) {
sprite.scale = 1.2;
sprite.rotationSpeed = 2;
} else {
sprite.scale = 1;
}
if (mouseIsOver(sprite) && mouseWentDown("leftButton")) {
clicks = clicks + click_power;
sprite.scale = 1.1;
}
if ((mouseIsOver(mouse_buy) && mouseWentDown("leftButton")) && clicks >= mouse_price) {
mouse_owned = mouse_owned + 1;
clicks = clicks - mouse_price;
mouse_price = mouse_price + 10;
}
if ((mouseIsOver(mmouse_buy) && mouseWentDown("leftButton")) && clicks >= mmouse_price) {
mmouse_owned = mmouse_owned + 1;
clicks = clicks - mmouse_price;
mmouse_price = mmouse_price + 15;
}
getKeyValue(encodeURIComponent(getUserId())+ "click",function(click){
setKeyValue(encodeURIComponent(getUserId())+ "click",clicks);
} );
textSize(24);
text("clicks: " + clicks, 0, 20);
textSize(12);
text("mouse price: " + mouse_price, 50, 100);
text("mega mouse price: " + mmouse_price, 175, 100);
if (username == "") {
username = "guest" + getUserId();
}
if (username == "guest" + getUserId()) {
username = "guest" + getUserId();
}
textSize(16);
text("name: " + username, 0, 380);
if (keyWentDown("space")) {
getKeyValue(encodeURIComponent(getUserId())+ "click",function(click){
setKeyValue(encodeURIComponent(getUserId())+ "click",clicks);
} );
getKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",function(mouse_prices){
setKeyValue(encodeURIComponent(getUserId())+ "mouse_prices",mouse_price);
} );
getKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",function(mmouse_prices){
setKeyValue(encodeURIComponent(getUserId())+ "mmouse_prices",mmouse_price);
} );
text("saved", 0, 15);
}
}
console.log("hello " + username);
setInterval(function() {
if (mouse_owned >= 1) {
clicks = clicks + (mouse_give * mouse_owned);
}
}, 1000);
setInterval(function() {
if (mmouse_owned >= 1) {
clicks = clicks + (mmouse_give * mmouse_owned);
}
}, 500);
//this bit of code is not mine however i just thought it was incredible and had to use it
getKeyValue("users", function(users) {
if (getUserId() != "6gyH2ySbwXyDiizitaYptGVs7hU") {
if(users == undefined){
setKeyValue("users", 0);
} else {
setKeyValue("users", users + 1);
}
}
});
getKeyValue("users", function(users){
console.log(("mega clicker has " + users) + " views");
});`