Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tknight-dev/gaming-canvas

tknight-dev4.2kMIT1.15.4TypeScript support: included

A better/faster way to start writing games

audio, canvas, dpi, fullscreen, gamepad, gaming, grids, inputs, keyboard, layers, lightweight, mobile, mouse, multithreading, orientation, resolution, responsive, splitscreen, threads, touch, vibration, visibility, wakelock

readme

Gaming Canvas · GitHub license

Logo

Supports

Why This Library?

GamingCanvas is for the game developer that wants to write their own game or engine, their own way, rather than usings solutions like PixiJs and Phaser. It provides the following to get you up and running:

  • Audio: The built in audio system provides buffers which allow you play multiple audio files at the same time (even the same audio file)
    • Quickly update the pan and volume of the effect or music depending on your game's environment!
    • Use faders to automatically evolve your pan and volume values to your desired settings over a duration of milliseconds
      • Use fader callback chaining to perfectly time more complicated pan and volume changes over a series of actions
  • DPI: Supports high/low DPI screens (devicePixelRatio)
  • Fullscreen: Quickly fullscreen your game
  • Inputs: Quickly gives you access to Gamepad, Keyboard, Mouse, and Touch via a serialized (FIFO) input queues
    • Enable or disable any input type you want
    • Gamepad: Support currently excludes triggers due to different browser bugs/implementations of the Gamepad API
    • Mouse: Supports left, right, and wheel based inputs
    • Touch: Supports as many individual inputs as your screen can support
  • Layers: Specify how many layers you want to optimize your game for. It can generate multiple canvases for background, foreground, overlay-1, etc, etc
    • Send each layer to a different WebWorker to dedicate a thread to each canvas element (massive performance gains) (multithreading)
  • Lists: Provides List implementions where Array performance faulters
    • Double-Linked-List
    • FIFO Queue (Single-Linked-List without popEnd() or pushStart())
  • Lightweight: Core library is ~45kb
  • Modules
    • Grids: Includes Grid, Camera, Path Finding (A*), Raycasting, and Viewport implementations. See How-To > Module: Grids for all the features and details
  • Mobile: Mobile devices are fully supported
  • Orientation: Auto rotate for maximum screen usage or lock it to a specific orientation (Portrait/Landscape)
  • Resolution: Use a fixed resolution to optimize your FPS (it still scales to fill the screen like a regular video game would)
    • Dimensions are always rounded down to the nearest pixel to improve performance
    • Scaling uses the css transform: scale(x) function which your browser (CPU) offloads to your GPU (best performance)
    • Use the aspectRatio option to lock your display to something like 1 / 1, 4 / 3, and 16 / 9 (the default)
  • Splitscreen: A no hassle way to split your screen for 2 players (2 canvases sharing the space of 1 canvas)
  • Vibration: Set vibration (think mobile device vibration during an incoming phone call) for single use or repeating patterns
    • Not supported by all browsers (MDN)
  • Visibility: Quickly know if your game needs to be paused (browser minimized or switched to new tab)
  • Wake Lock: Quickly prevent mobile devices from dimming the screen while you're playing

See the GamingCanvas in action in the following games:

  • Life, A multithreaded Conway's Game of Life for Desktop and Mobile devices (supports Gamepad, Keyboard, Mouse, and Touch based inputs) [GitHub]

Documentation

Link: Documentation

TypeScript GitHub