Skip to content

wasd-org/wasd-flappy

Repository files navigation

wasd-flappy

Build Status Coverage Status npm

🐦 Create your own flappy.

Installation

npm i wasd-flappy -S

Demo

Usage

import Flappy, { Player, Block } from 'wasd-flappy'

new Flappy({
  canvas: {
    width: 300,
    height: 400
  },
  player: new Player({
    height: 30,
    width: 30
  }),
  levels: [
    {
      score: 0,
      blocks: [new Block()]
    }
  ]
})

API

Flappy

Options

Name Description Type Accepted Values Default
canvas.width Canvas width Number - 300
canvas.height Canvas height Number - 600
canvas.floorHeight floor height Number - 0
canvas.fps fps Number - 30
player player Player - -
levels[].score score Number - -
levels[].blocks blocks Block[] - -
levels[].blockDistance block distance Number Array -
levels[].blockRandom block random Boolean - false

Methods

  • Flappy#start
  • Flappy#pause
  • Flappy#continue
  • Flappy#gameover
  • Flappy#restart

Events

  • game:start
  • game:ready
  • game:progress
  • game:over

Properties

Player

Options

Name Description Type Accepted Values Default
width Player width Number - 30
height Player height Number - 30
startX start x Number - 0
startY start y Number - 0
velocity velocity Number - 15
g gravitational Number - 20
name name String - 'Player'
pop Fault tolerance Number - 0
reverse reverse Boolean - false
meta anything * - null

Methods

  • Player#jump

Events

  • player:hitblock
  • player:hitfloor

Properties

Block

Options

Name Description Type Accepted Values Default
width Block width Number Array -
height Block height Number Array -
padding padding Number Array -
placement placement String 'random', 'bottom', 'top' 30
name name String - 'Block'
meta anything * - null

Properties

License

MIT