bubblepos=new int[3][2];
bubblepos[0][0]=100;
bubblepos[0][1]=450;
bubblepos[1][0]=300;
bubblepos[1][1]=400;
bubblepos[2][0]=500;
bubblepos[2][1]=350;
starttime=System.currentTimeMillis(); //记录游戏开始毫秒数
this.setCursor(new Cursor(Cursor.MOVE_CURSOR));
//设置鼠标形状为移动式
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
/*创建后台图形对象*/
offScreenImage=createImage(640,480);
offScreen=offScreenImage.getGraphics();
if(life<0) //生命值小于0则结束游戏
{
offScreen.setFont(new Font("Dialog",Font.PLAIN,28));
offScreen.setColor(Color.yellow);
offScreen.drawString("得分:"+score,20,20);
offScreen.setFont(new Font("Dialog",Font.PLAIN,60));
offScreen.setColor(Color.red);
offScreen.drawString("游戏结束",200,250);
g.drawImage(offScreenImage,0,0,this);
return;
}
//显示大鲨鱼图形
if(direction==1)
offScreen.drawImage(image0z,mousex,mousey,this);
else
offScreen.drawImage(image0f,mousex,mousey,this);
//显示所有的小鱼图形
if(showfish1==1)
if(fishpos[0][0]%50==0)
offScreen.drawImage(image1z,fishpos[0][0],fishpos[0][1],this);
else
|