当前位置: 首页 > 软件库 > 游戏/娱乐 > >

phaser-catch-the-cat

An HTML5 game 'Catch The Cat' powered by Phaser 3
授权协议 MIT License
开发语言 JavaScript
所属分类 游戏/娱乐
软件类型 开源软件
地区 不详
投 递 者 淳于涛
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

捉住小猫

开始游戏

游戏玩法

  • 点击小圆点,围住小猫。
  • 你点击一次,小猫走一次。
  • 直到你把小猫围住(赢),或者小猫走到边界并逃跑(输)。

部署

首先引入游戏框架 phaser.min.js

<script src="phaser.min.js"></script>

然后引入游戏代码 catch-the-cat.js

<script src="catch-the-cat.js"></script>

然后在指定的 div 中新建一个游戏的 canvas,并开始游戏

<div id="catch-the-cat"></div>
<script>
    window.game = new CatchTheCatGame({
        w: 11,
        h: 11,
        r: 20,
        backgroundColor: 0xeeeeee,
        parent: 'catch-the-cat',
        statusBarAlign: 'center',
        credit: 'github.com/ganlvtech'
    });
</script>

参数列表:

参数 说明
w 11 横向格子数
h 11 竖向格子数
r 20 圆半径像素

非必选参数:

参数 说明
backgroundColor 0xeeeeee 背景颜色
parent catch-the-cat 父元素的 id 或 DOM 对象
statusBarAlign center 状态栏左对齐 left 或居中 center
credit github.com/ganlvtech 右下角的备注信息

自己编写算法

参考 src/solvers/ 中提供的例子编写算法,并使用下列代码替换。

window.game.solver = yourSolver;

这个 solver 的返回值即为猫要往哪个方向走一步,如果撞墙则算玩家获胜

说明
-1 猫主动弃权
0
1 左上
2 右上
3
4 右下
5 左下

猫站在星号的位置,数字代表每个方向的编号

 1 2
0 * 3
 5 4

例如

window.game.solver = function (blocksIsWall, i, j) {
    return 0;
};

即:一直向左走,直到撞墙。

说明

  • 游戏的思路和小猫的图片来源于 www.gamedesign.jp,原来的游戏名叫 Chat Noir,我只是尝试用 javascript 重写一遍。

License

MIT License

  • 运行阶段性并发任务 Java 并发 API 提供的一个非常复杂且强大的功能是,能够使用Phaser类运行阶段性的并发任务。当某些并发任务是分成多个步骤来执行时,那么此机制是非常有用的。Phaser类提供的机制是在每个步骤的结尾同步线程,所以除非全部线程完成第一个步骤,否则线程不能开始进行第二步。 相对于其他同步应用,我们必须初始化Phaser类与这次同步操作有关的任务数,我们可以通过增加或者减少来

 相关资料
  • Phaser 是一个快速、免费、有趣的开源HTML5游戏框架,在桌面和移动网络浏览器上提供WebGL和Canvas渲染功能。游戏可以通过使用第三方工具编译成iOS、Android和本地应用程序。你可以使用JavaScript或TypeScript进行开发。

  • IonPhaser Web Component built with Stencil.js to integrate Phaser with any other framework. Inspired by the old IonPhaser directive Demo Do you want to see this web component in action? Visit https://

  • Phaser 2 Examples Looking for Phaser 3 Examples? They are in their own repo. Phaser v2 is a fast, free and fun open source HTML5 game framework. It uses Pixi.js for WebGL and Canvas rendering across d

  • Phaser CE (Community Edition) Phaser CE is a fast, free, and fun open source HTML5 game framework. It uses a custom build of Pixi.js for WebGL and Canvas rendering, and supports desktop and mobile web

  • expo-phaser Tools for using Phaser-ce to build native 2D games in Expo �� Installation Usage Functions Example Demo Installation yarn add expo-phaser Usage Import the library into your JavaScript file

  • Phaser 3 TypeScript Starter Template A starter template for Phaser 3 with TypeScript and webpack for building excellent html5-games that work great in the browser and on mobile devices. Key Features •