We are about to switch to a new forum software. Until then we have removed the registration on this forum.
int getsec;
int tempmx;
int y=600-50;
int enemyx=(int)(random(600));
int enemyy=(int)(random(600-100));
void setup() {
size(600, 600);
getsec=second();
}
void draw() {
background(255-50);
fill(0);
rect(mouseX, height-50, 25, 25);
int s=second();
//println(getsec-s);
if (getsec-s<=0&&y>=0) {
tempmx=mouseX; //this line
fill(255-100);
y-=5;
rect(tempmx+15/2, y, 15, 15);
}
fill(255);
noStroke();
rect(enemyx, enemyy, 50, 50);
if ((mouseX>=enemyx-50&&mouseX<=enemyx+50)&&(y<=enemyy+25&&y>=enemyy-25)) {
enemyx=(int)(random(600));
enemyy=(int)(random(600-100));
println("да здорово");
}
if (y<=0) {
y=600-50;
}
}
Answers
if (tempmx == 0) tempmx = mouseX;
thanks
Or better still, on line 2 :
int tempmx = -1;
and replaceif(tempmx == 0)
withif(tempmx == -1)
.