Java坦克大战设计报告(11)
时间:2025-04-20
时间:2025-04-20
图1-18 单人游戏效果图
双人游戏效果如图1-19所示
图1-19 双人游戏效果图
菜单选择如图1-20所示
图1-20 菜单选择
1.4.9源代码分析
1.开机欢迎界面实现的代码。
public class FirstPanel extends JPanel implements Runnable { public WordMove word = null; FileReader fr = null; BufferedReader br = null; String str="";
Vector<String> aa =null; Image img;
Font f = new Font("华文姚体",Font.BOLD,25); Font f1 = new Font("华文姚体",Font.BOLD,35); Font f2 = new Font("华文彩云",Font.BOLD,150); public FirstPanel() { word = new WordMove(30,340); word.setHH(500); word.b=true;
aa = new Vector<String>(); this.setBackground(Color.black); show(); try { img = ImageIO.read(new File("123.jpg")); } catch (IOException e) {
e.printStackTrace(); }
}
public void paint(Graphics g) { super.paint(g);
g.setColor(Color.yellow); for(int i=0;i<aa.size();i++) { String a = aa.get(i); if(i==0) { g.setFont(f1); }else if(i==24) { g.setFont(f2); }else {
g.setFont(f);
}
g.drawString(a,word.x,word.HH+(i+1)*50); //画出运动的文字 }
}
public void show() { Thread t = new Thread(word);
t.start();