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

伐木猪小游戏

欢迎来到程序小院

伐木猪

玩法:控制小猪点击屏幕左右砍树,不能碰到树枝,考验手速与眼力,记录分数,快去挑战伐木吧^^。

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

html

<script type="text/javascript" src="js/state/boot.js"></script>
<script type="text/javascript" src="js/state/load.js"></script>
<script type="text/javascript" src="js/state/menu.js"></script>
<script type="text/javascript" src="js/state/play.js"></script>
<script type="text/javascript" src="js/state/demo.js"></script>

css

*{padding: 0;margin: 0;border: none;user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none;box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box;
}
canvas{margin: 0 auto;
}

js

var isStart = 0;
window.Timberpig.state.demo = {create: function(){var game = this;var j = 0; //当第一次按下 不执行var tweenA,tweenB;this.background = mt.create("background"); //创建背景this.ground = mt.create("ground");   //创建地面this.cloud = mt.create("cloud");   //创建云层this.cloud.update = function(){    //云层动画for(var i = 0; i < this.length; i++){if(this.getChildAt(i).x + this.getChildAt(i).width < 0){this.getChildAt(i).x = game.world.width;this.getChildAt(i).y = game.rnd.between(game.world.centerY / 2,game.world.centerY / 1.5);}this.getChildAt(i).x--;}};this.tree = mt.create("tree");      //创建树木this.title = mt.create("title");     //创建标题tweenA = game.add.tween(this.title).to( { y: this.title.y + 100 }, 2000, "Linear");tweenB = game.add.tween(this.title).to( { y: this.title.y }, 2000, "Linear");tweenA.chain(tweenB);        //缓动动画tweenB.chain(tweenA);        //动画链接tweenA.start();          //播放动画this.title.update = function(){if(isStart == 1){this.destroy();}};this.Score = mt.create("Score");this.Score.alpha = 0;var Score = this.Score;this.btnPlay = mt.create("btnPlay");    //开始按钮this.btnPlay.inputEnabled = true;     //接收事件this.btnPlay.events.onInputDown.addOnce(function(){ //鼠标点击事件j = 2;isStart = 1;Score.alpha = 1;});this.btnPlay.update = function(){if(isStart == 1){this.destroy();}};this.player = mt.create("player");var player = this.player;this.player.dt = 0;this.player.frameIndex = this.player.frame;var cutA = this.player.animations.add('cut', [0, 1, 2]);this.player.animations.add('gif', [0, 7]);this.player.animations.add('die',[12,11,10,4,3,8,9,6,5],10,false);cutA.onComplete.add(function(){player.animations.play('gif',5,true);}, this);this.player.anchor.set(0.5,0);this.player.leftX = 184;this.player.rightX = 354;this.player.x = this.player.leftX;this.player.update = function(){
//    this.dt++;
//    if(this.dt % 10 === 0){
//     if(this.frameIndex === 0){
//      //console.log("a");
//      this.frameIndex = 7;
//     } else {
//      //console.log("b");
//      this.frameIndex = 0;
//     }
//    }
//    this.frame = this.frameIndex;//播放人物常态动画if(isStart == 1){if (j <= 1) return false;if (game.input.activePointer.isDown){//游戏内鼠标点击if(game.input.activePointer.x < game.world.centerX){this.x = this.leftX;this.scaleX = 1;} else {this.x = this.rightX;this.scaleX = -1;}//this.animations.play('cut');cutA.play(10,false);}}};this.gameOver = mt.create("gameOver");this.gameOver.alpha = 0;this.gameOver.getData().userData.score = 0;this.gameOver.update = function(){if(isStart !== 2) {return false}if(isStart == 2){Score.destroy();this.mt.children.gameCase.setText(this.getData().userData.case);this.mt.children.gameScore.setText(this.getData().userData.score);this.mt.children.gameCase.x = game.world.centerX;this.mt.children.gameScore.x = game.world.centerX;this.alpha = 0.9;if(this.getData().userData.case == "Lost"){//死亡动画player.scaleY = 1;//player.frame = 5;player.animations.play('die');}isStart = 3;}};this.gameOver.mt.children.btnRetry.inputEnabled = true;this.gameOver.mt.children.btnRetry.events.onInputDown.addOnce(function(){game.state.start("demo");},this);var gameOver = this.gameOver;this.time = mt.create("time");this.time.alpha = 0;this.time.update = function(){if(isStart == 1){this.alpha = 1;this.mt.children.top.width--;if(this.mt.children.top.width <= 0){this.alpha = 0;gameOver.getData().userData.case = "Lost";isStart = 2;}}if(isStart == 2){this.alpha = 0;}};var dx1 = 0,dx2 = 0;game.input.onDown.add(function(){if(isStart == 1){//游戏内鼠标点击if(game.input.activePointer.x < game.world.centerX){//leftdx1 = 50;dx2 = 100;} else {//rightdx1 = -50;dx2 = -100;}for(var i = 1;i < this.tree.length;i++){if(this.tree.getChildAt(i).y + this.tree.getChildAt(i).height >= this.tree.getChildAt(0).y){//创建动画var animation = game.add.image(this.tree.getChildAt(i).x,this.tree.getChildAt(i).y,"");animation.texture = this.tree.getChildAt(i).texture;tweenA = game.add.tween(animation).to( { x: animation.x + dx1,y: animation.y - 50  }, 300, "Linear");tweenB = game.add.tween(animation).to( { x: animation.x + dx2,y: animation.y + 50 }, 300, "Linear");        //缓动动画tweenB.onComplete.add(function(){animation.destroy();},this);tweenA.chain(tweenB);tweenA.start(); /播放动画//销毁树桩上的一段木头this.tree.getChildAt(i).destroy();//游戏得分递增this.gameOver.getData().userData.score++;this.time.mt.children.top.width += 5;if(this.gameOver.getData().userData.score == 49){this.gameOver.getData().userData.case = "Win";isStart = 2;}} }for(var i = 1;i < this.tree.length;i++){//被砍往下掉this.tree.getChildAt(i).y += 57;if(this.tree.getChildAt(i).y + this.tree.getChildAt(i).height >= this.tree.getChildAt(0).y){//防止越界this.tree.getChildAt(i).y = this.tree.getChildAt(0).y - this.tree.getChildAt(i).height;}}}},this);},update:function(){if(isStart !== 1) return false;this.Score.text = this.gameOver.getData().userData.score;var gameOver = this.gameOver;this.game.physics.arcade.overlap(this.player,this.tree,function(){//console.log("游戏结束");gameOver.getData().userData.case = "Lost";isStart = 2;});}
};

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

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

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

相关文章:

伐木猪小游戏

欢迎来到程序小院 伐木猪 玩法&#xff1a;控制小猪点击屏幕左右砍树&#xff0c;不能碰到树枝&#xff0c;考验手速与眼力&#xff0c;记录分数&#xff0c;快去挑战伐木吧^^。开始游戏https://www.ormcc.com/play/gameStart/199 html <script type"text/javascript…...

0007Java安卓程序设计-ssm基于Android的校园新闻管理系统

文章目录 **摘** **要**目 录开发环境 编程技术交流、源码分享、模板分享、网课教程 &#x1f427;裙&#xff1a;776871563 摘 要 网络的广泛应用给生活带来了十分的便利。所以把校园新闻管理与现在网络相结合&#xff0c;利用java技术建设校园新闻管理系统app&#xff0c;实…...

git增加右键菜单

有次不小心清理系统垃圾&#xff0c;把git右击菜单搞没了&#xff0c;下面是恢复方法 将下面代码存为.reg文件&#xff0c;双击后导出生效&#xff0c;注意&#xff0c;你安装的git必须是默认C盘的&#xff0c;如果换了地方要改下面注册表文件中相关的位置 Windows Registry …...

openGauss学习笔记-117 openGauss 数据库管理-设置数据库审计-查看审计结果

文章目录 openGauss学习笔记-117 openGauss 数据库管理-设置数据库审计-查看审计结果117.1 前提条件117.2 背景信息117.3 操作步骤 openGauss学习笔记-117 openGauss 数据库管理-设置数据库审计-查看审计结果 117.1 前提条件 审计功能总开关已开启。需要审计的审计项开关已开…...

学习代码20231106

解释代码&#xff1a;os.environ[“OMP_NUM_THREADS“] “1“ 这行代码涉及到 Python 的 os 模块和环境变量。它的作用是设置名为 “OMPNUMTHREADS” 的环境变量的值为 “1”。让我解释一下各部分的含义&#xff1a; 1.os.environ: 这是 Python 中的一个字典&#xff0c;包含…...

turtle绘制分形树-第10届蓝桥杯省赛Python真题精选

[导读]&#xff1a;超平老师的Scratch蓝桥杯真题解读系列在推出之后&#xff0c;受到了广大老师和家长的好评&#xff0c;非常感谢各位的认可和厚爱。作为回馈&#xff0c;超平老师计划推出《Python蓝桥杯真题解析100讲》&#xff0c;这是解读系列的第5讲。 turtle绘制分形树&…...

【大厂招聘试题】__硬件工程师_2021年“美团”校招

目录 匹配职位&#xff1a;硬件工程师 1.&#xff08;多选题&#xff09;单处理系统中&#xff0c;进程P1,P2,P3处于就绪队列&#xff0c;进程P4&#xff0c;P6处于等待队列&#xff0c;P5正占用处理器运行&#xff0c;以下对接下来的运行合理的分析是&#xff08; &#xff…...

算法通关村第七关|黄金挑战|迭代实现二叉树的前、中、后序遍历

1.迭代实现前序遍历 public List<Integer> preOrderTraversal(TreeNode root) {List<Integer> res new ArrayList<Integer>();if (root null) {return res;}Deque<TreeNode> stack new LinkedList<TreeNode>();TreeNode node root;while (!…...

了解高防服务器的工作原理

在当今互联网时代&#xff0c;网络安全问题日益突出&#xff0c;各种网络攻击层出不穷。为了保护企业的网络安全&#xff0c;高防服务器应运而生。那么&#xff0c;你是否了解高防服务器的工作原理呢?下面就让我们一起来探索一下。 高防服务器是一种能够有效抵御各种网络攻击的…...

AVL树性质和实现

AVL树 AVL是两名俄罗斯数学家的名字&#xff0c;以此纪念 与二叉搜索树的区别 AVL树在二叉搜索树的基础上增加了新的限制&#xff1a;需要时刻保证每个树中每个结点的左右子树高度之差的绝对值不超过1 因此&#xff0c;当向树中插入新结点后&#xff0c;即可降低树的高度&…...

出口贸易媒体发稿推广6个技巧提升品牌知名度-华媒舍

1. 出口贸易媒体介绍 出口贸易媒体是指专注于报道国际贸易、跨境业务和进出口市场的媒体平台。这些媒体对于企业发展来说至关重要&#xff0c;可以帮助品牌扩大影响力、提升知名度&#xff0c;促进商业合作。下面介绍6个出口贸易媒体发稿推广技巧&#xff0c;帮助企业更好地利…...

学习笔记:CANOE模拟LIN主节点和实际从节点进行通信测试

先写点感想&#xff0c;在LIN开发阶段&#xff0c;我一般用图莫斯USB工具来进行模拟主机节点发送数据。后来公司买了CANOE工具就边学习边搭建了LIN的测试工程&#xff0c;网上的资料真的很少&#xff0c;主要是靠自己一点点摸索前进&#xff0c;总算入门。几个月后的今天&#…...

模型可解释性

模型可解释性 前言导读Background1、为什么需要可解释性&#xff1f;2、诞生背景3、研究现状4、常见的模型可解释性方法4.1 基于模型自身的可解释性1&#xff09;Explanation Generation2&#xff09;Prototype Network 4.2 基于结果的可解释性 5、应用前景6、面临挑战 前言导读…...

Django初窥门径-自定义用户模型

前言 自定义用户模型在Django应用中是一个重要的话题&#xff0c;它涉及到如何根据您的项目需求以及特定的用户身份验证和授权需求来调整用户模型。在以下前言中&#xff0c;我将讲述为什么自定义用户模型是如此重要以及其潜在的优势&#xff1a; 随着Web应用的不断发展&…...

微信小程序文件上传wx.uploadFile

网页版查看了一下负载要求是这样 wx.uploadFile({url: ${wx.getStorageSync(apiUrl)}//sysFileInfo/upload?token${wx.getStorageSync(token)}, // 仅为示例&#xff0c;非真实的接口地址filePath: files[0].url,name: file,formData: {secretFlag: Y },success: (res) > {…...

支持内录系统声音的Mac录屏软件Omi Recorder

Screen Recorder by Omi是一款功能强大的屏幕录制应用程序。它可用于在Windows和Mac计算机上捕获屏幕&#xff0c;以便进行演示、教程、游戏录制、视频编辑等各种用途。 以下是该应用程序的一些主要特点&#xff1a; 支持高清录制&#xff1a;Omi Screen Recorder可以以高达6…...

一、Hadoop初始化配置(final+ubuntu保姆级教程)

1、配置虚拟机 三台虚拟机&#xff0c;分别为node1、node2、node3&#xff0c;内存分别为4G、2G、2G&#xff0c;现存最好为&#xff08;>40G&#xff09;&#xff0c;如下&#xff1a; 2、修改主机名 分别打开三台虚拟机&#xff0c;root用户输入一下命令&#xff1a; no…...

Linux常用的包管理工具

Linux系统中有两个常用的包管理工具&#xff0c;分别是yum和apt。 1. yum命令 yum是Red Hat公司开发的一种包管理器&#xff0c;主要用于安装、更新、卸载和管理RPM包。它是基于RPM包管理系统的&#xff0c;可以自动解决软件包依赖关系问题。 常用yum命令&#xff1a; - 安…...

python随机生成指定长度的字符串

需求&#xff1a;随机生成一个指定长度的字符串&#xff08;数字和小写字母&#xff09; 涉及到的python知识点 &#xff08;1&#xff09;python模块包&#xff1a;random random.choice(sequence)&#xff1a;从指定的序列中获取一个随机元素 random.choice(sequence)从序…...

语音识别接口试用

语音识别结果对比 1.jonatasgrosman/wav2vec2-large-xlsr-53-chinese-zh-cn 啊五包你没有什么问题嗓局问的这老受刚来指伯间我想就了解其二联地完觉全没问题犹该奖姐家女标要等到老师主动据奖定练择因位我主要奖的是耶号联接最长加展们如果说宁士比到六点级到一到另年级的家长…...

Zustand 状态管理库:极简而强大的解决方案

Zustand 是一个轻量级、快速和可扩展的状态管理库&#xff0c;特别适合 React 应用。它以简洁的 API 和高效的性能解决了 Redux 等状态管理方案中的繁琐问题。 核心优势对比 基本使用指南 1. 创建 Store // store.js import create from zustandconst useStore create((set)…...

R语言AI模型部署方案:精准离线运行详解

R语言AI模型部署方案:精准离线运行详解 一、项目概述 本文将构建一个完整的R语言AI部署解决方案,实现鸢尾花分类模型的训练、保存、离线部署和预测功能。核心特点: 100%离线运行能力自包含环境依赖生产级错误处理跨平台兼容性模型版本管理# 文件结构说明 Iris_AI_Deployme…...

Java如何权衡是使用无序的数组还是有序的数组

在 Java 中,选择有序数组还是无序数组取决于具体场景的性能需求与操作特点。以下是关键权衡因素及决策指南: ⚖️ 核心权衡维度 维度有序数组无序数组查询性能二分查找 O(log n) ✅线性扫描 O(n) ❌插入/删除需移位维护顺序 O(n) ❌直接操作尾部 O(1) ✅内存开销与无序数组相…...

前端导出带有合并单元格的列表

// 导出async function exportExcel(fileName "共识调整.xlsx") {// 所有数据const exportData await getAllMainData();// 表头内容let fitstTitleList [];const secondTitleList [];allColumns.value.forEach(column > {if (!column.children) {fitstTitleL…...

【大模型RAG】Docker 一键部署 Milvus 完整攻略

本文概要 Milvus 2.5 Stand-alone 版可通过 Docker 在几分钟内完成安装&#xff1b;只需暴露 19530&#xff08;gRPC&#xff09;与 9091&#xff08;HTTP/WebUI&#xff09;两个端口&#xff0c;即可让本地电脑通过 PyMilvus 或浏览器访问远程 Linux 服务器上的 Milvus。下面…...

python如何将word的doc另存为docx

将 DOCX 文件另存为 DOCX 格式&#xff08;Python 实现&#xff09; 在 Python 中&#xff0c;你可以使用 python-docx 库来操作 Word 文档。不过需要注意的是&#xff0c;.doc 是旧的 Word 格式&#xff0c;而 .docx 是新的基于 XML 的格式。python-docx 只能处理 .docx 格式…...

Springcloud:Eureka 高可用集群搭建实战(服务注册与发现的底层原理与避坑指南)

引言&#xff1a;为什么 Eureka 依然是存量系统的核心&#xff1f; 尽管 Nacos 等新注册中心崛起&#xff0c;但金融、电力等保守行业仍有大量系统运行在 Eureka 上。理解其高可用设计与自我保护机制&#xff0c;是保障分布式系统稳定的必修课。本文将手把手带你搭建生产级 Eur…...

成都鼎讯硬核科技!雷达目标与干扰模拟器,以卓越性能制胜电磁频谱战

在现代战争中&#xff0c;电磁频谱已成为继陆、海、空、天之后的 “第五维战场”&#xff0c;雷达作为电磁频谱领域的关键装备&#xff0c;其干扰与抗干扰能力的较量&#xff0c;直接影响着战争的胜负走向。由成都鼎讯科技匠心打造的雷达目标与干扰模拟器&#xff0c;凭借数字射…...

vue3+vite项目中使用.env文件环境变量方法

vue3vite项目中使用.env文件环境变量方法 .env文件作用命名规则常用的配置项示例使用方法注意事项在vite.config.js文件中读取环境变量方法 .env文件作用 .env 文件用于定义环境变量&#xff0c;这些变量可以在项目中通过 import.meta.env 进行访问。Vite 会自动加载这些环境变…...

什么是Ansible Jinja2

理解 Ansible Jinja2 模板 Ansible 是一款功能强大的开源自动化工具&#xff0c;可让您无缝地管理和配置系统。Ansible 的一大亮点是它使用 Jinja2 模板&#xff0c;允许您根据变量数据动态生成文件、配置设置和脚本。本文将向您介绍 Ansible 中的 Jinja2 模板&#xff0c;并通…...