brick.java

来自「新功能坦克大战」· Java 代码 · 共 50 行

JAVA
50
字号
import java.awt.*;import javax.swing.*;import java.io.*;public class Brick extends JFrame {        TankFrame tankFrame;    int num=300;    Wall wall[]=new Wall[num];    int grade;    int x,y;    int c;    int no=0;    Brick(TankFrame tankFrame,int grade) throws Exception{          this.tankFrame=tankFrame;        this.grade=grade;               ShowWall();    }    public void ShowWall() throws Exception{        x=0;        y=40;        FileReader fr=new FileReader(grade+".txt");        while((c=(int)fr.read())!=-1){               if(c==59){                y+=20;                x=0;            }            else if((c-48)==0){                x+=20;            }            else if((c-48==1)){                wall[no]=new Wall(x,y,1,tankFrame);                x+=20;                no++;            }            else if(c-48==2){                wall[no]=new Wall(x,y,2,tankFrame);                x+=20;                no++;            }        }        fr.close();    }    public void paint(Graphics g){        for(int i=0;i<num;i++){            if(wall[i]!=null)                wall[i].draw(g);        }    }}

⌨️ 快捷键说明

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