当前位置: 首页 > news >正文

网站建设与管理 教学视频app官方免费下载

网站建设与管理 教学视频,app官方免费下载,做网站比较好的企业,泰州自助建站软件目录 1、Vue实现2、Java实现 2048 游戏是一个基于网格的数字益智游戏#xff0c;玩家需要通过滑动相同的数字来合并它们#xff0c;并最终得到一个值为 2048 的方块。以下是分别用Vue和Java来实现的 2048 游戏#xff0c;包含运行效果。 1、Vue实现 首先#xff0c;创建一… 目录 1、Vue实现2、Java实现 2048 游戏是一个基于网格的数字益智游戏玩家需要通过滑动相同的数字来合并它们并最终得到一个值为 2048 的方块。以下是分别用Vue和Java来实现的 2048 游戏包含运行效果。 1、Vue实现 首先创建一个名为Game.vue的 Vue 单文件组件代码如下 template div classgame-container div classgrid div v-for(row, rowIndex) in board :keyrowIndex classcell div v-ifrow.length div v-for(cell, colIndex) in row :keycolIndex :class{ highlight: cell current } {{ cell }} /div /div /div /div div classscore p得分{{ score }}/p /div button clicknewGame重新开始/button /div /template script export default { data() { return { board: [ [1, 1, 2, 2], [3, 3], [4, 4], [4, 4], [2, 2], [1, 1, 3, 3], [2, 2], [4, 4], ], current: null, score: 0, }; }, methods: { move(direction) { if (direction left this.current this.current.leftCell) { this.current.leftCell this.current.leftCell.left; if (!this.current.leftCell) { this.current null; } } else if (direction right this.current this.current.rightCell) { this.current.rightCell this.current.rightCell.right; if (!this.current.rightCell) { this.current null; } } }, newGame() { this.board [ [Math.floor(Math.random() * 4) 1, Math.floor(Math.random() * 4) 1], [Math.floor(Math.random() * 4) 1, Math.floor(Math.random() * 4) 1], [Math.floor(Math.random() * 4) 1, Math.floor(Math.random() * 4) 1], [Math.floor(Math.random() * 4) 1, Math.floor(Math.random() * 4) 1], ]; this.score 0; this.current null; }, slide() { if (this.current) { if (this.current.leftCell) { this.move(left); } else if (this.current.rightCell) { this.move(right); } } }, }, }; /script style scoped .game-container { width: 100%; max-width: 800px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; border-radius: 5px; } .grid { display: flex; flex-wrap: wrap; } .cell { width: 40px; height: 40px; background-color: #f2f2f2; display: flex; justify-content: center; align-items: center; border-radius: 5px; margin: 10px; } .cell:hover { background-color: #ddd; } .highlight { background-color: #ffc107; } .score { margin-top: 20px; font-size: 24px; font-weight: bold; } /style2、Java实现 import java.util.*; import java.util.concurrent.ThreadLocal; public class 2048Game { private static int BOARD_SIZE 4; private static int[][] board new int[BOARD_SIZE][BOARD_SIZE]; private static int current 0; private static int score 0;public static void main(String[] args) { new ThreadLocal2048Game().set(new 2048Game()); }private 2048Game() { reset(); }public void reset() { board new int[BOARD_SIZE][BOARD_SIZE]; generateBoard(); current 0; score 0; }private void generateBoard() { for (int i 0; i board.length; i) { for (int j 0; j board[i].length; j) { board[i][j] Math.floor(Math.random() * 4) 1; } } }public void slide(int direction) { if (direction 0 || direction 1) { for (int i 0; i board.length; i) { int[] temp board[i]; int j 0; for (int k 0; k temp.length; k) { if (temp[k]! 0) { while (j temp.length - 1 temp[j 1] temp[k]) { temp[j] temp[j 1]; j; } } temp[j] k; j; } board[i] temp; } } else if (direction 2 || direction 3) { for (int i 0; i board.length; i) { int[] temp board[i]; int k 0; for (int j 0; j temp.length; j) { if (temp[j]! 0) { while (k temp.length - 1 temp[k 1] temp[j]) { temp[k] temp[k 1]; k; } } temp[k] j; k; } board[i] temp; } } }public void printBoard() { System.out.println(当前分数 score); for (int i 0; i board.length; i) { for (int j 0; j board[i].length; j) { System.out.print(board[i][j] ); } System.out.println(); } }public void checkWin() { for (int i 0; i board.length; i) { for (int j 0; j board[i].length; j) { if (board[i][j] 0) { return; } if (j board[i].length - 1 board[i][j] board[i][j 1]) { int sum board[i][j] board[i][j 1]; board[i][j] 0; board[i][j 1] 0; score sum; System.out.println(恭喜你赢得了 sum 分); reset(); } } } } }运行效果 当前分数0
http://www.zqtcl.cn/news/900369/

相关文章:

  • 如何搭建一个公司网站互联网推广怎么找客户
  • 江苏同隆建设集团有限公司网站asp.net新建网站
  • 爱站网挖掘工具小程序网站开发怎么样
  • 网站文章批量上传工具自己制作免费网站
  • 凡科快速建站建设网站遇到问题的解决方案
  • 深圳市公司网站建设公司十大互联网营销公司
  • 免费发布推广信息的网站百度招聘2022年最新招聘
  • 建站公司怎么获客任县附近网站建设价格
  • 泰兴市淘宝网站建设指数 网站权重
  • 烟台市做网站找哪家好才艺多网站建设
  • nginx wordpress 重写seo技术大师
  • 公司网站建设需要什么科目上海服务政策调整
  • 如何免费搭建自己的网站网站建设公司swot分析
  • 太原网站优化技术如何开发一款app软件
  • 莆田做网站公司lnmp wordpress 404
  • 网站开发中的qq登录网站地图有什么作用
  • 南宁小程序开发网站建设公司网络营销方案设计范文
  • 电脑做网站主机空间哈尔滨人才招聘信息网
  • 无锡网站建设制作设计wordpress news list
  • 专业建站教程青海 网站开发 图灵
  • 济南网站公司哪家好中国建设银行电脑版
  • 企业网站建设定制网站建设成功案例怎么写
  • 一个网站做数据维护3天正常吗做sgs认证公司网站
  • 免费网络短剧网站摄影素材库网站
  • 如何做竞价网站数据监控网站建设企业的市场分析
  • 电脑做网站主机空间软件开发工作岗位
  • 计算机多媒体辅助教学网站开发响应式网站建设精英
  • 免费网站空间怎么做网站主持人
  • 开源建站系统有哪些网站信息化建设合同
  • 昆明云南微网站淄博专业网站建设