I am having trouble making a happiness meter. So I want to be able to have a timer aka my meter start counting down when I press the s key. Then if the happiness meter gets to low the rock image will change and if it gets super low it will change again. Then I want to be able to press the p key so the happiness of the rock goes up and the image changes to a happy rock. But if you go to high the rock will change images again.
PImage rock;
PImage neutralrock;
PImage likes;
PImage dislikes;
PImage happyrock;
PImage madrock;
PImage exploderock;
PImage deadrock;
int happiness;
int beforeTickle = 0;
int beforeTickleFrames = 5;
int tickleEnd;
boolean gameOver = false;
void setup()
{
frameRate(1);
size(800,600);
dislikes = loadImage("dislikes.png");
likes = loadImage("likes.png");
exploderock = loadImage("exploderock.png");
happyrock = loadImage("happyrock.png");
rock = loadImage("rock.png");
deadrock = loadImage("deadrock.png");
madrock = loadImage("madrock.png");
neutralrock = rock;
happiness = 100;
tickleEnd = millis(); //done for any early pet doAction
noLoop(); //reset by start button doAction
}
void draw()
{
//sun
fill(253,184,19);
noStroke();
ellipse(690,100,175,175);
//grass
fill(136, 204, 51);
rect(0,450,800,200);
fill(196, 136,71);
//tree
rect(64,239,60,250);
fill(210,105,30);
ellipse(100,217,220,220);
ellipse(20,287,180,180);
ellipse(160,287,180,180);
image(neutralrock,400,400,90,90);
if (gameOver)
{
noLoop();
}
println("Happiness level of Rock is ",happiness);
textSize(26);
text(happiness,20,30);
}
void checkRock()
{
if (happiness<60) {
neutralrock = madrock;
gameOver = true;
}
else if (happiness<80) {
neutralrock = deadrock;
}
else if (happiness < 120) {
neutralrock = rock;
}
else if (happiness <150) {
neutralrock = happyrock;
}
else {
neutralrock = exploderock;
gameOver = true;
}
}