变换的矩形

public class Flygame extends Canvas implements Runnable {
  
   
    
    
     boolean kaishi=true; 
     private int i=0; 
     int[] bianhuan;                                                                                                                                    
     public Flygame()
     {    
          
        new Thread(this).start();      
        
          
     }
   
   
     public void paint(Graphics g)
     {
      g.setColor(0x00ffffff);
      g.fillRect(0,0,getWidth(),getHeight());
      g.setColor(0x00000000);
      for(int j=0;j<4;j++){
         for(int k=0;k<4;k++){
           
      drawjuxing(g,30+j*20,30+k*20,20);
     
    }}
     
     }
    protected void drawjuxing(Graphics g,int x,int y,int d)
        {
         bianhuan =new int[]{0,15,30,45,60,68,76,84,76,68,60,45,30,15,0,-8,-16,-24,-16,-8};
         
         
         g.drawLine(x+bianhuan[i%20]*d/60,y+bianhuan[(i+15)%20]*d/60,x+bianhuan[(i+5)%20]*d/60,y+bianhuan[i%20]*d/60);
         g.drawLine(x+bianhuan[(i+5)%20]*d/60,y+bianhuan[(i+20)%20]*d/60,x+bianhuan[(i+10)%20]*d/60,y+bianhuan[(i+5)%20]*d/60);
         g.drawLine(x+bianhuan[(i+10)%20]*d/60,y+bianhuan[(i+5)%20]*d/60,x+bianhuan[(i+15)%20]*d/60,y+bianhuan[(i+10)%20]*d/60);
         g.drawLine(x+bianhuan[(i+15)%20]*d/60,y+bianhuan[(i+10)%20]*d/60,x+bianhuan[i%20]*d/60,y+bianhuan[(i+15)%20]*d/60);
         
      }
     
    public void run() {
     
       while(kaishi) {
        try {
          
            repaint();
            Thread.sleep(500);
            i++;
        }catch(InterruptedException e) {}
       
    }
    } 

你可能感兴趣的:(J2ME,thread,class)