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

wasd-tetris

v0.1.4

Published

🎮 A tetris only with core data layer.

Downloads

16

Readme

Description

🎮 A tetris only with core data layer.

Table of contents

Features

  • No dependences.
  • Only provide data operation.
  • Custom UI.

Installation

yarn add wasd-tetris

Demo

Usage

import Tetris from 'wasd-tetris'

const tetris = new Tetris()

tetris.on('repaint', graph => {
  // draw graph
})

tetris.start()

API

Tetris

Options

| Name | Description | Type | Accepted Values | Default | |------|-------------|------|-----------------|---------| | matrix | Matrix for tetris | Matrix | - | matrix | | auto | Whether auto progress game | Boolean | - | true | | speed | The speed (milliseconds) of falling block | Number | - | 500 |

Attributes

| Attribute | Description | Type | Accepted Values | Default | |-----------|-------------|------|-----------------|---------| | graph(getter) | The graph of current game | - | — | — |

Events

| Event Name | Description | Parameters | |------------|-------------|----------- | | repaint | triggers when game need reapint | graph | | hit | triggers when block hit existed block or bottom of the matrix | - | | overflow:left | triggers when block hit left of the matrix | - | | overflow:right | triggers when block hit right of the matrix | - | | hit:rotate | triggers if block hit after rotate | - | | clear:lines | triggers when lines need to be cleard | lines | | failed | triggers when game over | - |

Methods

| Method | Description | Parameters | |--------|-------------|------------| | start | start the game | - | | reset | reset the game | - | | pause | pause the game | - | | resume | resume the game | - | | fail | fail the game | - | | save | save current state of the game | - | | restore | restore the last saved state | - | | addBlock | add new block | block | | drop | move the block down until hit | - | | down | move the block down | - | | left | move the block left | - | | right | move the block right | - | | rotate | rotate the block | - |

Block

Options

| Name | Description | Type | Accepted Values | Default | |------|-------------|------|-----------------|---------| | x | X coordinate | Number | - | 0 | | y | Y coordinate | Number | - | 0 | | shape | Shape of the block | shape | - | random shape |

Attributes

| Attribute | Description | Type | Accepted Values | Default | |-----------|-------------|------|-----------------|---------| | coordinate(getter) | The coordinate of current game | Object | — | { x, y, array } |

Methods

| Method | Description | Parameters | |--------|-------------|------------| | moveBy | move the block to a relative position | x, y | | moveTo | move the block to a absolute position | x, y | | rotate | rotate the block clockwise or anti-clockwise | clockwise |

Shape

Options

| Name | Description | Type | Accepted Values | Default | |------|-------------|------|-----------------|---------| | shape | Initial shape of the Shape | Array | - | [] |

Attributes

| Attribute | Description | Type | Accepted Values | Default | |-----------|-------------|------|-----------------|---------| | shape(getter) | Current shape | Array | — | - | | index(getter) | Current index | Number | — | 0 | | index(setter) | Set current index | Number | — | - | | margin(getter) | Margin of current shape | Object | - | { row, col, top, left, bottom, right } |

Methods

| Method | Description | Parameters | |--------|-------------|------------| | clone | clone Shape | - | | rotate | rotate current shape clockwise or anti-clockwise | clockwise |

Matrix

Options

| Name | Description | Type | Accepted Values | Default | |------|-------------|------|-----------------|---------| | row | row of the matrix | Number | - | 20 | | col | column of the matrix | Number | - | 10 | | x | X coordinate | Number | - | 0 | | y | Y coordinate | Number | - | 0 |

Attributes

| Attribute | Description | Type | Accepted Values | Default | |-----------|-------------|------|-----------------|---------| | coordinate(getter) | The coordinate of matrix | Object | — | { x, y, array } |

Methods

| Method | Description | Parameters | |--------|-------------|------------| | reset | reset matrix to initial state | - |

Development

yarn
yarn dev

License

MIT