npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

open-game

v0.3.2

Published

<pre>npm i open-game --save</pre>

Downloads

4

Readme

open-game

Examples

Table of Contents

Actor

Actor 类

Parameters

  • game Game 游戏实例
  • size

Returns Actor Instance

reset

重置参数值

Returns void

update

更新参数值

Returns void

render

渲染自己

Returns void

aabb

碰撞判断

Parameters

Returns boolean

isItOn

给定一组 x, y判断是否在角色身上

Parameters

  • cX
  • cY

Returns boolean

isOut

判断是否已经出去在画布之外

Returns boolean

Game

Game 类

Parameters

  • canvas
  • Image Class 图片构造函数,浏览器下为 window.Image, node.js 下为 require('canvas').Image
  • width Number 期望的画布宽度,浏览器下全拼为 document.documentElement.clientWidth
  • height Number 期望的画布高度,浏览器下全拼为 document.documentElement.clientHeight
  • widthRange Array.Number? 画布宽度取值范围,不设置则宽度严格等于 width
  • heightRange Array.Number? 画布高度取值范围,不设置则宽度严格等于 heigth
  • convas Object DOM对象,或者node.js 下 require('canvas').createCanvas()

reset

重置游戏参数, 例如积分

Returns void

init

初始化并开始游戏

Parameters

  • resources Array.Object 游戏所需静态资源对象 key => value 格式, key 为资源名称,value为object,格式如下 { type: 'image', // audio, video, image name: 'name', // 资源名称,预加载后会存入 this.R 方便随时获取 url: 'https://urladress/', // 资源地址 map: 'https://urladress/' // 图片资源对应的定位信息文件, 仅 type = image 有效 }

Returns void

progress

显示资源加载 loading 效果

Parameters

  • percent
  • resources Array.URL 游戏所需静态资源url列表

Returns void

loadResources

加载游戏所需静态资源

Parameters

  • resources Array.Object 游戏所需静态资源对象 key => value 格式, key 为资源名称,value为object,格式如下 { type: 'image', // audio, video, image name: 'name', // 资源名称,预加载后会存入 this.R 方便随时获取 url: 'https://urladress/', // 资源地址 map: 'https://urladress/' // 图片资源对应的定位信息文件, 仅 type = image 有效 }

Returns void

drawImageAlignCenterByName

水平居中绘制图片获取图片切片

Parameters

Returns void

drawImageByName

绘制图片获取图片切片

Parameters

Returns void

registCallback

注册帧回调函数

Parameters

Returns void

Scene

Scene 类

Parameters

  • game Game 游戏实例
  • name

Returns Scene Instance

update

更新各成员

Returns void

render

渲染各成员

Returns void

enter

进入场景

Returns void

click

点击事件

Parameters

  • x
  • y

Returns void