xxxxxxxxxx
73
let timer;
let timerOver=false;
let state = "Preparing:"
let total=0
let bg;
let played=false
// let state = "Creating"
function preload(){
// soundFormats('mp3');
mySound = loadSound('bell.mp3');
tap1 = loadSound('tap1.mp3');
tap2 = loadSound('tap2.mp3');
}
function setup() {
createCanvas(windowWidth, windowHeight*1.3);
textFont("Courier")
textAlign(CENTER)
textSize(windowWidth/14)
colorMode(RGB)
// bg = color(167, 230, 176)
timer = 1000 * 6
}
function draw() {
if(state == "Preparing:"){
background(183, 235, 190);
} else{
background(239, 165, 154)
}
timer -= deltaTime
textAlign(CENTER)
text("Games Finished: " + total + "/100",width/2,100)
textAlign(CENTER)
text(state + "\n" + nfc(timer/1000,0) ,width/2,height/2)
if(timer < 0 && !played ){
played = true
mySound.play();
}
}
function touchStarted(){
played = false
print("click")
timer = 60000
if(state == "Preparing:"){
tap1.play()
state = "Creating:"
} else {
tap2.play()
total++
state = "Preparing:"
}
}