📄 timer.java
字号:
/**The thread controling the dynamic process of the network
* game
*/
class Timer extends Thread
{
GameFace gameFace;
ColorSet colorSet;
ColorSet next;
Timer(GameFace gameFace)
{
super();
this.gameFace = gameFace;
}
public void run()
{
System.out.println("timer starts");
while(!GamePool.isFull())
{
if(gameFace.gameStart)
{//the bar can't all inside the ground,game is over
while(!GamePool.isFull())
{
if(Queue.isEmpty())
Communication.requestRandomNumber();
while(Queue.isEmpty());
colorSet=Queue.deQueue();
next=Queue.getNext();
gameFace.createBar(colorSet,next);
while(gameFace.bar==null);
// bar drop until it reaches the bottom
gameFace.selfPanel.canvas.requestFocus(true);
while(!gameFace.bar.checkBottom())
{
gameFace.bar.dropOneStep();
gameFace.selfPanel.canvas.repaint();
try
{
this.sleep(200);
}catch(InterruptedException e){}
}
gameFace.selfPanel.canvas.requestFocus();
for(int i=0; i<3; i++)
GamePool.elimination.enQueue(gameFace.bar.squares[i]);
System.out.println("AAAAAAAA");
// try
// {Thread.sleep(1);
// }
// catch(InterruptedException e){}
//
while(!GamePool.eliminate())
try
{
Thread.sleep(200);
}
catch(InterruptedException e){}
GamePool.lock=false;
/*send the whole playing field to other clients*/
Communication.sendPlayingField();
System.out.println("BBBBBBBBBBBBBBBB");
Communication.setScore(gameFace.score);
System.out.println("CCCCCCCCCCCCCCCC");
gameFace.bar=null;
}
// gameFace.gameOver();
}
}
//GameFace.back1.back2.stop();
this.gameFace.gameOver();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -