⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 day.java

📁 这是一些学生的JAVA课程设计
💻 JAVA
字号:
import java.awt.*;
import java.applet.Applet;
///////////////////////////
public class day extends Applet implements Runnable{
int dlt=1,x,y,r=0,g=0,b=255,cx=1000,cy=400,m=0,d=0;
int mx[]={0,80,120,200,240,300,320,400,460,500,560,660,700,800};
int my[]={300,200,220,140,120,220,180,240,150,160,140,230,210,300};
Thread curtrd,trd;
Image offimg,yu1,yu2;
Graphics offg;
Color clr=new Color(r,g,b);
public void init()
{
x=20;y=280;
offimg=createImage(800,600);
offg=offimg.getGraphics();
yu1=getImage(getCodeBase(),"yu1.gif");
yu2=getImage(getCodeBase(),"yu2.gif");
}

public void start()
{
trd=new Thread(this);

trd.start();


}

public void stop()
{
trd.stop();

}

public void run(){
curtrd=Thread.currentThread();

  while(curtrd==trd)
 {   
    try{ m=m%2;
  if(m==0)
  cy+=3;
  else
  cy-=3;
  m++;
  cx-=5;
  if(dlt==1){
  if(x<200)
   {
    x+=5;y-=5;g+=5;
    if(x>70)
    d=1;
    }
  else if(x<250)
    {x+=5;y-=3;}
  else if(x<300)
    {x+=5;y-=2;}
  else if(x<400)
    {x+=5;y-=1;}
  else if(x<500)
    {x+=5;y+=1;}
  else if(x<550)
    {x+=5;y+=2;}
  else if(x<600)
    {x+=5;y+=3;}
  else if(x<=770)
   {
    x+=5;y+=5;g-=5;
   if(x>700)
    d=0;
   } 
  else{x=30;y=280;r=0;g=0;b=255;dlt=0;}
  }
  else{
  if(x<200)
   {x+=5;y-=5;}
  else if(x<250)
    {x+=5;y-=3;}
  else if(x<300)
    {x+=5;y-=2;}
  else if(x<400)
    {x+=5;y-=1;}
  else if(x<500)
    {x+=5;y+=1;}
  else if(x<550)
    {x+=5;y+=2;}
  else if(x<600)
    {x+=5;y+=3;}
  else if(x<=780)
   {x+=5;y+=5;} 
  else{x=20;y=280;r=0;g=0;b=255;dlt=1;cx=1000;}
  }
  clr=new Color(r,g,b);
   repaint(); 
     trd.sleep(150); 
     }catch(InterruptedException e){}  
  }

}

public void update(Graphics g)
{
 offg.setColor(clr);
 offg.fillRect(0,0,800,600);
 if(dlt==1){
 offg.setColor(Color.red);
 offg.fillOval(x-30,y-30,60,60);
 }
 else{
 offg.setColor(Color.yellow);
 offg.fillOval(x-30,y-30,60,60);
 offg.setColor(clr);
 offg.fillOval(x-50,y-30,60,60);
 }
if(d==0)
{
 offg.setColor(Color.yellow);
 for(int a=0;a<70;a++)
 offg.fillOval((int)(Math.random()*800),(int)(Math.random()*200),1,1);
}
if(m==1)
 offg.drawImage(yu2,cx,cy,100,50,this);
else  
 offg.drawImage(yu1,cx,cy,100,50,this);
 offg.setColor(Color.black);
 offg.fillPolygon(mx,my,14);
 g.drawImage(offimg,0,0,this);
}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -