滑木块H5小游戏

news2024/9/30 7:32:37

欢迎来到程序小院

滑木块

玩法:点击木块横着的只能左右移动,竖着的只能上下移动,
移动到箭头的位置即过关,不同关卡不同的木块摆放,快去滑木块吧^^。

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

html

<canvas id="c2canvas" width="384" height="600"></canvas>

css

* {
  padding: 0;
  margin: 0;
}
body {
  background: #fff;
  color: #fff;
  overflow: hidden;
  -ms-touch-action: none;
}
canvas {
  touch-action-delay: none;
  touch-action: none;
  -ms-touch-action: none;
}

js

var sg_texts = {
  'en' : {
      'MORE GAMES' : '',
      'SLIDE GREEN BLOCK TO START': 'SLIDE GREEN BLOCK TO START',
      'MOVE:': 'MOVE:',
      'LEVEL:' : 'LEVEL:',
      'BEST:' : 'BEST:',
      'TIME:' : 'TIME:'
  },
  'es' : {
      'MORE GAMES' : 'MAS JUEGOS',
      'SLIDE GREEN BLOCK TO START' : 'DESLIZA EL BLOQUE VERDE PARA EMPEZAR',
      'MOVE:': 'MOVER:',
      'LEVEL:' : 'NIVEL:',
      'BEST:' : 'MEJOR:',
      'TIME:' : 'TIEMPO:'
  }
};
var cr = {};
cr.plugins_ = {};
cr.behaviors = {};
// SG.detectPortalUrl();

