how to make tempx=mousex only execute once

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;
  }
}
Tagged:

Answers

Sign In or Register to comment.