Socket
Book a DemoInstallSign in
Socket

@tknight-dev/gaming-canvas

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tknight-dev/gaming-canvas

A better/faster way to start writing games in JS

1.7.1
latest
Source
npmnpm
Version published
Weekly downloads
1.1K
49.03%
Maintainers
1
Weekly downloads
 
Created
Source

Gaming Canvas · GitHub license

Logo

Supports CommonJS (.cjs) and ESM (.mjs)

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)
  • Lists: Provides List implementions where Array performance faulters
    • Double-Linked-List
    • FIFO Queue (Single-Linked-List without popEnd() or pushStart())
  • Lightweight: Core library is ~40kb
  • Modules
    • Grids: Includes Grid, Camera, and Viewport implementations (including Raycasting!). 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 fix your display to something like 1 / 1 , 4 / 3, and 16 / 9 (the default)
  • 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 it in action with my game: Life. Its a multithreaded Conway's Game of Life for Desktop and Mobile devices (supports Gamepad, Keyboard, Mouse, and Touch based inputs) [GitHub]!

Documentation

Link: Documentation

forthebadge forthebadge

Keywords

canvas

FAQs

Package last updated on 05 Sep 2025

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.