java设计博客_JAVA课程设计——团队博客

JAVA课程设计——团队博客

1. 团队名称、团队成员介绍(需要有照片)

团队名称:“小羊吃蓝莓”小游戏

团队成员介绍:

成员

班级

学号

廖怡洁

网络1513

201521123067

黄晓杨

网络1513

201521123071

2. 项目git地址

3. 项目git提交记录截图(要体现出每个人的提交记录、提交说明),老师将点击进去重点考核。

e579cc6c8d44e7d2cc3884ff7ef567bd.png

4. 项目功能架构图与主要功能流程图

项目功能架构图

488f403c190e9d267f3f49f4c33fc0e7.png

主要功能流程图

165f756ed14f70d316f91abdb654b8a1.png

5. 项目运行截图

5.1 游戏主界面

98aec9ed7ffc49a265ae00d106c1408c.png

5.2 游戏规则界面

34660222f4a38bc555422390bcd6ec02.png

5.3 游戏历史记录界面

8a59b00a7730803e9c8fbf96909cbfa4.png

5.4 游戏运行界面

c23fae08023975aa2b9ab5d985099d0f.png

6. 项目关键代码(不能太多)

public void actionPerformed(ActionEvent e) {

if(e.getSource() == exit){

System.exit(0); //退出的监听事件

}

if(e.getSource() == begin){

SheepFrame s=new SheepFrame();//点“开始”后,出现一个新界面,作为游戏界面

s.setFrame();

}

if(e.getSource() == record){

TxtFrame t = new TxtFrame();

}

if(e.getSource() == rule){

RuleFrame r = new RuleFrame(); //点击“规则”后,出现一个新界面

r.setFrame();

}

}

class TxtFrame extends JFrame {

TextArea text = new TextArea();

public TxtFrame() {

super("历史记录");

add(text);

readFile();

}

public void readFile() {

try {

File file = new File(fileName);

FileReader readIn = new FileReader(file);

char[] content = readIn.read();

readIn.close();

text.setText(new String(content));

}

catch (IOException e) {

System.out.println("Error Opening file");

}

}

}

public void init() {

for (int i = 0; i < 3; i++) {

int x = rand.nextInt(30) + 2;//随机产生横坐标

int y = rand.nextInt(30) + 2;//随机产生纵坐标

if (i == 0) {

this.food1 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

} else if (i == 1) {

this.food2 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

} else {

this.food3 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

}

}

}

public int calculateScore() {// 计算分数并将分数存进文件

if (count < 10) score += 10;

else if (count < 20) score += 15;

else score += 20;

try {

FileWriter fw=new FileWriter(filepath,true);

PrintWriter pw=new PrintWriter(fw);

pw.println(score);

} catch (IOException e) {

e.printStackTrace();

}

return score;

}

public void ChangeLevel(int num) { // 改变等级

level = num / 100;

if (oldlevel != level) {

speed -= (level * 5);

oldlevel = level;

}

}

public void moveAll(){ // 移动整只小羊

Iterator Sheep = all.iterator();

int step = sheep.nextstep;

while (Sheep.hasNext()) {

Coordinate newsheep = Sheep.next();

switch (newsheep.nextstep) {

case SheepFrame.S_UP: newsheep.y -= 20; break;

case SheepFrame.S_DOWN: newsheep.y += 20; break;

case SheepFrame.S_LEFT: newsheep.x -= 20; break;

case SheepFrame.S_RIGHT: newsheep.x += 20; break;

}

tmp = newsheep.nextstep;

newsheep.nextstep = step;

step = tmp;

}

}

public boolean checkEatFood(Coordinate node) { // 判断是否吃到食物

if ((node.x == food1.x) && (node.y == food1.y)) {

int x = rand.nextInt(30) + 2;

int y = rand.nextInt(30) + 2;

this.food1 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

count++;

return true;

}

if ((node.x == food2.x) && (node.y == food2.y)) {

int x = rand.nextInt(30) + 2;

int y = rand.nextInt(30) + 2;

this.food2 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

count++;

return true;

}

if ((node.x == food3.x) && (node.y == food3.y)) {

int x = rand.nextInt(30) + 2;

int y = rand.nextInt(30) + 2;

this.food3 = new Coordinate(x * 20, y * 20, SheepFrame.S_STOP);

count++;

return true;

}

return false;

}

public boolean checkEatBody(Coordinate head) {//判断是否咬到自己

Iterator Sheep = all.iterator();

while (Sheep.hasNext()) {

Coordinate newsheep = Sheep.next();

if (head.x == newsheep.x && head.y == newsheep.y)

return true;

}

return false;

}

public boolean checkGround(Coordinate head) {//判断是否撞墙

for (int x = 0; x < 35; x++)

if (head.x == x * 20 && (head.y == 0 || head.y == 34 * 20))

return true;

for (int y = 0; y < 35; y++)

if ((head.x == 0 || head.x == 35 * 20) && head.y == y * 20)

return true;

return false;

}

7. 尚待改进或者新的想法

我们感觉整个游戏的完整度还是挺高的,改进的话我们会考虑增加一个排行榜的功能,使玩家可以方便快捷地看到最佳记录和最差分数,并且使界面以及小羊和蓝莓的形象更加精致些。

8. 团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长。

成员

任务分配

博客链接

廖怡洁(组长)

游戏算法编程

黄晓杨

游戏界面设计

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值