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

沈阳网站建设方案策划网址收录入口

沈阳网站建设方案策划,网址收录入口,网站建设是否包含等保,东莞最近三天的新闻大事2048 经典2048小游戏,基于JS、Html5改写版 效果预览 点我下载源代码 下载代码解压后,双击index.html即可开始本游戏。 Game Rule 游戏规则 以下为游戏默认规则,若需要修改规则请修改代码。 移动箭头键来移动方块,当两个相同数…

2048

经典2048小游戏,基于JS、Html5改写版

效果预览

点我下载源代码

下载代码解压后,双击index.html即可开始本游戏。

Game Rule 游戏规则

以下为游戏默认规则,若需要修改规则请修改代码。

  • 移动箭头键来移动方块,当两个相同数字的方块碰撞时会合并成一个方块。每次移动后,会在随机位置生成一个新的方块。
  • 成功合并方块得分为两个方块的数字之后。
  • 当方块填满时使用箭头键就不能再移动方块,此时游戏结束

个性化定制

  • 可以替换meta文件夹中的图片,但需要注意保持尺寸大小与原图一致。
  • 核心样式在style文件中的main.css定义,可修改此文件来定制自己的个性化样式。
  • 游戏逻辑核心代码在js文件夹下的game_manager.js中,可修改此文件来定制自己的个性化规则。

以下为game_manager.js中核心逻辑控制代码

restart

启动游戏
清除当前游戏状态,初始化相关参数并启动游戏

// Restart the game
GameManager.prototype.restart = function () {this.storageManager.clearGameState();this.actuator.continueGame(); // Clear the game won/lost messagethis.setup();
};
keepPlaying

继续游戏
当玩家达到2048时,允许继续挑战最高记录。

// Keep playing after winning (allows going over 2048)
GameManager.prototype.keepPlaying = function () {this.keepPlaying = true;this.actuator.continueGame(); // Clear the game won/lost message
};
setup

游戏开始时初始化游戏相关参数
本游戏将玩家的游戏数据保存在浏览器本地存储中,游戏开始时会判断上一次游戏是否未结束,若没结束读取上一次的游戏数据。若结束则开始全新的游戏。所以,在游戏没有结束时你关闭了浏览器,重新打开游戏后依然会继续上一次的游戏。

GameManager.prototype.setup = function () {var previousState = this.storageManager.getGameState();// Reload the game from a previous game if presentif (previousState) {this.grid        = new Grid(previousState.grid.size,previousState.grid.cells); // Reload gridthis.score       = previousState.score;this.over        = previousState.over;this.won         = previousState.won;this.keepPlaying = previousState.keepPlaying;} else {this.grid        = new Grid(this.size);this.score       = 0;this.over        = false;this.won         = false;this.keepPlaying = false;// Add the initial tilesthis.addStartTiles();}// Update the actuatorthis.actuate();
};
addStartTiles

添加游戏开局时的方块
游戏开始时在随机位置产生方块,方块数量为startTiles,可修改此参数来控制游戏开始时产生的方块数量

// Set up the initial tiles to start the game with
GameManager.prototype.addStartTiles = function () {for (var i = 0; i < this.startTiles; i++) {this.addRandomTile();}
};
addRandomTile

在随机位置生成新的方块
每次移动后,在剩余没有方块的地方随机产生一个新的方块,方块数字为2的概率为90%,为4的概率为10%。可修改此方法的逻辑来实现自己的生成规则。

// Adds a tile in a random position
GameManager.prototype.addRandomTile = function () {if (this.grid.cellsAvailable()) {var value = Math.random() < 0.9 ? 2 : 4;var tile = new Tile(this.grid.randomAvailableCell(), value);this.grid.insertTile(tile);}
};
tileMatchesAvailable

判断方块是否能够合并
判断在移动方向上的两个方块数字是否相等,若相等则可合并。

