So this is a wack a mole game where the red (Villan) is supposed to give you points (this isnt working) I think it somthing to do with the mousex mousey im not sure as it doesnt work when i port it too android but it does work on pc
int score;
float x, y, x1, y1;
float diameterVillan = 125;//diameter of circle
float diameterHero = 125;
int time = 10; // how long it is displayed
int time1= 5;
int lastTime, lastTime1; // When the current circle was first displayed
void setup() {
size(1920,1080);//turn off for android mode
background(255);
textFont( createFont("Arial.vlw", 16) );//font change it
randomGenerator();//calls method
randomGeneratorHero();
lastTime = second();//make last time into secondecound
lastTime1 = second();
}
void draw() {
background(255);
fill(#FC0000);//color of circle
ellipse(x, y, diameterVillan, diameterVillan);//draw the circle
// if time to display the circle is over
if (second() - lastTime >= time){
// create new circle
randomGenerator();
lastTime = second();
}
// print score
if (score < 10) {
text("Score = " + score, 10, 10);
}
else {
text("You Win!!", 10, 10);
}
//hero
fill(#0000FF);//color of circle
ellipse(x1, y1, diameterHero, diameterHero);//draw the circle
// if time to display the circle is over
if (second() - lastTime1 >= time1){
// create new circle
randomGeneratorHero();
lastTime1 = second();
}
/* print score
if (score < 10) {
text("Score = " + score, 10, 10);
}
else {
text("You Win!!", 10, 10);
}*/
}
void mouseClicked() {
if (x - diameterVillan * .5 <= mouseX && mouseX <= x + diameterVillan * .5 &&
y - diameterVillan * .5 <= mouseY && mouseY <= y + diameterVillan * .5) {
score += 1;
// create new circle after mouse is clicked
randomGenerator() ;
lastTime = second();
}
if (x1 - diameterHero * .5 <= mouseX && mouseX <= x1 + diameterHero * .5 &&
y1 - diameterHero * .5 <= mouseY && mouseY <= y1 + diameterHero * .5) {
text("You Lost", 10, 10);
}
}
void randomGenerator() {
// creates new circle
x = random(0 + diameterVillan, width - diameterVillan);
y = random(0 + diameterVillan, height - diameterVillan);
}
void randomGeneratorHero() {
// creates new circle
x1 = random(0 + diameterHero, width - diameterHero);
y1 = random(0 + diameterHero, height - diameterHero);
}