if (typeof Object.getPrototypeOf !== "function")
{
 if (typeof "test".__proto__ === "object")
 {
  Object.getPrototypeOf = function(object) {
   return object.__proto__;
  };
 }
 else
 {
  Object.getPrototypeOf = function(object) {
   return object.constructor.prototype;
  };
 }
}
(function(){
 cr.logexport = function (msg)
 {
  if (window.console && window.console.log)
   window.console.log(msg);
 };
 cr.seal = function(x)
 {
  return x;
 };
 cr.freeze = function(x)
 {
  return x;
 };
 cr.is_undefined = function (x)
 {
  return typeof x === "undefined";
 };
 cr.is_number = function (x)
 {
  return typeof x === "number";
 };
 cr.is_string = function (x)
 {
  return typeof x === "string";
 };
 cr.isPOT = function (x)
 {
  return x > 0 && ((x - 1) & x) === 0;
 };
 cr.nextHighestPowerOfTwo = function(x) {
  --x;
  for (var i = 1; i < 32; i <<= 1) {
   x = x | x >> i;
  }
  return x + 1;
 }
 cr.abs = function (x)
 {
  return (x < 0 ? -x : x);
 };
 cr.max = function (a, b)
 {
  return (a > b ? a : b);
 };
 cr.min = function (a, b)
 {
  return (a < b ? a : b);
 };
 cr.PI = Math.PI;
 cr.round = function (x)
 {
  return (x + 0.5) | 0;
 };
 cr.floor = function (x)
 {
  if (x >= 0)
   return x | 0;
  else
   return (x | 0) - 1;  // correctly round down when negative
 };
 cr.ceil = function (x)
 {
  var f = x | 0;
  return (f === x ? f : f + 1);
 };
 function Vector2(x, y)
 {
  this.x = x;
  this.y = y;
  cr.seal(this);
 };
 Vector2.prototype.offset = function (px, py)
 {
  this.x += px;
  this.y += py;
  return this;
 };
 Vector2.prototype.mul = function (px, py)
 {
  this.x *= px;
  this.y *= py;
  return this;
 };
 cr.vector2 = Vector2;
 cr.segments_intersect = function(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y)
 {
  var max_ax, min_ax, max_ay, min_ay, max_bx, min_bx, max_by, min_by;
  if (a1x < a2x)
  {
   min_ax = a1x;
   max_ax = a2x;
  }
  else
  {
   min_ax = a2x;
   max_ax = a1x;
  }
  if (b1x < b2x)
  {
   min_bx = b1x;
   max_bx = b2x;
  }
  else
  {
   min_bx = b2x;
   max_bx = b1x;
  }
  if (max_ax < min_bx || min_ax > max_bx)
   return false;
  if (a1y < a2y)
  {
   min_ay = a1y;
   max_ay = a2y;
  }
  else
  {
   min_ay = a2y;
   max_ay = a1y;
  }
  if (b1y < b2y)
  {
   min_by = b1y;
   max_by = b2y;
  }
  else
  {
   min_by = b2y;
   max_by = b1y;
  }
  if (max_ay < min_by || min_ay > max_by)
   return false;
  var dpx = b1x - a1x + b2x - a2x;
  var dpy = b1y - a1y + b2y - a2y;
  var qax = a2x - a1x;
  var qay = a2y - a1y;
  var qbx = b2x - b1x;
  var qby = b2y - b1y;
  var d = cr.abs(qay * qbx - qby * qax);
  var la = qbx * dpy - qby * dpx;
  if (cr.abs(la) > d)
   return false;
  var lb = qax * dpy - qay * dpx;
  return cr.abs(lb) <= d;
 };
 function Rect(left, top, right, bottom)
 {
  this.set(left, top, right, bottom);
  cr.seal(this);
 };
 Rect.prototype.set = function (left, top, right, bottom)
 {
  this.left = left;
  this.top = top;
  this.right = right;
  this.bottom = bottom;
 };
 Rect.prototype.copy = function (r)
 {
  this.left = r.left;
  this.top = r.top;
  this.right = r.right;
  this.bottom = r.bottom;
 };
 Rect.prototype.width = function ()
 {
  return this.right - this.left;
 };
 Rect.prototype.height = function ()
 {
  return this.bottom - this.top;
 };
 Rect.prototype.offset = function (px, py)
 {
  this.left += px;
  this.top += py;
  this.right += px;
  this.bottom += py;
  return this;
 };
 Rect.prototype.normalize = function ()
 {
  var temp = 0;
  if (this.left > this.right)
  {
   temp = this.left;
   this.left = this.right;
   this.right = temp;
  }
  if (this.top > this.bottom)
  {
   temp = this.top;
   this.top = this.bottom;
   this.bottom = temp;
  }
 };
 Rect.prototype.intersects_rect = function (rc)
 {
  return !(rc.right < this.left || rc.bottom < this.top || rc.left > this.right || 
    rc.top > this.bottom);
 };
 Rect.prototype.intersects_rect_off = function (rc, ox, oy)
 {
  return !(rc.right + ox < this.left || rc.bottom + oy < this.top || rc.left + ox > 
    this.right || rc.top + oy > this.bottom);
 };
 Rect.prototype.contains_pt = function (x, y)
 {
  return (x >= this.left && x <= this.right) && (y >= this.top && y <= this.bottom);
 };
 Rect.prototype.equals = function (r)
 {
  return this.left === r.left && this.top === r.top && this.right === r.right && 
    this.bottom === r.bottom;
 };
 cr.rect = Rect;
 function Quad()
 {
  this.tlx = 0;
  this.tly = 0;
  this.trx = 0;
  this.try_ = 0; // is a keyword otherwise!
  this.brx = 0;
  this.bry = 0;
  this.blx = 0;
  this.bly = 0;
  cr.seal(this);
 };
 Quad.prototype.set_from_rect = function (rc)
 {
  this.tlx = rc.left;
  this.tly = rc.top;
  this.trx = rc.right;
  this.try_ = rc.top;
  this.brx = rc.right;
  this.bry = rc.bottom;
  this.blx = rc.left;
  this.bly = rc.bottom;
 };
 Quad.prototype.set_from_rotated_rect = function (rc, a)
 {
  if (a === 0)
  {
   this.set_from_rect(rc);
  }
  else
  {
   var sin_a = Math.sin(a);
   var cos_a = Math.cos(a);
   var left_sin_a = rc.left * sin_a;
   var top_sin_a = rc.top * sin_a;
   var right_sin_a = rc.right * sin_a;
   var bottom_sin_a = rc.bottom * sin_a;
   var left_cos_a = rc.left * cos_a;
   var top_cos_a = rc.top * cos_a;
   var right_cos_a = rc.right * cos_a;
   var bottom_cos_a = rc.bottom * cos_a;
   this.tlx = left_cos_a - top_sin_a;
   this.tly = top_cos_a + left_sin_a;
   this.trx = right_cos_a - top_sin_a;
   this.try_ = top_cos_a + right_sin_a;
   this.brx = right_cos_a - bottom_sin_a;
   this.bry = bottom_cos_a + right_sin_a;
   this.blx = left_cos_a - bottom_sin_a;
   this.bly = bottom_cos_a + left_sin_a;
  }
 };
 Quad.prototype.offset = function (px, py)
 {
  this.tlx += px;
  this.tly += py;
  this.trx += px;
  this.try_ += py;
  this.brx += px;
  this.bry += py;
  this.blx += px;
  this.bly += py;
  return this;
 };
 var minresult = 0;
 var maxresult = 0;
 function minmax4(a, b, c, d)
 {
  if (a < b)
  {
   if (c < d)
   {
    if (a < c)
     minresult = a;
    else
     minresult = c;
    if (b > d)
     maxresult = b;
    else
     maxresult = d;
   }
   else
   {
    if (a < d)
     minresult = a;
    else
     minresult = d;
    if (b > c)
     maxresult = b;
    else
     maxresult = c;
   }
  }
  else
  {
   if (c < d)
   {
    if (b < c)
     minresult = b;
    else
     minresult = c;
    if (a > d)
     maxresult = a;
    else
     maxresult = d;
   }
   else
   {
    if (b < d)
     minresult = b;
    else
     minresult = d;
    if (a > c)
     maxresult = a;
    else
     maxresult = c;
   }
  }
 };
 Quad.prototype.bounding_box = function (rc)
 {
  minmax4(this.tlx, this.trx, this.brx, this.blx);
  rc.left = minresult;
  rc.right = maxresult;
  minmax4(this.tly, this.try_, this.bry, this.bly);
  rc.top = minresult;
  rc.bottom = maxresult;
 };
 Quad.prototype.contains_pt = function (x, y)
 {
  var v0x = this.trx - this.tlx;
  var v0y = this.try_ - this.tly;
  var v1x = this.brx - this.tlx;
  var v1y = this.bry - this.tly;
  var v2x = x - this.tlx;
  var v2y = y - this.tly;
  var dot00 = v0x * v0x + v0y * v0y
  var dot01 = v0x * v1x + v0y * v1y
  var dot02 = v0x * v2x + v0y * v2y
  var dot11 = v1x * v1x + v1y * v1y
  var dot12 = v1x * v2x + v1y * v2y
  var invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
  var u = (dot11 * dot02 - dot01 * dot12) * invDenom;
  var v = (dot00 * dot12 - dot01 * dot02) * invDenom;
  if ((u >= 0.0) && (v > 0.0) && (u + v < 1))
   return true;
  v0x = this.blx - this.tlx;
  v0y = this.bly - this.tly;
  var dot00 = v0x * v0x + v0y * v0y
  var dot01 = v0x * v1x + v0y * v1y
  var dot02 = v0x * v2x + v0y * v2y
  invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
  u = (dot11 * dot02 - dot01 * dot12) * invDenom;
  v = (dot00 * dot12 - dot01 * dot02) * invDenom;
  return (u >= 0.0) && (v > 0.0) && (u + v < 1);
 };
 Quad.prototype.at = function (i, xory)
 {
  if (xory)
  {
   switch (i)
   {
    case 0: return this.tlx;
    case 1: return this.trx;
    case 2: return this.brx;
    case 3: return this.blx;
    case 4: return this.tlx;
    default: return this.tlx;
   }
  }
  else
  {
   switch (i)
   {
    case 0: return this.tly;
    case 1: return this.try_;
    case 2: return this.bry;
    case 3: return this.bly;
    case 4: return this.tly;
    default: return this.tly;
   }
  }
 };
 Quad.prototype.midX = function ()
 {
  return (this.tlx + this.trx  + this.brx + this.blx) / 4;
 };
 Quad.prototype.midY = function ()
 {
  return (this.tly + this.try_ + this.bry + this.bly) / 4;
 };
 Quad.prototype.intersects_segment = function (x1, y1, x2, y2)
 {
  if (this.contains_pt(x1, y1) || this.contains_pt(x2, y2))
   return true;
  var a1x, a1y, a2x, a2y;
  var i;
  for (i = 0; i < 4; i++)
  {
   a1x = this.at(i, true);
   a1y = this.at(i, false);
   a2x = this.at(i + 1, true);
   a2y = this.at(i + 1, false);
   if (cr.segments_intersect(x1, y1, x2, y2, a1x, a1y, a2x, a2y))
    return true;
  }
  return false;
 };
 Quad.prototype.intersects_quad = function (rhs)
 {
  var midx = rhs.midX();
  var midy = rhs.midY();
  if (this.contains_pt(midx, midy))
   return true;
  midx = this.midX();
  midy = this.midY();
  if (rhs.contains_pt(midx, midy))
   return true;
  var a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y;
  var i, j;
  for (i = 0; i < 4; i++)
  {
   for (j = 0; j < 4; j++)
   {
    a1x = this.at(i, true);
    a1y = this.at(i, false);
    a2x = this.at(i + 1, true);
    a2y = this.at(i + 1, false);
    b1x = rhs.at(j, true);
    b1y = rhs.at(j, false);
    b2x = rhs.at(j + 1, true);
    b2y = rhs.at(j + 1, false);
    if (cr.segments_intersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y))
     return true;
   }
  }
  return false;
 };

源码

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

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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1413704.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

JavaEE 网络编程

JavaEE 网络编程 文章目录 JavaEE 网络编程引子1. 网络编程-相关概念1.1 基本概念1.2 发送端和接收端1.3 请求和响应1.4 客户端和服务端 2. Socket 套接字2.1 数据包套接字通信模型2.2 流套接字通信模型2.3 Socket编程注意事项 3. UDP数据报套接字编程3.1 DatagramSocket3.2 Da…

pip 安装出现报错 SSLError(SSLError(“bad handshake

即使设置了清华源&#xff1a; pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simplepip 安装包不能配置清华源&#xff0c;出现报错: Retrying (Retry(total2, connectNone, readNone, redirectNone, statusNone)) after connection broken by ‘SSLE…

适用于 Windows 的 10 款免费 MP4 转 MP3 转换神器

每当我们观看歌曲或视频剪辑时&#xff0c;我们经常会想到将其转换为 MP3 格式&#xff0c;以便我们可以将其保存在设备上&#xff0c;因为它占用的空间更少。在将 MP4 转换为 MP3 的过程中&#xff0c;第一步也是最重要的一步是选择正确的工具来转换它&#xff0c;如果您想添加…

API网关-Apisix RPM包方式自动化安装配置教程

文章目录 前言一、简介1. etcd简介2. APISIX简介3. apisix-dashboard简介 二、Apisix安装教程1. 复制脚本2. 增加执行权限3. 执行脚本4. 浏览器访问5. 卸载Apisix 三、命令1. Apisix命令1.1 启动apisix服务1.2 停止apisix服务1.3 优雅地停止apisix服务1.4 重启apisix服务1.5 重…

SG-8506CA 可编程晶体振荡器 (SPXO)

输出: LV-PECL频率范围: 50MHz ~ 800MHz电源电压: 2.5V to 3.3V外部尺寸规格: 7.0 5.0 1.5mm (8引脚)特性:用户指定一个起始频率, 7-bit I2C 地址:用户可编程: I2C 接口:基频的高频晶体:低抖动PLL技术应用:OTN, BTS, 测试设备 规格&#xff08;特征&#xff09; *1 这包括初…

链表--543. 二叉树的直径/medium 理解度C

543. 二叉树的直径 1、题目2、题目分析3、复杂度最优解代码示例4、适用场景 1、题目 给你一棵二叉树的根节点&#xff0c;返回该树的 直径 。 二叉树的 直径 是指树中任意两个节点之间最长路径的 长度 。这条路径可能经过也可能不经过根节点 root 。 两节点之间路径的 长度 …

Python Flask与APScheduler构建简易任务监控

1. Flask Web Flask诞生于2010年&#xff0c;是用Python语言&#xff0c;基于Werkzeug工具箱编写的轻量级、灵活的Web开发框架&#xff0c;非常适合初学者或小型到中型的 Web 项目。 Flask本身相当于一个内核&#xff0c;其他几乎所有的功能都要用到扩展&#xff08;邮件扩展…

案例分享 | 助力数字化转型:嘉为科技项目管理平台上线

嘉为科技项目管理平台&#xff08;一期&#xff09;基于易趋&#xff08;EasyTrack&#xff09;进行实施&#xff0c;通过近一年的开发及试运行&#xff0c;现已成功交付上线、推广使用&#xff0c;取得了良好的应用效果。 1.关于广州嘉为科技有限公司&#xff08;以下简称嘉为…

外卖跑腿系统开发:构建高效、安全的服务平台

在当今快节奏的生活中&#xff0c;外卖跑腿系统的开发已成为技术领域的一个重要课题。本文将介绍如何使用一些常见的编程语言和技术框架&#xff0c;构建一个高效、安全的外卖跑腿系统。 1. 技术选择 在开始开发之前&#xff0c;我们需要选择适合的技术栈。常用的技术包括&a…

idea使用注释时如何不从行首开始

1、File—>setting 2、找到Editor&#xff0c;点Code Style 1.对于java注释设置 点java&#xff0c;然后选择Code Generation,去掉Line comment at first column,选择Add a space at comment start 2.对于xml注释设置 点XML&#xff0c;然后选择Code Generation,去掉Line c…

java-数组(以及jvm的内存分布)

文章目录 数组的基本概念数组的作用数组的创建以及初始化数组的创建数组的初始化 数组的使用数组中元素的访问遍历打印数组 数组是引用类型初始jvm的内存分布基本类型变量和引用类型变量的区别引用变量 认识null 数组的基本概念 数组可以看作是一种类型的集合我们在内存空间上…

Go 命令行解析 flag 包之快速上手

本篇文章是 Go 标准库 flag 包的快速上手篇。 概述 开发一个命令行工具&#xff0c;视复杂程度&#xff0c;一般要选择一个合适的命令行解析库&#xff0c;简单的需求用 Go 标准库 flag 就够了&#xff0c;flag 的使用非常简单。 当然&#xff0c;除了标准库 flag 外&#x…

Mac网线上网绿联扩展坞连接网线直接上网-无脑操作

声明&#xff1a;博主使用的绿联扩展坞 以下为绿联扩展坞Mac网线使用方法 1.首先需要下载电脑对应版本的驱动 直接点击即可下载 2. 下载好以后 解压 点进去 对应版本 博主直接使用最新的12-14 3. 安装包好了以后 会提示重启电脑 此时拔掉扩展坞 再重启动 拔掉扩展坞 再重启…

【Tomcat与网络1】史前时代—没有Spring该如何写Web服务

在前面我们介绍了网络与Java相关的问题&#xff0c; 最近在调研的时候发现这块内容其实非常复杂&#xff0c;涉及的内容多而且零碎&#xff0c;想短时间梳理出整个体系是不太可能的&#xff0c;所以我们还是继续看Tomcat的问题&#xff0c;后面有网络的内容继续补充吧。 目录 …

【python爬虫】爬虫编程技术的解密与实战

​&#x1f308;个人主页&#xff1a;Sarapines Programmer&#x1f525; 系列专栏&#xff1a; 爬虫】网络爬虫探秘⏰诗赋清音&#xff1a;云生高巅梦远游&#xff0c; 星光点缀碧海愁。 山川深邃情难晤&#xff0c; 剑气凌云志自修。 目录 &#x1f33c;实验目的 &#x1f…

Redis客户端之Jedis(一)介绍

目录 一、Jedis介绍&#xff1a; 1、背景&#xff1a; 2、Jedis连接池介绍&#xff1a; 二、Jedis API&#xff1a; 1、连接池API 2、其他常用API&#xff1a; 三、SpringBoot集成Jedis&#xff1a; 1、Redis集群模式&#xff1a; &#xff08;1&#xff09;配置文件…

如何用甘特图跟踪项目进度

甘特图是一个简单但是极其强大的项目管理工具,能够清晰可视化复杂项目的进度,在项目跟踪和控制上发挥重要作用。任何一个严肃的项目组织者都会使用甘特图来规划和管理项目中的任务。 甘特图的纵坐标表示项目的各项活动或任务,横坐标表示项目的时间进度。每个任务用一条横条表示…

杰理方案——WIFI连接物联网配置阿里云操作步骤

demo——DevKitBoard 注意:最好用这个Demo,其它Demo可能会有莫名其妙的错误问题。 wifi配置 需要在app_config.h文件中定义USE_DEMO_WIFI_TEST,工程会在wifi_demo_task.c文件中自动启动wifi相关的任务, 我们将工程配置为连接外部网络STA模式 默认工程会使用如下账号密码 这…

微信小程序 仿微信聊天界面

1. 需求效果图 2. 方案 为实现这样的效果&#xff0c;首先要解决两个问题&#xff1a; 2.1.点击输入框弹出软键盘后&#xff0c;将已有的少许聊天内容弹出&#xff0c;导致看不到的问题 点击输入框弹出软键盘后&#xff0c;将已有的少许聊天内容弹出&#xff0c;导致看不到的问…

2024新版68套Axure RP大数据可视化大屏模板及通用组件+PSD源文件

Axure RP数据可视化大屏模板及通用组件库2024新版重新制作了这套新的数据可视化大屏模板及通用组件库V2版。新版本相比于V1版内容更加丰富和全面&#xff0c;但依然秉承“敏捷易用”的制作理念&#xff0c;这套作品也同样延续着我们对细节的完美追求&#xff0c;整个设计制作过…