Курсовая работа: Разработка приложения на Java
if(right){ x[0]+=10; }
if(up){ y[0]-=10; }
if(down){ y[0]+=10; }
}
if(y[0]>191){y[0]=191;game=3;}
if(y[0]<1){y[0]=1;game=3;}
if(x[0]>191){x[0]=191;game=3;}
if(x[0]<1){x[0]=1;game=3;}
if (game==3)
{
if (count <(1500/level)) { count++; } else { count=0;game=1;repaint();setTime.stop(); }
}
repaint();
try{setTime.sleep(level);}
catch(InterruptedException e){}
}
}
public void locateRandom(int turn)
{
rtemp=(int)(Math.random()*20);
x[turn]=((rtemp*10)+1) ;
rtemp=(int)(Math.random()*20);
y[turn]=((rtemp*10)+1);
n++;
}
public boolean keyDown(Event e, int key)
{
if ((key == Event.LEFT) &&(!right)){left = true; up = false; down = false;if(!started)started=true;}
if ((key == Event.RIGHT) && (!left)){right = true; up = false; down = false;if(!started)started=true;}