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

dmc-puzzle-game

v0.1.0

Published

puzzle game

Downloads

3

Readme

原生HTML+JS+CSS制作的拼图小游戏模块

原生的拼图小游戏,抽离成一个模块,参数可配置化,方便复用.

安装

npm install dmc-puzzle-game --save-prod

使用

// 引用
import PuzzleGame from "dmc-puzzle-game";
// 参数见下表
const option = {
    container: "main",
    img: "https://hm-wx.oss-cn-hangzhou.aliyuncs.com/1105295.jpeg",
    colNum: 5 * 1,
    rowNum: 3 * 1,
    isJumpDislocate: true,
    dislocateLevel: 2,
    isShowGap: false,
    gapWidth: 1,
    gapColor: "rgba(0,0,0,1)",
    isShowOverEndAnimation: true,
    isShowShadowContainer: true,
    isShowShadowCell: false,
    isShowMarkNumber: true,
    hidePuzzleCellPosition: "random",
 };
// 传入option初始化,返回game实例
const puzzleGame = new PuzzleGame(option);
// 监听游戏状态变化
puzzleGame.addEventListener("changeGameStatus", (status) => {
  // status 类型见下方代码
  console.log("status: ", status);
});
// 监听游戏所用步数变化
puzzleGame.addEventListener("changeStepCount", function (stepCount) {
  console.log("stepCount: ", stepCount);
});
// 开始游戏
game.start();
// 重置游戏, <option> 可选,覆盖初始化的参数
game.reset(<option>);

Option

| Key | Explanation | Type | Default | Required | | ---------------------- | ------------------------------------------------------------ | ----------------- | ------------- | -------- | | container | 游戏的容器元素,DOM 元素或 queryString. | DOM / queryString | null | true | | img | 要拼的图片的url | String | null | true | | colNum | 要分成几列 | Number[0-∞] | 3 | false | | rowNum | 要分成几行 | Number[0-∞] | 3 | false | | isJumpDislocate | 是否跳过打乱过程 | Boolean | true | false | | dislocateLevel | 打乱的级别 | Number[0-∞] | 3 | false | | isShowGap | 是否显示方块之间的间隙 | Boolean | false | false | | gapWidth | 间隙的宽度 | Number[0-∞] | 1(px) | false | | gapColor | 间隙的颜色 | String | rgba(0,0,0,1) | false | | isShowOverEndAnimation | 是否显示游戏结束过场效果 | Boolean | true | false | | isShowShadowContainer | 是否显示容器元素的内阴影 | Boolean | true | false | | isShowShadowCell | 是否显示方块元素的内阴影 | Boolean | false | false | | isShowMarkNumber | 是否显示标记数字 | Boolean | true | false | | hidePuzzleCellPosition | 要隐藏的方块的位置,默认随机选取,若要指定可以传一个数组,例如:[2,3]代表第2列,第3行,超过默认取最后一个方块 | Array / 'random' | random | false |