当前位置: 首页 > 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 啊五包你没有什么问题嗓局问的这老受刚来指伯间我想就了解其二联地完觉全没问题犹该奖姐家女标要等到老师主动据奖定练择因位我主要奖的是耶号联接最长加展们如果说宁士比到六点级到一到另年级的家长…...

12.找到字符串中所有字母异位词

&#x1f9e0; 题目解析 题目描述&#xff1a; 给定两个字符串 s 和 p&#xff0c;找出 s 中所有 p 的字母异位词的起始索引。 返回的答案以数组形式表示。 字母异位词定义&#xff1a; 若两个字符串包含的字符种类和出现次数完全相同&#xff0c;顺序无所谓&#xff0c;则互为…...

爬虫基础学习day2

# 爬虫设计领域 工商&#xff1a;企查查、天眼查短视频&#xff1a;抖音、快手、西瓜 ---> 飞瓜电商&#xff1a;京东、淘宝、聚美优品、亚马逊 ---> 分析店铺经营决策标题、排名航空&#xff1a;抓取所有航空公司价格 ---> 去哪儿自媒体&#xff1a;采集自媒体数据进…...

Spring AI与Spring Modulith核心技术解析

Spring AI核心架构解析 Spring AI&#xff08;https://spring.io/projects/spring-ai&#xff09;作为Spring生态中的AI集成框架&#xff0c;其核心设计理念是通过模块化架构降低AI应用的开发复杂度。与Python生态中的LangChain/LlamaIndex等工具类似&#xff0c;但特别为多语…...

在QWebEngineView上实现鼠标、触摸等事件捕获的解决方案

这个问题我看其他博主也写了&#xff0c;要么要会员、要么写的乱七八糟。这里我整理一下&#xff0c;把问题说清楚并且给出代码&#xff0c;拿去用就行&#xff0c;照着葫芦画瓢。 问题 在继承QWebEngineView后&#xff0c;重写mousePressEvent或event函数无法捕获鼠标按下事…...

华为OD机考-机房布局

import java.util.*;public class DemoTest5 {public static void main(String[] args) {Scanner in new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextLine()) { // 注意 while 处理多个 caseSystem.out.println(solve(in.nextLine()));}}priv…...

打手机检测算法AI智能分析网关V4守护公共/工业/医疗等多场景安全应用

一、方案背景​ 在现代生产与生活场景中&#xff0c;如工厂高危作业区、医院手术室、公共场景等&#xff0c;人员违规打手机的行为潜藏着巨大风险。传统依靠人工巡查的监管方式&#xff0c;存在效率低、覆盖面不足、判断主观性强等问题&#xff0c;难以满足对人员打手机行为精…...

Unity中的transform.up

2025年6月8日&#xff0c;周日下午 在Unity中&#xff0c;transform.up是Transform组件的一个属性&#xff0c;表示游戏对象在世界空间中的“上”方向&#xff08;Y轴正方向&#xff09;&#xff0c;且会随对象旋转动态变化。以下是关键点解析&#xff1a; 基本定义 transfor…...

TCP/IP 网络编程 | 服务端 客户端的封装

设计模式 文章目录 设计模式一、socket.h 接口&#xff08;interface&#xff09;二、socket.cpp 实现&#xff08;implementation&#xff09;三、server.cpp 使用封装&#xff08;main 函数&#xff09;四、client.cpp 使用封装&#xff08;main 函数&#xff09;五、退出方法…...

AWS vs 阿里云:功能、服务与性能对比指南

在云计算领域&#xff0c;Amazon Web Services (AWS) 和阿里云 (Alibaba Cloud) 是全球领先的提供商&#xff0c;各自在功能范围、服务生态系统、性能表现和适用场景上具有独特优势。基于提供的引用[1]-[5]&#xff0c;我将从功能、服务和性能三个方面进行结构化对比分析&#…...

Git 命令全流程总结

以下是从初始化到版本控制、查看记录、撤回操作的 Git 命令全流程总结&#xff0c;按操作场景分类整理&#xff1a; 一、初始化与基础操作 操作命令初始化仓库git init添加所有文件到暂存区git add .提交到本地仓库git commit -m "提交描述"首次提交需配置身份git c…...