diff --git a/.classpath b/.classpath
index d171cd4..c3a725e 100644
--- a/.classpath
+++ b/.classpath
@@ -2,5 +2,6 @@
+
diff --git a/bin/.gitignore b/bin/.gitignore
index eb8cc9c..7e51044 100644
--- a/bin/.gitignore
+++ b/bin/.gitignore
@@ -1,2 +1,3 @@
/controller/
+/view/
/model/
diff --git a/bin/Database.accdb b/bin/Database.accdb
new file mode 100644
index 0000000..68b1df6
Binary files /dev/null and b/bin/Database.accdb differ
diff --git a/bin/controller/EnemyAI.class b/bin/controller/EnemyAI.class
index d0a5e29..fffdd77 100644
Binary files a/bin/controller/EnemyAI.class and b/bin/controller/EnemyAI.class differ
diff --git a/bin/model/Enemy.class b/bin/model/Enemy.class
index 2c790e3..f2bf48e 100644
Binary files a/bin/model/Enemy.class and b/bin/model/Enemy.class differ
diff --git a/bin/model/Event.class b/bin/model/Event.class
index 4ff29fc..1ab7a64 100644
Binary files a/bin/model/Event.class and b/bin/model/Event.class differ
diff --git a/bin/model/Player.class b/bin/model/Player.class
index ec3b947..9323e85 100644
Binary files a/bin/model/Player.class and b/bin/model/Player.class differ
diff --git a/bin/view/MBattleView.class b/bin/view/MBattleView.class
index 2d76973..4a16026 100644
Binary files a/bin/view/MBattleView.class and b/bin/view/MBattleView.class differ
diff --git a/bin/view/MChooseView.class b/bin/view/MChooseView.class
index 45fe0cb..337b2ac 100644
Binary files a/bin/view/MChooseView.class and b/bin/view/MChooseView.class differ
diff --git a/bin/view/MStartView$1.class b/bin/view/MStartView$1.class
index 278b114..8fd123f 100644
Binary files a/bin/view/MStartView$1.class and b/bin/view/MStartView$1.class differ
diff --git a/bin/view/MStartView.class b/bin/view/MStartView.class
index 24c5c63..d1deea0 100644
Binary files a/bin/view/MStartView.class and b/bin/view/MStartView.class differ
diff --git a/src/Database.accdb b/src/Database.accdb
index 64af502..68b1df6 100644
Binary files a/src/Database.accdb and b/src/Database.accdb differ
diff --git a/src/controller/ChoiceListener.java b/src/controller/ChoiceListener.java
new file mode 100644
index 0000000..3f88331
--- /dev/null
+++ b/src/controller/ChoiceListener.java
@@ -0,0 +1,51 @@
+package controller;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.sql.SQLException;
+
+import model.Player;
+import view.ContentPane;
+
+public class ChoiceListener implements ActionListener{
+
+ private int choice;
+ private ContentPane cp;
+
+ public ChoiceListener(int choice,ContentPane cp) {
+ this.setChoice(choice);
+ this.setCp(cp);
+ }
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // TODO Auto-generated method stub
+ StartGame.curEvent.getChoices()[this.choice].changeAttribute();
+ try {
+ StartGame.curEvent=StartGame.curEvent.getChoices()[this.choice].newEvent(StartGame.curEvent.getChoices()[this.choice].getNextID());
+ } catch (SQLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ ContentPane.textLabel.setText(StartGame.curEvent.getDescription());
+ ContentPane.tattr[0].setText(""+Player.hp);
+ ContentPane.tattr[1].setText(""+Player.money);
+ ContentPane.tattr[2].setText(""+Player.food);
+ ContentPane.tattr[3].setText(""+Player.water);
+ if(StartGame.gameOver()) {
+ // TODO
+ }
+ }
+ public int getChoice() {
+ return choice;
+ }
+ public void setChoice(int choice) {
+ this.choice = choice;
+ }
+ public ContentPane getCp() {
+ return cp;
+ }
+ public void setCp(ContentPane cp) {
+ this.cp = cp;
+ }
+
+}
diff --git a/src/controller/Game.java b/src/controller/Game.java
index 11db474..33a1d22 100644
--- a/src/controller/Game.java
+++ b/src/controller/Game.java
@@ -9,7 +9,7 @@
import model.Player;
public class Game {
- /** ܾ*/
+ /** 总距离*/
public static final int DISTANCE=100;
public static Random eRand=new Random();
@@ -25,7 +25,7 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti
if(aEvent==null) {
aEvent=Event.find(eventId);
}
- System.out.println(aEvent.getDescription()+":\nA."+aEvent.getChoices()[0].getDescription()+"\nB."+aEvent.getChoices()[1].getDescription()+"\nC."+aEvent.getChoices()[2].getDescription()+"\nD."+aEvent.getChoices()[3].getDescription()+"\nѡ");
+ System.out.println(aEvent.getDescription()+":\nA."+aEvent.getChoices()[0].getDescription()+"\nB."+aEvent.getChoices()[1].getDescription()+"\nC."+aEvent.getChoices()[2].getDescription()+"\nD."+aEvent.getChoices()[3].getDescription()+"\n请选择:");
Scanner sc=new Scanner(System.in);
String pChoice=sc.nextLine();
Choice curChoice=chooseEvent(pChoice,aEvent);
@@ -36,10 +36,10 @@ public static void main(String[] args) throws ClassNotFoundException, SQLExcepti
}
/**
- * ѡ
- * @param pChoice ѡ
- * @param aEvent ¼
- * @return ѡ
+ * 选择
+ * @param pChoice 选项
+ * @param aEvent 事件
+ * @return 选项
*/
public static Choice chooseEvent(String pChoice, Event aEvent) {
if(pChoice.equals("A")||pChoice.equals("a")) {
@@ -56,8 +56,8 @@ public static Choice chooseEvent(String pChoice, Event aEvent) {
}
/**
- * ϷǷ
- * @return Ƿ
+ * 游戏是否结束
+ * @return 是否
*/
public static boolean gameOver() {
if(Player.food<=0||Player.hp<=0||Player.water<=0||Player.distance>=DISTANCE) {
@@ -68,7 +68,7 @@ public static boolean gameOver() {
}
/**
- * չʾϷ
+ * 展示游戏结果
*/
public static void showResult() {
if((Player.food<=0||Player.hp<=0||Player.water<=0)&&Player.distance=DISTANCE) {
+ showResult();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 展示游戏结果
+ */
+ public static void showResult() {
+ if((Player.food<=0||Player.hp<=0||Player.water<=0)&&Player.distance=0 && Player.hp>=0 && Player.water>=0 && Player.distance>=DISTANCE) {
+ System.out.println("you win");
+ }
}
+ //wzw
}
diff --git a/src/model/Choice.java b/src/model/Choice.java
index ea08730..eeb2b7c 100644
--- a/src/model/Choice.java
+++ b/src/model/Choice.java
@@ -2,40 +2,41 @@
import java.sql.SQLException;
+import controller.StartGame;
+
/**
- * ѡ
- * @author ֮
+ * 选项类
+ * @author 王之威
*
*/
public class Choice {
- /** */
+ /** 描述*/
private String description;
- /** Ǯ*/
+ /** 金钱*/
private int money;
- /** ʳ*/
+ /** 食物*/
private int food;
- /** Ѫ*/
+ /** 血量*/
private int HP;
- /** ˮ*/
+ /** 水*/
private int water;
- /** ĺ*/
+ /** 触发的函数*/
private int whichFun;
- /** һ¼ID*/
+ /** 下一个事件的ID*/
private int nextID;
- /** ƶ*/
+ /** 移动距离*/
private int diatance;
/**
- * ѡ캯
- * @param des ѡ
- * @param money Ǯ
- * @param food ʳ
- * @param HP Ѫ
- * @param water ˮ
- * @param whichFun ѡкĸ
- * @param nextID һ¼ID
+ * 选项构造函数
+ * @param des 选项描述
+ * @param money 金钱
+ * @param food 食物
+ * @param HP 血量
+ * @param water 水
+ * @param nextID 下一个关联事件ID
*/
- public Choice(String des, int diatance,int money ,int food, int HP,int water, int whichFun,int nextID) {
+ public Choice(String des, int diatance,int money ,int food, int HP,int water,int nextID) {
this.setDescription(des);
this.setDiatance(diatance);
this.setMoney(money);
@@ -46,19 +47,22 @@ public Choice(String des, int diatance,int money ,int food, int HP,int water, in
}
/**
- * ضһ¼
+ * 产生特定的下一个事件
* @return
* @throws SQLException
*/
public Event newEvent(int nextID) throws SQLException {
if(nextID!=0) {
return Event.find(nextID);
+ }else {
+ int eventId;
+ eventId=StartGame.eRand.nextInt(4)+1;
+ return Event.find(eventId);
}
- return null;
}
/**
- *
+ * 进入打斗界面
*/
public void fight() {
new Fight(100,200);
@@ -66,7 +70,7 @@ public void fight() {
}
/**
- * ı
+ * 改变玩家属性
*/
public void changeAttribute() {
Player.hp+=this.getHP();
diff --git a/src/model/Event.java b/src/model/Event.java
index 711375a..c852eb4 100644
--- a/src/model/Event.java
+++ b/src/model/Event.java
@@ -3,22 +3,23 @@
import java.sql.SQLException;
/**
- * ¼
- * @author ֮
+ * 事件类
+ * @author 王之威
*
*/
public class Event {
- /** ¼ID*/
+ /** 事件ID*/
private int ID;
- /** ¼*/
+ /** 事件描述*/
private String description;
- /** ѡ*/
+ /** 选项数组*/
private Choice[] choices;
public Event(int id,String description,Choice[] choices) {
this.setID(id);
this.setDescription(description);
this.setChoices(choices);
+ System.out.println("eeee");
}
public static void initialize() throws ClassNotFoundException, SQLException {
diff --git a/src/model/EventDA.java b/src/model/EventDA.java
index 5ea34d1..eb0ab27 100644
--- a/src/model/EventDA.java
+++ b/src/model/EventDA.java
@@ -5,10 +5,11 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.Properties;
/**
- * Eventݷ
- * @author ֮
+ * Event数据访问
+ * @author 王之威
*
*/
public class EventDA {
@@ -16,28 +17,32 @@ public class EventDA {
static Connection aConnection;
static Statement aStatement;
- /** ¼ID*/
+ /** 事件ID*/
static int ID;
- /** ¼*/
+ /** 事件描述*/
static String description;
- /** ѡ*/
+ /** 选项数组*/
static Choice[] choices;
/**
- * ݿ
- * @return
+ * 连接数据库
+ * @return 连接
* @throws ClassNotFoundException
* @throws SQLException
*/
public static Connection initialize() throws ClassNotFoundException, SQLException {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
- aConnection = DriverManager.getConnection("jdbc:odbc:Database", "Database", "database");
+ String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=src\\Database.accdb";
+ //aConnection = DriverManager.getConnection("jdbc:odbc:Database", "Database");
+ Properties p = new Properties();
+ p.put("charSet", "GBK");
+ aConnection = DriverManager.getConnection(url, p);
aStatement = aConnection.createStatement();
return aConnection;
}
/**
- * Ͽݿ
+ * 断开数据库连接
* @throws SQLException
*/
public static void terminate() throws SQLException {
@@ -46,27 +51,27 @@ public static void terminate() throws SQLException {
}
/**
- * ¼
- * @param id ¼id
- * @return ¼
+ * 查找事件
+ * @param id 事件id
+ * @return 事件
* @throws SQLException
*/
public static Event find(int id) throws SQLException {
aEvent=null;
- String sql="SELECT * FROM ¼ WHERE ID="+id;
+ String sql="SELECT * FROM 事件 WHERE ID="+id;
ResultSet rs=aStatement.executeQuery(sql);
boolean gotIt=rs.next();
if(gotIt) {
ID=rs.getInt(1);
description=rs.getString(2);
choices=new Choice[4];
- choices[0]=new Choice(rs.getString(3),rs.getInt(4),rs.getInt(5),rs.getInt(6),rs.getInt(7),rs.getInt(8),rs.getInt(9), rs.getInt(10));
- choices[1]=new Choice(rs.getString(11),rs.getInt(12),rs.getInt(13),rs.getInt(14),rs.getInt(15),rs.getInt(16),rs.getInt(17), rs.getInt(18));
- choices[2]=new Choice(rs.getString(19),rs.getInt(20),rs.getInt(21),rs.getInt(22),rs.getInt(23),rs.getInt(24),rs.getInt(25), rs.getInt(26));
- choices[3]=new Choice(rs.getString(27),rs.getInt(28),rs.getInt(29),rs.getInt(30),rs.getInt(31),rs.getInt(32),rs.getInt(33), rs.getInt(34));
+ choices[0]=new Choice(rs.getString(3),rs.getInt(4),rs.getInt(5),rs.getInt(6),rs.getInt(7),rs.getInt(8), rs.getInt(10));
+ choices[1]=new Choice(rs.getString(11),rs.getInt(12),rs.getInt(13),rs.getInt(14),rs.getInt(15),rs.getInt(16),rs.getInt(18));
+ choices[2]=new Choice(rs.getString(19),rs.getInt(20),rs.getInt(21),rs.getInt(22),rs.getInt(23),rs.getInt(24), rs.getInt(26));
+ choices[3]=new Choice(rs.getString(27),rs.getInt(28),rs.getInt(29),rs.getInt(30),rs.getInt(31),rs.getInt(32),rs.getInt(34));
aEvent=new Event(ID,description,choices);
}
rs.close();
return aEvent;
}
-}
+}
\ No newline at end of file
diff --git a/src/model/Player.java b/src/model/Player.java
index 64d3e6e..ccc7f37 100644
--- a/src/model/Player.java
+++ b/src/model/Player.java
@@ -3,23 +3,23 @@
import java.util.ArrayList;
public class Player {
- /** ֵ*/
+ /** 生命值*/
public static int hp;
- /** ʳ*/
+ /** 食物量*/
public static int food;
- /** ˮ*/
+ /** 水*/
public static int water;
- /** Ǯ*/
+ /** 金钱*/
public static int money;
- /** еľ*/
+ /** 航行的距离*/
public static int distance;
- /** λx*/
+ /** 位置x*/
public static int x;
- /** λy*/
+ /** 位置y*/
public static int y;
- /** */
+ /** 攻击力*/
public static int attack;
- /** Ʒ嵥*/
+ /** 物品清单*/
public static ArrayList buffs;
public Player() {
diff --git a/src/view/ContentPane.java b/src/view/ContentPane.java
new file mode 100644
index 0000000..dabebff
--- /dev/null
+++ b/src/view/ContentPane.java
@@ -0,0 +1,135 @@
+package view;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextArea;
+
+import controller.ChoiceListener;
+import controller.StartGame;
+
+public class ContentPane extends JPanel{
+ public static JButton[] choice=new JButton[4];
+ public static JLabel[] tattr=new JLabel[4];
+ public static JTextArea textLabel;
+
+ public ContentPane() {
+ Font font14=new Font("Monospaced",Font.BOLD,14);//设置字体格式和大小
+ Font font=new Font("Monospaced",Font.BOLD,18);//设置字体格式和大小
+ Font font1=new Font("Monospaced",Font.BOLD,22);//设置字体格式和大小
+ /** 左上角信息区域 */
+ JPanel text=new JPanel();//显示选择区域
+ text.setBackground(new Color(135,206,235));
+ text.setBounds(30, 30, 500, 230);
+ text.setLayout(null);
+ this.add(text);
+ textLabel=new JTextArea(StartGame.curEvent.getDescription());
+ textLabel.setLineWrap(true);
+ textLabel.setFont(new Font("标楷体", Font.BOLD, 16));
+ textLabel.setEditable(false);
+ textLabel.setBackground(new Color(135,206,235));
+ textLabel.setBounds(40, 50, 400, 150);
+ text.add(textLabel);
+
+ JLabel ttextTitle=new JLabel("事件");
+ ttextTitle.setFont(font1);
+ ttextTitle.setBounds(230, 5, 200, 40);
+ text.add(ttextTitle);
+
+ /** 左下角选择区域 */
+ JPanel choiceAera=new JPanel();
+ choiceAera.setBounds(30, 280, 500, 200);
+ choiceAera.setBackground(new Color(135,206,235));
+ this.add(choiceAera);
+ choiceAera.setLayout(null);
+ choice[0] =new JButton(StartGame.curEvent.getChoices()[0].getDescription());
+ choice[0].addActionListener(new ChoiceListener(0,this));
+ choice[0].setBounds(50, 60, 170, 50);
+ choice[0].setFont(font14);
+ choiceAera.add(choice[0]);
+ choice[1]=new JButton(StartGame.curEvent.getChoices()[1].getDescription());
+ choice[1].addActionListener(new ChoiceListener(1,this));
+ choice[1].setBounds(280, 60, 170, 50);
+ choice[1].setFont(font14);
+ choiceAera.add(choice[1]);
+ choice[2] =new JButton(StartGame.curEvent.getChoices()[2].getDescription());
+ choice[2].addActionListener(new ChoiceListener(2,this));
+ choice[2].setBounds(50, 130, 170, 50);
+ choice[2].setFont(font14);
+ choiceAera.add(choice[2]);
+ choice[3] =new JButton(StartGame.curEvent.getChoices()[3].getDescription());
+ choice[3].addActionListener(new ChoiceListener(3,this));
+ choice[3].setBounds(280, 130, 170, 50);
+ choice[3].setFont(font14);
+ choiceAera.add(choice[3]);
+
+ JLabel tchoiceTitle=new JLabel("选择");
+ tchoiceTitle.setFont(font1);
+ tchoiceTitle.setBounds(230, 5, 200, 40);
+ choiceAera.add(tchoiceTitle);
+
+ /** 右上角物品区域 */
+ JPanel itemAera=new JPanel();
+ itemAera.setBounds(580, 30, 250, 230);
+ itemAera.setBackground(new Color(135,206,235));
+ this.add(itemAera);
+ itemAera.setLayout(null);
+
+ JLabel tItemTitle=new JLabel("物品");
+ tItemTitle.setFont(font1);
+ tItemTitle.setBounds(100, 10, 180, 40);
+ itemAera.add(tItemTitle);
+
+
+ /** 右下角属性区域 */
+ JPanel attrAera=new JPanel();
+ attrAera.setBounds(580, 280, 250, 200);
+ attrAera.setBackground(new Color(135,206,235));
+ this.add(attrAera);
+ attrAera.setLayout(null);
+ JLabel tAttrTitle=new JLabel("属性");
+ tAttrTitle.setFont(font1);
+ tAttrTitle.setBounds(100, 10, 180, 40);
+ attrAera.add(tAttrTitle);
+ JLabel tBlood=new JLabel("血量: %");
+ tBlood.setFont(font);
+ tBlood.setBounds(70, 50, 180, 30);
+ attrAera.add(tBlood);
+ tattr[0]=new JLabel("100");
+ tattr[0].setBounds(120, 50, 60, 30);
+ tattr[0].setFont(font);
+ attrAera.add(tattr[0]);
+
+ JLabel tMoney=new JLabel("金钱: G");
+ tMoney.setFont(font);
+ tMoney.setBounds(70, 80, 100, 30);
+ attrAera.add(tMoney);
+ tattr[1]=new JLabel("0");
+ tattr[1].setBounds(120, 80, 60, 30);
+ tattr[1].setFont(font);
+ attrAera.add(tattr[1]);
+
+ JLabel tFood=new JLabel("食物: 包");
+ tFood.setFont(font);
+ tFood.setBounds(70, 110, 100, 30);
+ attrAera.add(tFood);
+ tattr[2]=new JLabel("10");
+ tattr[2].setBounds(120, 110, 60, 30);
+ tattr[2].setFont(font);
+ attrAera.add(tattr[2]);
+
+ JLabel tWater=new JLabel("淡水: 桶");
+ tWater.setFont(font);
+ tWater.setBounds(70, 140, 120, 30);
+ attrAera.add(tWater);
+ tattr[3]=new JLabel("10");
+ tattr[3].setBounds(120, 140, 60, 30);
+ tattr[3].setFont(font);
+ attrAera.add(tattr[3]);
+ }
+
+}
diff --git a/src/view/MBattleView.java b/src/view/MBattleView.java
index 789e773..6068814 100644
--- a/src/view/MBattleView.java
+++ b/src/view/MBattleView.java
@@ -30,6 +30,10 @@ private void battleViewInit() {
initBattleAera(contentPane);
}
private void initBattleAera(JPanel contentPane) {
-
+ JPanel leftAera=new JPanel();
+ leftAera.setBounds(30, 280, 500, 200);
+ leftAera.setBackground(new Color(135,206,235));
+ contentPane.add(leftAera);
+ leftAera.setLayout(null);
}
}
\ No newline at end of file
diff --git a/src/view/MChooseView.java b/src/view/MChooseView.java
index 19ea3f3..965134e 100644
--- a/src/view/MChooseView.java
+++ b/src/view/MChooseView.java
@@ -14,14 +14,15 @@
import javax.swing.JTextArea;
import javax.swing.JTextField;
+import controller.ChoiceListener;
+import controller.StartGame;
+
public class MChooseView extends JFrame{
/** 信息窗口的宽度 */
private static final int INFO_W = 860;
/** 信息窗口的高度 */
private static final int INFO_H = 540;
- public static JButton[] choice=new JButton[4];
- public static JLabel[] tattr=new JLabel[4];
- public static JTextArea textLabel;
+
public MChooseView(String name){
super(name);
chooseViewInit();
@@ -34,122 +35,10 @@ private void chooseViewInit() {
this.setLocation(50, 100);
this.setPreferredSize(new Dimension(INFO_W, INFO_H));
// 添加成员组件
- JPanel contentPane=new JPanel();
+ ContentPane contentPane=new ContentPane();
this.setContentPane(contentPane);
contentPane.setLayout(null);
contentPane.setBackground(new Color(220,220,220));
- initArea(contentPane);
-
- }
- private void initArea(JPanel contentPane) {
- Font font14=new Font("Monospaced",Font.BOLD,14);//设置字体格式和大小
- Font font=new Font("Monospaced",Font.BOLD,18);//设置字体格式和大小
- Font font1=new Font("Monospaced",Font.BOLD,22);//设置字体格式和大小
- /** 左上角信息区域 */
- JPanel text=new JPanel();//显示选择区域
- text.setBackground(new Color(135,206,235));
- text.setBounds(30, 30, 500, 230);
- text.setLayout(null);
- contentPane.add(text);
- textLabel=new JTextArea(" "+"初始选择问题初始选择问题初始选择问题初始选择问题初始选择问题初始选择问题初始选择问题");
- textLabel.setLineWrap(true);
- textLabel.setFont(new Font("标楷体", Font.BOLD, 16));
- textLabel.setEditable(false);
- textLabel.setBackground(new Color(135,206,235));
- textLabel.setBounds(40, 50, 400, 150);
- text.add(textLabel);
-
- JLabel ttextTitle=new JLabel("事件");
- ttextTitle.setFont(font1);
- ttextTitle.setBounds(230, 5, 200, 40);
- text.add(ttextTitle);
-
- /** 左下角选择区域 */
- JPanel choiceAera=new JPanel();
- choiceAera.setBounds(30, 280, 500, 200);
- choiceAera.setBackground(new Color(135,206,235));
- contentPane.add(choiceAera);
- choiceAera.setLayout(null);
- choice[0] =new JButton("选择1");
- choice[0].setBounds(50, 60, 170, 50);
- choice[0].setFont(font14);
- choiceAera.add(choice[0]);
- choice[1]=new JButton("选择2");
- choice[1].setBounds(280, 60, 170, 50);
- choice[1].setFont(font14);
- choiceAera.add(choice[1]);
- choice[2] =new JButton("选择3");
- choice[2].setBounds(50, 130, 170, 50);
- choice[2].setFont(font14);
- choiceAera.add(choice[2]);
- choice[3] =new JButton("选择4");
- choice[3].setBounds(280, 130, 170, 50);
- choice[3].setFont(font14);
- choiceAera.add(choice[3]);
-
- JLabel tchoiceTitle=new JLabel("选择");
- tchoiceTitle.setFont(font1);
- tchoiceTitle.setBounds(230, 5, 200, 40);
- choiceAera.add(tchoiceTitle);
-
- /** 右上角物品区域 */
- JPanel itemAera=new JPanel();
- itemAera.setBounds(580, 30, 250, 230);
- itemAera.setBackground(new Color(135,206,235));
- contentPane.add(itemAera);
- itemAera.setLayout(null);
-
- JLabel tItemTitle=new JLabel("物品");
- tItemTitle.setFont(font1);
- tItemTitle.setBounds(100, 10, 180, 40);
- itemAera.add(tItemTitle);
-
-
- /** 右下角属性区域 */
- JPanel attrAera=new JPanel();
- attrAera.setBounds(580, 280, 250, 200);
- attrAera.setBackground(new Color(135,206,235));
- contentPane.add(attrAera);
- attrAera.setLayout(null);
- JLabel tAttrTitle=new JLabel("属性");
- tAttrTitle.setFont(font1);
- tAttrTitle.setBounds(100, 10, 180, 40);
- attrAera.add(tAttrTitle);
- JLabel tBlood=new JLabel("血量: %");
- tBlood.setFont(font);
- tBlood.setBounds(70, 50, 180, 30);
- attrAera.add(tBlood);
- tattr[0]=new JLabel("100");
- tattr[0].setBounds(120, 50, 60, 30);
- tattr[0].setFont(font);
- attrAera.add(tattr[0]);
-
- JLabel tMoney=new JLabel("金钱: G");
- tMoney.setFont(font);
- tMoney.setBounds(70, 80, 100, 30);
- attrAera.add(tMoney);
- tattr[1]=new JLabel("0");
- tattr[1].setBounds(120, 80, 60, 30);
- tattr[1].setFont(font);
- attrAera.add(tattr[1]);
-
- JLabel tFood=new JLabel("食物: 包");
- tFood.setFont(font);
- tFood.setBounds(70, 110, 100, 30);
- attrAera.add(tFood);
- tattr[2]=new JLabel("10");
- tattr[2].setBounds(120, 110, 60, 30);
- tattr[2].setFont(font);
- attrAera.add(tattr[2]);
-
- JLabel tWater=new JLabel("水 : 瓶");
- tWater.setFont(font);
- tWater.setBounds(70, 140, 120, 30);
- attrAera.add(tWater);
- tattr[3]=new JLabel("10");
- tattr[3].setBounds(120, 140, 60, 30);
- tattr[3].setFont(font);
- attrAera.add(tattr[3]);
}
}
\ No newline at end of file
diff --git a/src/view/MStartView.java b/src/view/MStartView.java
index 73ee4c4..7a7c3b0 100644
--- a/src/view/MStartView.java
+++ b/src/view/MStartView.java
@@ -19,6 +19,7 @@ public class MStartView extends JFrame{
private static final int INFO_W = 960;
/** 信息窗口的高度 */
private static final int INFO_H = 600;
+ public static JLabel start;
public MStartView(String name){
super(name);
startViewInit();
@@ -36,7 +37,7 @@ private void startViewInit() {
contentPane.setLayout(null);
int labelHigh=80;
int labelWidth=100;
- JLabel start=new JLabel("开始");
+ start=new JLabel("开始");
Font font=new Font("Monospaced",Font.BOLD,44);//设置字体格式和大小
start.setFont(font);
start.setBounds((INFO_W-labelWidth)/2, INFO_H/2, labelWidth, labelHigh);