• 回答数

    6

  • 浏览数

    147

岁月若如世
首页 > 毕业论文 > java贪吃蛇代码步骤毕业论文

6个回答 默认排序
  • 默认排序
  • 按时间排序

Nicole20041414

已采纳

这种小游戏,小程序你可以到蛙课网上去看看,我一直在这个网站上学习。

254 评论

幸福航海家

给邮箱我发给你,几百行。

179 评论

燃烧吧猪五花

主要用了这个类:import .*;import .*;@SuppressWarnings("serial")public class MainClass extends JFrame {ControlSnake control;Toolkit kit;Dimension dimen;public static void main(String[] args) {new MainClass("my snake");}public MainClass(String s) {super(s);control = new ControlSnake();(true);kit = ();dimen = ();add(control);setLayout(new BorderLayout());setLocation( / 3, / 3);// (FWIDTH, FHEIGHT);setDefaultCloseOperation();setResizable(false);setVisible(true);}public static final int FWIDTH = 315;public static final int FHEIGHT = 380;}import .*;import .*;import .*;import .*;import ;import ;@SuppressWarnings("serial")public class ControlSnake extends JPanel implements ActionListener {Random rand;ArrayList list, listBody;String str, str1;static boolean key;int x, y, dx, dy, fx, fy, flag;int snakeBody;int speed;public ControlSnake() {snakeBody = 1;str = "上下左右方向键控制 P键暂停...";str1 = "现在的长度为:" + snakeBody;key = true;flag = 1;speed = 700;rand = new Random();list = new ArrayList();listBody = new ArrayList();x = 5;y = 5;(new Point(x, y));((0));dx = 10;dy = 0;fx = (30) * 10 + 5;// 2fy = (30) * 10 + 5;// 2setBackground();setSize(new Dimension(318, 380));final Timer time = new Timer(speed, this);();addKeyListener(new KeyAdapter() {public void keyPressed(KeyEvent e) {if (() == 37) {dx = -10;dy = 0;} else if (() == 38) {dx = 0;dy = -10;} else if (() == 39) {dx = 10;dy = 0;} else if (() == 40) {dx = 0;dy = 10;} else if (() == 80) {if (flag % 2 == 1) {();}if (flag % 2 == 0) {();}flag++;}}});}public void paint(Graphics g) {();(0, 0, 400, 400);();(3, 3, 305, 3);(3, 3, 3, 305);(305, 3, 305, 305);(3, 305, 305, 305);();for (int i = 0; i < (); i++) {((i).x, (i).y, 9, 9);}(x, y, 9, 9);();(fx, fy, 9, 9);();str1 = "现在的长度为:" + snakeBody;(str, 10, 320);(str1, 10, 335);}public void actionPerformed(ActionEvent e) {x += dx;y += dy;if (makeOut() == false) {(null, "重新开始......");speed = 700;snakeBody = 1;x = 5;y = 5;();(new Point(x, y));();((0));dx = 10;dy = 0;}addPoint(x, y);if (x == fx && y == fy) {speed = (int) (speed * );//速度增加参数if (speed < 200) {speed = 100;}fx = (30) * 10 + 5;// 2fy = (30) * 10 + 5;// 2snakeBody++;// 2} // 2repaint();}public void addPoint(int xx, int yy) {// 动态的记录最新发生的50步以内的移动过的坐标// 并画出最新的snakeBodyif (() < 100) {//蛇身长度最长为(new Point(xx, yy));} else {(0);(new Point(xx, yy));}if (snakeBody == 1) {(0);(0, (() - 1));} else {();if (() < snakeBody) {for (int i = () - 1; i > 0; i--) {((i));}} else {for (int i = () - 1; () < snakeBody; i--) {((i));}}}}public boolean makeOut() {if ((x < 3 || y < 3) || (x > 305 || y > 305)) {return false;}for (int i = 0; i < () - 1; i++) {for (int j = i + 1; j < (); j++) {if ((i).equals((j))) {return false;}}}return true;}}

83 评论

侯丹丹0518

代码太多,邮箱给我,发给你。

81 评论

米莱vicky

这是我专科二年级第一学期的Java课程设计,贪吃蛇是很多人知晓的游戏,但是我做了创新,主要有移动障碍物、穿越节点、创建关卡、AI,其中移动障碍物,穿越节点丰富游戏玩法,AI用到了BFS算法,用了IO流保存地图数据

93 评论

yanran8385

一楼的挺好的

204 评论

相关问答

  • html贪吃蛇游戏毕业论文

    能。1、贪吃蛇简单些,而且可扩展的不少,方面多,如果不好好考虑和设计,将难以成功开发出这个游戏。2、在这个游戏设计中,牵涉到图形界面的显示与更新、数据的收集与更

    詹姆斯尐雪 4人参与回答 2023-12-11
  • 基于贪吃蛇java毕业论文

    学生课程设计(论文)题 目: 贪吃蛇游戏程序设计指导学生姓名: 学 号:200910801001所在院(系): 计算机学院专

    肖小月半仔 3人参与回答 2023-12-10
  • 贪吃蛇毕业论文c语言

    /* 贪吃蛇程序 by champking */#define N 200#include #include #include #define LEFT 0x4

    zoemai0505 7人参与回答 2023-12-05
  • js设计贪吃蛇游戏毕业论文

    贪吃蛇 Snake v2.4 body{ font-size:9pt; } table{

    天天开心好好好 4人参与回答 2023-12-09
  • 贪吃蛇游戏毕业论文设计

    2.1程序功能介绍贪吃蛇游戏是一个经典小游戏,一条蛇在封闭围墙里,围墙里随机出现一个食物,通过按键盘四个光标键控制蛇向上下左右四个方向移动,蛇头撞倒食物,则食物

    民辉窗帘布艺 4人参与回答 2023-12-10