0.1.2 • Published 3 years ago

frame-draft v0.1.2

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Frame Draft 🖼

version shield license shield

Frame Draft is a very minimal engine library to bootstrap your game idea!

Just install it in your project

$ npm install frame-draft

And you are ready to use a game loop, a html canvas and a keyboard helper that it packs.

Frame Draft is super easy to use just like the example below:

import {
  Engine,
  Canvas,
  Keyboard
} from 'frame-draft'

const engine = new Engine()
const canvas = new Canvas(1280, 720)
const keyboard = new Keyboard()

const update = () => {
  // Put your game logic

  if (keyboard.isDown('ArrowUp')) {
    // Do some control actions
  }

  if (keyboard.isHeld('ArrowUp')) {
    // Do some control actions once when the key is been held
  }
}

const render = () => {
  canvas.context.fillStyle = '#ffffff'
  canvas.context.fillRect(0, 0, 1280, 720)

  // Draw your game
}

keyboard.onKeyPress(key => {
  // Do anything on key press
})

engine.start(elapsedTime => {
  update()
  render()
})

About

Frame Draft is built with Typescript using Rollup as its bundler.


Made with 🧑‍🚀 by @caioferrarezi