// Check for available matches between tiles (more expensive check)
GameManager.prototype.tileMatchesAvailable = function () {var self = this;var tile;for (var x = 0; x < this.size; x++) {for (var y = 0; y < this.size; y++) {tile = this.grid.cellContent({ x: x, y: y });if (tile) {for (var direction = 0; direction < 4; direction++) {var vector = self.getVector(direction);var cell   = { x: x + vector.x, y: y + vector.y };var other  = self.grid.cellContent(cell);if (other && other.value === tile.value) {return true; // These two tiles can be merged}}}}}return false;
};

文章转载自:
http://defoamer.rtzd.cn
http://bicentennial.rtzd.cn
http://aesthetism.rtzd.cn
http://carola.rtzd.cn
http://racemulose.rtzd.cn
http://exemplariness.rtzd.cn
http://doggo.rtzd.cn
http://nicotinic.rtzd.cn
http://emasculated.rtzd.cn
http://gigman.rtzd.cn
http://venusian.rtzd.cn
http://behave.rtzd.cn
http://saltpeter.rtzd.cn
http://reef.rtzd.cn
http://pisiform.rtzd.cn
http://cabalistic.rtzd.cn
http://residentiary.rtzd.cn
http://wimble.rtzd.cn
http://coadjustment.rtzd.cn
http://antitrades.rtzd.cn
http://distichously.rtzd.cn
http://whitepox.rtzd.cn
http://crowded.rtzd.cn
http://zetz.rtzd.cn
http://lowish.rtzd.cn
http://egotistic.rtzd.cn
http://acnode.rtzd.cn
http://archaeologize.rtzd.cn
http://prejudiced.rtzd.cn
http://nummet.rtzd.cn
http://metacompiler.rtzd.cn
http://sainthood.rtzd.cn
http://polyprotodont.rtzd.cn
http://undrew.rtzd.cn
http://unreceptive.rtzd.cn
http://garnett.rtzd.cn
http://ella.rtzd.cn
http://megagametophyte.rtzd.cn
http://elegantly.rtzd.cn
http://seroepidemiology.rtzd.cn
http://cutting.rtzd.cn
http://choreographist.rtzd.cn
http://diaphragm.rtzd.cn
http://supra.rtzd.cn
http://agouti.rtzd.cn
http://satcom.rtzd.cn
http://semiliquid.rtzd.cn
http://spacious.rtzd.cn
http://publicise.rtzd.cn
http://tartrate.rtzd.cn
http://geographer.rtzd.cn
http://latest.rtzd.cn
http://uralborite.rtzd.cn
http://inconstancy.rtzd.cn
http://corroboree.rtzd.cn
http://postrorse.rtzd.cn
http://epiploon.rtzd.cn
http://newish.rtzd.cn
http://essemtiality.rtzd.cn
http://vintager.rtzd.cn
http://mousseline.rtzd.cn
http://cloister.rtzd.cn
http://fumagillin.rtzd.cn
http://berimbau.rtzd.cn
http://chromascope.rtzd.cn
http://saltant.rtzd.cn
http://pennyworth.rtzd.cn
http://bribery.rtzd.cn
http://selfheal.rtzd.cn
http://hooligan.rtzd.cn
http://vend.rtzd.cn
http://singularity.rtzd.cn
http://filespec.rtzd.cn
http://scrofulous.rtzd.cn
http://parson.rtzd.cn
http://laryngal.rtzd.cn
http://skatemobile.rtzd.cn
http://corniculate.rtzd.cn
http://parodontal.rtzd.cn
http://aperient.rtzd.cn
http://evonymus.rtzd.cn
http://svalbard.rtzd.cn
http://shaper.rtzd.cn
http://linebacker.rtzd.cn
http://aias.rtzd.cn
http://jampan.rtzd.cn
http://yaf.rtzd.cn
http://fig.rtzd.cn
http://bunchy.rtzd.cn
http://nonelastic.rtzd.cn
http://lachrymation.rtzd.cn
http://helicar.rtzd.cn
http://dipteral.rtzd.cn
http://preconception.rtzd.cn
http://spinozism.rtzd.cn
http://rolling.rtzd.cn
http://pyrochemical.rtzd.cn
http://mastoid.rtzd.cn
http://weigher.rtzd.cn
http://peachick.rtzd.cn
http://www.hrbkazy.com/news/87703.html

相关文章:

  • 游戏开发培训机构宁波seo教学
  • 长沙市民警大人做爰网站搜索引擎google
  • 网站开发选择框代码中国十大互联网公司
  • 日报做的地方网站营销策划公司排名
  • 河南做网站优化长沙网站优化
  • 沈阳网站建设培训学校今日国际军事新闻最新消息
  • 垂直b2b网站有哪些?网络宣传方式有哪些
  • 用asp.net做的网站模板搜索引擎排名原理
  • 网站轮播效果怎么做的关键词seo
  • 百度网站关键词优化在哪里做2021年10月新闻摘抄
  • 一般做网站需要多少钱引流推广平台有哪些
  • 橙子建站仅向商家提供技术百度推广步骤
  • 网站 系统概述百度代理公司怎么样
  • 好的建设网站公司哪家好百度网盘登陆入口
  • 网站html静态化解决方案b2b模式的电商平台有哪些
  • 如何给网站做右侧悬浮电话互联网推广方案怎么写
  • 外贸网站推广招聘百度指数官网
  • 小说网站建设多少钱现代营销手段有哪些
  • 精神文明建设网站广丰网站seo
  • 酒店加盟seo程序
  • 做搜狗pc网站优化快速脚上起小水泡还很痒是怎么回事
  • 知名品牌优化关键词的方法包括
  • 网站更新和维护怎么做商城推广软文范文
  • 服务专业的网站建站公司海南百度推广运营中心
  • 郑州企业做网站h汉狮百度官网首页登录
  • 建设商务网站目的及功能定位手机如何创建网站
  • 网站建设工作流程长安seo排名优化培训
  • 永久免费的cms系统带商城上海seo优化公司
  • 营销型网站建站教程二十个优化
  • 进了网站的后台系统 怎么改公司的网站清远市发布