当前位置: 首页 > 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人…...

测试微信模版消息推送

进入“开发接口管理”--“公众平台测试账号”&#xff0c;无需申请公众账号、可在测试账号中体验并测试微信公众平台所有高级接口。 获取access_token: 自定义模版消息&#xff1a; 关注测试号&#xff1a;扫二维码关注测试号。 发送模版消息&#xff1a; import requests da…...

XCTF-web-easyupload

试了试php&#xff0c;php7&#xff0c;pht&#xff0c;phtml等&#xff0c;都没有用 尝试.user.ini 抓包修改将.user.ini修改为jpg图片 在上传一个123.jpg 用蚁剑连接&#xff0c;得到flag...

7.4.分块查找

一.分块查找的算法思想&#xff1a; 1.实例&#xff1a; 以上述图片的顺序表为例&#xff0c; 该顺序表的数据元素从整体来看是乱序的&#xff0c;但如果把这些数据元素分成一块一块的小区间&#xff0c; 第一个区间[0,1]索引上的数据元素都是小于等于10的&#xff0c; 第二…...

日语学习-日语知识点小记-构建基础-JLPT-N4阶段(33):にする

日语学习-日语知识点小记-构建基础-JLPT-N4阶段(33):にする 1、前言(1)情况说明(2)工程师的信仰2、知识点(1) にする1,接续:名词+にする2,接续:疑问词+にする3,(A)は(B)にする。(2)復習:(1)复习句子(2)ために & ように(3)そう(4)にする3、…...

MMaDA: Multimodal Large Diffusion Language Models

CODE &#xff1a; https://github.com/Gen-Verse/MMaDA Abstract 我们介绍了一种新型的多模态扩散基础模型MMaDA&#xff0c;它被设计用于在文本推理、多模态理解和文本到图像生成等不同领域实现卓越的性能。该方法的特点是三个关键创新:(i) MMaDA采用统一的扩散架构&#xf…...

Java线上CPU飙高问题排查全指南

一、引言 在Java应用的线上运行环境中&#xff0c;CPU飙高是一个常见且棘手的性能问题。当系统出现CPU飙高时&#xff0c;通常会导致应用响应缓慢&#xff0c;甚至服务不可用&#xff0c;严重影响用户体验和业务运行。因此&#xff0c;掌握一套科学有效的CPU飙高问题排查方法&…...

代码随想录刷题day30

1、零钱兑换II 给你一个整数数组 coins 表示不同面额的硬币&#xff0c;另给一个整数 amount 表示总金额。 请你计算并返回可以凑成总金额的硬币组合数。如果任何硬币组合都无法凑出总金额&#xff0c;返回 0 。 假设每一种面额的硬币有无限个。 题目数据保证结果符合 32 位带…...

【从零开始学习JVM | 第四篇】类加载器和双亲委派机制(高频面试题)

前言&#xff1a; 双亲委派机制对于面试这块来说非常重要&#xff0c;在实际开发中也是经常遇见需要打破双亲委派的需求&#xff0c;今天我们一起来探索一下什么是双亲委派机制&#xff0c;在此之前我们先介绍一下类的加载器。 目录 ​编辑 前言&#xff1a; 类加载器 1. …...

在 Spring Boot 项目里,MYSQL中json类型字段使用

前言&#xff1a; 因为程序特殊需求导致&#xff0c;需要mysql数据库存储json类型数据&#xff0c;因此记录一下使用流程 1.java实体中新增字段 private List<User> users 2.增加mybatis-plus注解 TableField(typeHandler FastjsonTypeHandler.class) private Lis…...

Kubernetes 网络模型深度解析:Pod IP 与 Service 的负载均衡机制,Service到底是什么?

Pod IP 的本质与特性 Pod IP 的定位 纯端点地址&#xff1a;Pod IP 是分配给 Pod 网络命名空间的真实 IP 地址&#xff08;如 10.244.1.2&#xff09;无特殊名称&#xff1a;在 Kubernetes 中&#xff0c;它通常被称为 “Pod IP” 或 “容器 IP”生命周期&#xff1a;与 Pod …...