Im really bad at this and Im trying to make a "simulation" of people entering and exiting a room. When the mouseX > width/2 then a "new person comes in" and when mouseX > width/2 then the program should remove a person.
It "works", but it never stops adding/subtracting "people". I don't know how to make it add or subtract only one time for every-time the mouse crosses the canvas.
here's the code:
String comesIn = "In";
String goesOut = "Out";
int n=0;
void setup()
{
size(640, 360);
}
void draw()
{
background(255);
line(320, 0, 320,360 );
if(mouseX > width/2)
{
println("in");
text(comesIn, (width/2)+(width/4), height/2);
fill(50);
n++;
println("people = "+n);
}
if(mouseX < width/2)
{
println("out");
text(goesOut, width/4, height/2);
fill(50);
n--;
println("people = "+n);
}
}
THANK YOUUU
Aucun commentaire:
Enregistrer un commentaire