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

小鸟飞呀飞

欢迎来到程序小院

小鸟飞呀飞

玩法:鼠标控制小鸟飞翔的方向,点击鼠标左键上升,不要让小鸟掉落,从管道中经过,快去飞呀飞哦^^。

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

html

  <canvas width="288" height="505"></canvas>

css

canvas {margin: 0 auto;
}

js

var game = new Phaser.Game(288, 505, Phaser.CANVAS, 'game');game.States = {};game.States.boot = function() {this.preload = function() {if(typeof(GAME) !== "undefined") {this.load.baseURL = GAME + "/";}if(!game.device.desktop){this.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;this.scale.forcePortrait = true;this.scale.refresh();}game.load.image('loading', 'assets/preloader.gif');};this.create = function() {game.state.start('preload');};
};game.States.preload = function() {this.preload = function() {var preloadSprite = game.add.sprite(34, game.height/2, 'loading');game.load.setPreloadSprite(preloadSprite);game.load.image('background', 'assets/background.png');game.load.image('ground', 'assets/ground.png');game.load.image('title', 'assets/title.png');game.load.spritesheet('bird', 'assets/bird.png', 34, 24, 3);game.load.image('btn', 'assets/start-button.png');game.load.spritesheet('pipe', 'assets/pipes.png', 54, 320, 2);game.load.bitmapFont('flappy_font', 'assets/fonts/flappyfont/flappyfont.png', 'assets/fonts/flappyfont/flappyfont.fnt');game.load.audio('fly_sound', 'assets/flap.wav');game.load.audio('score_sound', 'assets/score.wav');game.load.audio('hit_pipe_sound', 'assets/pipe-hit.wav');game.load.audio('hit_ground_sound', 'assets/ouch.wav');game.load.image('ready_text', 'assets/get-ready.png');game.load.image('play_tip', 'assets/instructions.png');game.load.image('game_over', 'assets/gameover.png');game.load.image('score_board', 'assets/scoreboard.png');};this.create = function() {game.state.start('menu');};
};game.States.menu = function() {this.create = function() {var bg = game.add.tileSprite(0, 0, game.width, game.height, 'background');var ground = game.add.tileSprite(0, game.height-112, game.width, 112, 'ground');bg.autoScroll(-10 ,0);ground.autoScroll(-100 ,0);var titleGroup = game.add.group();titleGroup.create(0, 0, 'title');var bird = titleGroup.create(190, 10, 'bird');bird.animations.add('fly');bird.animations.play('fly', 12, true);titleGroup.x = 35;titleGroup.y = 100;game.add.tween(titleGroup).to({y: 120}, 1000, null, true, 0, Number.MAX_VALUE, true);var btn = game.add.button(game.width/2, game.height/2, 'btn', function() {game.state.start('play');});btn.anchor.setTo(0.5, 0.5);};
};game.States.play = function() {this.create = function() {this.bg = game.add.tileSprite(0, 0, game.width, game.height, 'background');this.pipeGroup = game.add.group();this.pipeGroup.enableBody = true;this.ground = game.add.tileSprite(0, game.height-112, game.width, 112, 'ground');this.bird = game.add.sprite(50, 150, 'bird');this.bird.animations.add('fly');this.bird.animations.play('fly', 12, true);this.bird.anchor.setTo(0.5, 0.5);game.physics.enable(this.bird, Phaser.Physics.ARCADE);this.bird.body.gravity.y = 0;game.physics.enable(this.ground, Phaser.Physics.ARCADE);this.ground.body.immovable = true;this.soundFly = game.add.sound('fly_sound');this.soundScore = game.add.sound('score_sound');this.soundHitPipe = game.add.sound('hit_pipe_sound');this.soundHitGround = game.add.sound('hit_ground_sound');this.scoreText = game.add.bitmapText(game.world.centerX - 20, 30, 'flappy_font', '0', 36);this.readyText = game.add.image(game.width/2, 40, 'ready_text');this.playTip = game.add.image(game.width/2, 300, 'play_tip');this.readyText.anchor.setTo(0.5, 0);this.playTip.anchor.setTo(0.5, 0);this.hasStarted = false;game.time.events.loop(900, this.generatePipes, this);game.time.events.stop(false);game.input.onDown.addOnce(this.startGame, this);};this.update = function() {if(!this.hasStarted) return;game.physics.arcade.collide(this.bird, this.ground, this.hitGround, null, this);game.physics.arcade.overlap(this.bird, this.pipeGroup, this.hitPipe, null, this);if(!this.bird.inWorld) this.hitCeil();if(this.bird.angle < 90) this.bird.angle += 2.5;this.pipeGroup.forEachExists(this.checkScore, this);};this.generatePipes = function() {var gap = 150;var difficulty = 100; // difficulty越大越简单var position = 50 + Math.floor((505 - 112 - difficulty - gap) * Math.random());var topPipeY = position - 320;var bottomPipeY = position + gap;if(this.resetPipe(topPipeY, bottomPipeY)) return;var topPipe = game.add.sprite(game.width, topPipeY, 'pipe', 0, this.pipeGroup);var bottomPipe = game.add.sprite(game.width, bottomPipeY, 'pipe', 1, this.pipeGroup);this.pipeGroup.setAll('checkWorldBounds', true);this.pipeGroup.setAll('outOfBoundsKill', true);this.pipeGroup.setAll('body.velocity.x', -this.gameSpeed);};this.startGame = function() {this.gameSpeed = 200;this.gameIsOver = false;this.hasHitGround = false;this.hasStarted = true;this.score = 0;this.bg.autoScroll(-(this.gameSpeed/10), 0);this.ground.autoScroll(-this.gameSpeed, 0);this.bird.body.gravity.y = 1150;this.readyText.destroy();this.playTip.destroy();game.input.onDown.add(this.fly, this);game.time.events.start();};this.stopGame = function() {this.bg.stopScroll();this.ground.stopScroll();this.pipeGroup.forEachExists(function(pipe) {pipe.body.velocity.x = 0;}, this);this.bird.animations.stop('fly', 0);game.input.onDown.remove(this.fly, this);game.time.events.stop(true);};this.fly = function() {this.bird.body.velocity.y = -350;game.add.tween(this.bird).to({angle: -30}, 100, null, true, 0, 0, false);this.soundFly.play();};this.hitCeil = function() {this.soundHitPipe.play();this.gameOver();};this.hitPipe = function() {if(this.gameIsOver) return;this.soundHitPipe.play();this.gameOver();};this.hitGround = function() {if(this.hasHitGround) return;this.hasHitGround = true;this.soundHitGround.play();this.gameOver(true);};this.gameOver = function(show_text) {this.gameIsOver = true;this.stopGame();if(show_text) this.showGameOverText();};this.showGameOverText = function() {this.scoreText.destroy();game.bestScore = game.bestScore || 0;if(this.score > game.bestScore) game.bestScore = this.score;this.gameOverGroup = game.add.group();var gameOverText = this.gameOverGroup.create(game.width/2, 0, 'game_over');var scoreboard = this.gameOverGroup.create(game.width/2, 70, 'score_board');var currentScoreText = game.add.bitmapText(game.width/2 + 60, 105, 'flappy_font', this.score+'', 20, this.gameOverGroup);var bestScoreText = game.add.bitmapText(game.width/2 + 60, 153, 'flappy_font', game.bestScore+'', 20, this.gameOverGroup);var replayBtn = game.add.button(game.width/2, 210, 'btn', function() {game.state.start('play');}, this, null, null, null, null, this.gameOverGroup);gameOverText.anchor.setTo(0.5, 0);scoreboard.anchor.setTo(0.5, 0);replayBtn.anchor.setTo(0.5, 0);this.gameOverGroup.y = 30;};this.resetPipe = function(topPipeY, bottomPipeY) {var i = 0;this.pipeGroup.forEachDead(function(pipe) {if(pipe.y <= 0) {pipe.reset(game.width, topPipeY);pipe.hasScored = false;} else {pipe.reset(game.width, bottomPipeY);}pipe.body.velocity.x = -this.gameSpeed;i++;}, this);return i == 2;};this.checkScore = function(pipe) {if(!pipe.hasScored && pipe.y <= 0 && pipe.x <= this.bird.x - 17 - 54) {pipe.hasScored = true;this.scoreText.text = ++this.score;this.soundScore.play();return true; }return false;};
};game.state.add('boot', game.States.boot);
game.state.add('preload', game.States.preload);
game.state.add('menu', game.States.menu);
game.state.add('play', game.States.play);game.state.start('boot');

源码icon-default.png?t=N7T8https://www.ormcc.com/

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

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

相关文章:

小鸟飞呀飞

欢迎来到程序小院 小鸟飞呀飞 玩法&#xff1a;鼠标控制小鸟飞翔的方向&#xff0c;点击鼠标左键上升&#xff0c;不要让小鸟掉落&#xff0c;从管道中经过&#xff0c;快去飞呀飞哦^^。开始游戏https://www.ormcc.com/play/gameStart/204 html <canvas width"288&quo…...

Unity 场景烘培 ——unity Post-Processing后处理1(四)

提示&#xff1a;文章有错误的地方&#xff0c;还望诸位大神不吝指教&#xff01; 文章目录 前言一、Post-Processing是什么&#xff1f;二、安装使用Post-Processing1.安装Post-Processing2.使用Post-Processing&#xff08;1&#xff09;.添加Post-process Volume&#xff08…...

Burpsuite抓HTTPS证书导入问题

Burpsuite证书导出有两种方法&#xff1a; 第一种方法 1、开启代理后直接在浏览器中输入burp下载CA证书 2、在中间证书颁发机构中导入刚导出的证书 3、导入完成后再把这个证书选择导出&#xff0c;另存为cer格式的文件 4、在受信任的根证书颁发机构中导入刚保存的cer格式证书…...

python保存文件到zip压缩包中

这里我们使用zipfile这个库进行操作&#xff0c;保存压缩文件相对简单&#xff0c;只需要指定文件名即可&#xff0c;不需要读取那个文件&#xff1a; with zipfile.ZipFile("zip文件路径", mode, zipfile.ZIP_DEFLATED) as z:z.write("压缩源文件路径", …...

java发送媒体类型为multipart/form-data的请求

文章目录 public static String sendMultipartFormDataPostRequest(String urlString, String data) throws IOException {String fullUrl urlString "?" data;log.info("完整请求路径为{}", fullUrl);URL url new URL(fullUrl);HttpURLConnection co…...

自定义类使用ArrayList中的remove

Java中ArrayList对基础类型和字符串类型的删除操作&#xff0c;直接用remove方法即可。但是对于自定义的类来说&#xff0c;用remove方法删除不了&#xff0c;因为没有办法确定是否是要删除的对象。 ArrayList中remove源码是&#xff1a; public boolean remove(Object o) {if…...

前端面试考核点【更持续新中】

文章目录 HTMLcssjsVueReactTypeScript移动端&小程序编译/打包/构建npmnodejs微前端网络安全浏览器性能OKR工程化、标准化 HTML Script放在body中间会阻塞吗&#xff1f;defer与async的区别&#xff1f;https://blog.csdn.net/qq_41887214/article/details/124909219 DOM和…...

linux-docker安装

​TOC 一&#xff0c;Docker简介 百科说&#xff1a;Docker 是一个开源的应用容器引擎&#xff0c;让开发者可以打包他们的应用以及依赖包到一个可移植的容器中&#xff0c;然后发布到任何流行的Linux机器上&#xff0c;也可以实现虚拟化&#xff0c;容器是完全使用沙箱机制&…...

如何用html css js 画出曲线 或者斜线;

效果图 解题思路 将图片全部定位至中心点&#xff0c;然后x轴就变动translateX &#xff0c;y轴同理&#xff1b; 这里有两个问题 浏览器&#xff1a; 以左上角为原点0&#xff0c;0 越往下y越大 数学坐标系&#xff1a;以中心点为原点0&#xff0c;0 越往下y越小&#xff1…...

【错误记录】Uncaught TypeError: m.nodeName.toLowerCase is not a function

描述&#xff1a;在控制台输出上述错误~ 原因&#xff1a;在页面中&#xff0c;使用jQuery 开发时&#xff0c;命名不能和jQuery一起方法属性冲突&#xff0c;比如这里的nodeName&#xff0c;这里换一个不冲突的名字&#xff0c;就解决问题了。...

王颖奇:ONES.ai 上线,以及我的一些思考

ONES.ai 正式上线&#xff01;为你解锁更智能、更高效的新一代研发管理体验 我们上线了 ONES.ai&#xff0c;当然我们用了公开的 LLM(AI)&#xff0c;目前我们最方便使用的就是公开的 LLM&#xff0c;其实是不是 公开的 LLM 也不重要&#xff0c;在未来可预见的时间内&#xff…...

将AI技术与VR元宇宙相结合的整体解决方案

当前人工智能与VR虚拟现实两大热门技术的融合&#xff0c;正引领着人类走向更智能、更数字化、更便捷、更快速的时代。将这两者结合&#xff0c;AI智能检索应用到VR教学中&#xff0c;将为教育带来前所未有的好处。 个性化教学体验 通过AI智能检索&#xff0c;VR教学可以针对每…...

IPKISS Tutorials 3------绘制矩形版图

IPKISS Tutorials 3------绘制矩形版图 方法1------使用Rectangle函数模块导入与放置层设定创建PCell可视化版图这里给大家介绍一下如何在 IPKISS 绘制一个矩形结构的版图。 方法1------使用Rectangle函数 import si_fab.all as pdk import ipkiss3.all as i3class Box(i3.PC…...

为什么需要用高压放大器

高压放大器是一种重要的电子设备&#xff0c;它的主要功能是将高电压信号放大到所需的输出水平。在各种不同的应用中&#xff0c;为什么我们需要使用高压放大器呢&#xff1f;本文将详细探讨以下几个方面的原因。 高压放大器在科学研究中起着关键的作用。在物理学、化学、生物学…...

前端uniapp生成海报绘制canvas画布并且保存到相册【实战/带源码/最新】

目录 插件市场效果如下图注意使用my-share.vue插件文件如下图片hch-posterutilsindex.js draw-demo.vuehch-poster.vue 最后 插件市场 插件市场 效果如下图 注意 主要&#xff1a;使用my-share.vue和绘制canvas的hch-poster.vue这两个使用 使用my-share.vue <template&…...

【算法专题】双指针

双指针 双指针1. 移动零2. 复写零3. 快乐数4. 盛水最多的容器5. 有效三角形的个数6. 和为s的两个数字7. 三数之和8. 四数之和 双指针 常见的双指针有两种形式&#xff0c;⼀种是对撞指针&#xff0c;⼀种是左右指针。 对撞指针&#xff1a;⼀般用于顺序结构中&#xff0c;也称…...

redis运维(七)基础通用命令

一 基础通用命令 备注&#xff1a; 与具体数据类型无关Tab键 自动补全补充&#xff1a; redis 命令是不区分大小写 通用不到 10 个提升逼格的 redis 命令 后续&#xff1a; slowlog、rename-command、monitor、set ① help command 需求&#xff1a; 显示有关redis命令的…...

搜索引擎ElasticSearch分布式搜索和分析引擎学习,SpringBoot整合ES个人心得

ElasticSearch Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎&#xff0c;基于RESTful web接口。Elasticsearch是用Java语言开发的&#xff0c;并作为Apache许可条款下的开放源码发布&#xff0c;是一种流行的企业级搜索引擎。Elas…...

云原生微服务架构图

云原生微服务架构的具体架构图会根据应用程序的需求、规模和业务场景而有所不同。以下是一个通用的云原生微服务架构图&#xff0c;具体每层的组件可能有所不同&#xff1a; 用户界面层&#xff1a; Web应用或移动应用&#xff1a; 提供用户访问和交互的前端应用。API Gateway&…...

泊车功能专题介绍 ———— AVP系统技术要求之人机交互云平台

文章目录 人机交互车端人机交互车外人机交互灯光交互声音交互 车内人机交互信号装置标示的交互声音交互 场景左右转弯经过让行提示泊入泊出 激活及退出条件激活条件退出条件 场端人机交互V2X交互故障车提醒路口盲区预警弱势交通参与者提醒 场端设施的预警车辆入场车辆故障 APP人…...

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

谷歌浏览器插件

项目中有时候会用到插件 sync-cookie-extension1.0.0&#xff1a;开发环境同步测试 cookie 至 localhost&#xff0c;便于本地请求服务携带 cookie 参考地址&#xff1a;https://juejin.cn/post/7139354571712757767 里面有源码下载下来&#xff0c;加在到扩展即可使用FeHelp…...

Appium+python自动化(十六)- ADB命令

简介 Android 调试桥(adb)是多种用途的工具&#xff0c;该工具可以帮助你你管理设备或模拟器 的状态。 adb ( Android Debug Bridge)是一个通用命令行工具&#xff0c;其允许您与模拟器实例或连接的 Android 设备进行通信。它可为各种设备操作提供便利&#xff0c;如安装和调试…...

《Playwright:微软的自动化测试工具详解》

Playwright 简介:声明内容来自网络&#xff0c;将内容拼接整理出来的文档 Playwright 是微软开发的自动化测试工具&#xff0c;支持 Chrome、Firefox、Safari 等主流浏览器&#xff0c;提供多语言 API&#xff08;Python、JavaScript、Java、.NET&#xff09;。它的特点包括&a…...

如何在看板中有效管理突发紧急任务

在看板中有效管理突发紧急任务需要&#xff1a;设立专门的紧急任务通道、重新调整任务优先级、保持适度的WIP&#xff08;Work-in-Progress&#xff09;弹性、优化任务处理流程、提高团队应对突发情况的敏捷性。其中&#xff0c;设立专门的紧急任务通道尤为重要&#xff0c;这能…...

江苏艾立泰跨国资源接力:废料变黄金的绿色供应链革命

在华东塑料包装行业面临限塑令深度调整的背景下&#xff0c;江苏艾立泰以一场跨国资源接力的创新实践&#xff0c;重新定义了绿色供应链的边界。 跨国回收网络&#xff1a;废料变黄金的全球棋局 艾立泰在欧洲、东南亚建立再生塑料回收点&#xff0c;将海外废弃包装箱通过标准…...

Cinnamon修改面板小工具图标

Cinnamon开始菜单-CSDN博客 设置模块都是做好的&#xff0c;比GNOME简单得多&#xff01; 在 applet.js 里增加 const Settings imports.ui.settings;this.settings new Settings.AppletSettings(this, HTYMenusonichy, instance_id); this.settings.bind(menu-icon, menu…...

IoT/HCIP实验-3/LiteOS操作系统内核实验(任务、内存、信号量、CMSIS..)

文章目录 概述HelloWorld 工程C/C配置编译器主配置Makefile脚本烧录器主配置运行结果程序调用栈 任务管理实验实验结果osal 系统适配层osal_task_create 其他实验实验源码内存管理实验互斥锁实验信号量实验 CMISIS接口实验还是得JlINKCMSIS 简介LiteOS->CMSIS任务间消息交互…...

css3笔记 (1) 自用

outline: none 用于移除元素获得焦点时默认的轮廓线 broder:0 用于移除边框 font-size&#xff1a;0 用于设置字体不显示 list-style: none 消除<li> 标签默认样式 margin: xx auto 版心居中 width:100% 通栏 vertical-align 作用于行内元素 / 表格单元格&#xff…...

mysql已经安装,但是通过rpm -q 没有找mysql相关的已安装包

文章目录 现象&#xff1a;mysql已经安装&#xff0c;但是通过rpm -q 没有找mysql相关的已安装包遇到 rpm 命令找不到已经安装的 MySQL 包时&#xff0c;可能是因为以下几个原因&#xff1a;1.MySQL 不是通过 RPM 包安装的2.RPM 数据库损坏3.使用了不同的包名或路径4.使用其他包…...