New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

use-tetris

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-tetris

This is a fun project with the sole purpose to learn new things. It is a work in progress. Currently there are some things missing:

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Tetris Game implemented as a custom hook

This is a fun project with the sole purpose to learn new things. It is a work in progress. Currently there are some things missing:

  • add levels
  • increase speed (gravitation) for each level
  • simplify current hook using useReducer for the game logic

I've extracted this from another project which you can try here https://florin-cosmin-tetris.netlify.app/

How to use it

npm i use-tetris@latest -E

Then in your JavaScript/TypeScript code:

import React from 'react'
import { render } from 'react-dom'
import { useTetris } from 'use-tetris'

// copied from: https://usehooks-typescript.com/react-hook/use-event-listener
import useEventListener from './use-event-listener'

const TetrisApp: React.FC = () => {
    const {
        tetrisState,
        handleKey
    } = useTetris()

    // listen for keydown events
    useEventListener('keydown', function(event) {
        const keycode = (event as KeyboardEvent).keyCode as keyof typeof browserKeyCodeMap
        const key = browserKeyCodeMap[keycode]

        handleKey(key)
    })

    const { score, grid, piece, nextPiece, gameState } = tetrisState

    return (
        ...
    )
}

render(<TetrisApp />, document.querySelector('#root'))

This project was bootstrapped using tsdx.io

If you want to get in contact with me you can always DM me on twitter

Keywords

preact

FAQs

Package last updated on 15 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts