JAVA课程设计——团队博客 - Go语言中文社区

JAVA课程设计——团队博客


JAVA课程设计——团队博客


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

团队名称:“小羊吃蓝莓”小游戏
团队成员介绍:
成员 班级 学号
廖怡洁 网络1513 201521123067
黄晓杨 网络1513 201521123071

2. 项目git地址

https://git.oschina.net/yjliao/javakechengsheji.git

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

1109951-20170622005951632-1302872817.png

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

项目功能架构图

1109951-20170621213358741-981702030.png

主要功能流程图

1109951-20170621214643991-573595566.png

5. 项目运行截图

5.1 游戏主界面

1109951-20170621182951163-1959262777.png

5.2 游戏规则界面

1109951-20170621183009460-563995407.png

5.3 游戏历史记录界面

1109951-20170621183210257-152895176.png

5.4 游戏运行界面

1109951-20170621183221085-627269314.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<Coordinate> 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<Coordinate> 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. 团队成员任务分配,团队成员课程设计博客链接(以表格形式呈现),标明组长。

成员 任务分配 博客链接
廖怡洁(组长) 游戏算法编程 链接地址
黄晓杨 游戏界面设计 链接地址

转载于:https://www.cnblogs.com/HXY071/p/7061216.html

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/weixin_30369087/article/details/96889345
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-02-13 13:17:24
  • 阅读 ( 990 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