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

机器人向前冲

欢迎来到程序小院

机器人向前冲

玩法:一直走动的机器人,点击鼠标左键进行跳跃,跳过不同的匝道,掉下去即为游戏接续,
碰到匝道铁钉游戏结束,一直往前冲吧^^。

开始游戏icon-default.png?t=N7T8https://www.ormcc.com/play/gameStart/206

html

  <canvas width="1280" height="768"></canvas>

css

canvas {display: block;touch-action: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); width: 680px; height: 408px; cursor: inherit; margin-left: 0px; margin-top: 71px; margin-bottom: -71px;"
}

js

var game = new Phaser.Game(1280, 768, Phaser.AUTO, '');
game.state.add('Boot', BasicGame.Boot);
game.state.add('Preloader', BasicGame.Preloader);
game.state.add('MainMenu', BasicGame.MainMenu);
game.state.add('Game', BasicGame.Game);
// Now start the Boot state.
game.state.start('Boot');
BasicGame.Game.prototype = {
create: function () {this.map = this.game.add.tilemap('map');this.map.addTilesetImage('gem');this.map.addTilesetImage('platforms');this.map.setTileIndexCallback(61,this.hitCoin,this);this.map.setTileIndexCallback(24,this.dead,this);this.map.setTileIndexCallback(25,this.dead,this);this.layer = this.map.createLayer('Tile Layer 1');this.layer.resizeWorld();this.map.setCollisionBetween(1,10);this.map.setCollisionBetween(13,20);this.map.setCollisionBetween(23,37);this.map.setCollisionBetween(39,45);this.map.setCollisionBetween(49,60);this.sprite = this.game.add.sprite(75,600,'hero');this.sprite.animations.add('run',[0,1,2,3,4,5,6,7],16,true);this.game.physics.enable(this.sprite);this.sprite.body.bounce.set(0);this.sprite.body.tilePadding.set(64);this.game.camera.follow(this.sprite);this.sprite.body.gravity.y = 1200;this.game.input.onDown.add(this.jump,this);this.game.physics.startSystem(Phaser.Physics.ARCADE);this.game.physics.arcade.TILE_BIAS = 50;this.playing = true;
},jump: function() {if (this.sprite.body.blocked.down) {this.sprite.body.velocity.y = -720;this.sprite.animations.stop();this.sprite.frame = 2;}},
update: function () {this.game.physics.arcade.collide(this.sprite,this.layer);if (this.sprite.body.blocked.right) {this.sprite.body.velocity.x = 0;} else {this.sprite.body.velocity.x = 300;}if (this.sprite.body.blocked.down) {this.sprite.animations.play('run');}if (this.sprite.x > 7460) {console.log("win");this.playing=false;}if (this.sprite.y > 760) {this.dead();}this.quitGame(this.playing);
},
quitGame: function (pointer) {if(!this.playing) {delete this.map;delete this.layer;delete this.sprite;//takes us back to Main Menuthis.state.start('MainMenu');}
},hitCoin: function (sprite,tile) {if (tile.alpha != 0) {tile.alpha = 0;this.layer.dirty = true;return false;}},dead: function () {console.log("dead");this.playing=false;}
};

源码

需要源码请关注添加好友哦^ ^

转载:欢迎来到本站,转载请注明文章出处https://ormcc.com/

http://www.lryc.cn/news/247529.html

相关文章:

  • jq——实现弹幕滚动(往左滚动+往右滚动)——基础积累
  • 深度学习第2天:RNN循环神经网络
  • 深度学习之基于百度飞桨PaddleOCR图像字符检测识别系统
  • 九、LuaTable(表)
  • 每日一题(LeetCode)----链表--链表最大孪生和
  • 腾讯云轻量服务器通过Docker搭建外网可访问连接的redis5.x集群
  • C++学习之路(十一)C++ 用Qt5实现一个工具箱(增加一个进制转换器功能)- 示例代码拆分讲解
  • C语言每日一题(40)栈实现队列
  • Vue.js 的生命周期
  • SeaTunnel引擎下的SQL Server CDC解决方案:构建高效数据管道
  • 【攻防世界-misc】Encode
  • visual c++ 2019 redistributable package
  • WPF中DataGrid解析
  • 在数据库中进行表内容的修改(MYSQL)
  • Android中的多进程
  • Apache2.4 AliasMatch导致301重定向问题?
  • 广州华锐视点:基于VR元宇宙技术开展法律法规常识在线教学,打破地域和时间限制
  • Maven——Maven使用基础
  • U4_2:图论之MST/Prim/Kruskal
  • springboot 注解@JsonInclude
  • Python 中文完整教程目录
  • C/C++---------------LeetCode第35. 搜索插入位置
  • 网络安全--基于Kali的网络扫描基础技术
  • C语言——求π的近似值
  • 如何使用ffmpeg转换图片格式
  • 11 动态规划解最后一块石头的重量II
  • LeetCode算法题解(动态规划,股票买卖)|LeetCode121. 买卖股票的最佳时机、LeetCode122. 买卖股票的最佳时机 II
  • python实验3 石头剪刀布游戏
  • 米贸搜|如何设置 Facebook 转换 API + 事件重复数据删除
  • python每日一题——11滑动窗口最大值