@json2d/react-snake-lib

1.0.9-next.8 • Public • Published

Snake Game Lib

A highly customizable snake game component created using React.js

Installation

npm i @json2d/react-snake-lib

Usage

You can use it simply by

<Snake />

Or you can customize it

<Snake
  startOnLoad
  initialSnake={[
    { x: 2, y: 0 },
    { x: 2, y: 1 },
    { x: 2, y: 2 },          
    { x: 2, y: 3 },
    { x: 2, y: 4 },
  ]}        
  initialDirection="down"
  onScoreChange={onScoreChange}
  onGameOver={onGameOver}
  onGameStart={onGameStart}
  width="500px"
  height="500px"
  bgColor="silver"
  innerBorderColor="#b1b0b0"
  snakeSpeed={90}
  borderColor="black"
  snakeColor="#3e3e3e"
  snakeHeadColor="#1a1a1a"
  appleColor="tomato"
  borderRadius={5}
  snakeHeadRadius={1}
  borderWidth={0}
  shakeBoard={true}
  boxShadow="rgba(100, 100, 111, 0.2) 0px 7px 29px 0px"
  size={16}
  startGameText="Start Game"
  startButtonStyle={{
    color: "white",
    padding: "6px 20px",
    backgroundColor: "#1a1a1a",
    borderRadius: "10px",
    fontSize: "17px",
    fontWeight: "600",
    cursor:"pointer"
  }}
  startButtonHoverStyle={{
    backgroundColor: "#4f4d4d"
  }}
  noWall={false}
  />

Publish

npm run build-lib
npm publish --access public

Readme

Keywords

none

Package Sidebar

Install

npm i @json2d/react-snake-lib

Weekly Downloads

2

Version

1.0.9-next.8

License

MIT

Unpacked Size

19.7 kB

Total Files

4

Last publish

Collaborators

  • json2d