วันพุธที่ 26 สิงหาคม พ.ศ. 2558

Point the box 10 second countdown

int point=0;
int timelimit=11000;
int enable=1;
int boX=300,boY=300;
int previousM=0;
int m; //millisecond
void setup(){
  size(500,500);
  background(0);
  rectMode(CENTER);
  textSize(30);
}


void draw(){
  background(0);


if (enable==1){
  m=millis()-previousM;
  rect(boX,boY,30,30);
  text("Point : "+point,10,30); //show point
   if (mouseX<=boX+15 && mouseX>=boX-15 && mouseY>=boY-15 && mouseY<=boY+15){
     point+=1;
     boX=int(random(width-50));
     boY=int(random(30,height-50));
   }
   text("TIME : "+(timelimit-m)/1000,width-150,30); //SHOW TIME LIMIT
   if (timelimit-m<0){
       enable=0;
       timelimit=11000;
       previousM = millis();
    }

}
else if (enable==0)
{
   text("YOUR POINT IS : "+point,width/2-150,height/2+50);
  text("PRESS R TO RESTART",width/2-150,height/2);
  if (keyPressed && (key=='r' || key=='R')){
    enable=1;
    point=0;

  }
}
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...