zoukankan      html  css  js  c++  java
  • Java课程设计贪吃蛇大作战

    目录

    一、团队课程设计博客链接

    二、个人负责模块和任务说明

    三、自己的代码提交记录截图

    四、自己负责模块或任务详细说明

    五、课程设计感想


    一、团队课程设计博客链接

         https://www.cnblogs.com/pikaaaqiu/p/12171064.html

    二、个人负责模块和任务说明

        1.负责实现闯关模式

        2.负责实现挑战模式

        3.串联GUI与信息代码
        4.实现排行榜功能

    三、自己的代码提交记录截图

    四、自己负责模块或任务详细说明

    这是挑战模式的时间线程

    this.thread = new Thread(() -> {
                while (start) {
                    if (count == 0)
                    {
                        break;
                    }
                    if (!pause) {
                        count--;
                        initText();
                    }
                    try {
                        Thread.sleep(SECOND);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                count = 0;
            });

    游戏面板的重绘方法覆写

    public void paint(Graphics g) {
       clearDraw(g);
    if(ground != null&&snake!=null&&food!=null) {
    ground.drawMe(g);
    food.drawMe(g);
    snake.drawMe(g);
    }
    if(snake!=null&& !snake.isLife()) {
    recover(g);
    }
    }

    启动游戏

    public void newGame() {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ignored) {
    
            }
            ground.clear();
            ground.generateRocks();
            food.newFood(ground.getPoint());
            buttonPanel.getMapLevLabel().setText("");
            buttonPanel.getMapLevLabel().setText(""+ground.getMapType());
            snake.setSleepTime(100);
            buttonPanel.setScore(0);
            buttonPanel.repaint();
    }

    游戏结束核算成绩的弹窗

     public void calculate() {
            String s ="您的成绩为:最终关卡:"+ground.getMapType()+"	 最终得分"+snake.getFoodCount();
            SkipFrame2 skipFrame = new SkipFrame2();
            skipFrame.getLabel().setBounds(100,50,600,40);
            int flag=information.compare1(ground.getMapType(), snake.getFoodCount());
            skipFrame.getLabel().setText(s);
            if(flag>0) {
                skipFrame.successful();
                skipFrame.visible();
                skipFrame.getButton().addActionListener(e -> {
    
                    String name=skipFrame.getNameText().getText();
                    skipFrame.shutdown();
                    information.addList1(flag, name, ground.getMapType(), snake.getFoodCount());
                });
            }else {
                skipFrame.visible();
                skipFrame.getButton().addActionListener(e -> skipFrame.shutdown());
            }
        }

     

     五、课程设计感想

      经过这次的课程设计,让我对多线程以及面向对象编程有了更加深刻的理解,并且感受到了团队合作的重要性,Java通常是要团队分工进行的,所以一些命名的规范,接口之类的就变得非常重要了,此次课程设计也让我对java编程有了更深一层的掌握,并且对游戏的创作有了一点了解。

  • 相关阅读:
    Kth element of Two Sorted Arrays
    Populating Next Right Pointers in Each Node I && II
    Average waiting time of SJF and Round Robin scheduling
    LRU Cache
    Calculate H-index
    Get Level of a node in a Binary Tree
    Two Sum
    Intersection of Two Linked Lists
    Symmetric Tree
    Lowest Common Ancestor of Binary (Search) Tree
  • 原文地址:https://www.cnblogs.com/crc01/p/12169274.html
Copyright © 2011-2022 走看看