Socket
Socket
Sign inDemoInstall

@basementuniverse/debug

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @basementuniverse/debug

A component for rendering debug output on a canvas


Version published
Maintainers
1
Created

Readme

Source

Game Component: Debug

A component for rendering debug output on a canvas.

How to use

Initialise debug before use:

import Debug from '@basementuniverse/debug';

Debug.initialise();

Render the debug output:

class Game {
  // ...

  public draw(context: CanvasRenderingContext2D) {
    // Draw everything else...

    Debug.draw(context);
  }
}

Show a value in a corner of the screen:

Debug.value('FPS', game.fps);

Show a marker somewhere on the screen:

Debug.marker('player', player.name, player.position);

Options

const options = { ... };
Debug.initialise(options);
OptionTypeDefaultDescription
marginnumber10Edge of screen margin
paddingnumber4Padding between debug text and background
fontstring10pt Lucida Console, monospaceThe font to use
lineHeightnumber12The height of a line of text
foregroundColourstring#fffThe colour of the text
backgroundColourstring#333The colour of the background
defaultValueDebugValue(see below)Default options for values
defaultMarkerDebugMarker(see below)Default options for markers

Value options

const options = { ... };
Debug.value('FPS', game.fps, options);
OptionTypeDefaultDescription
align`'left''right'`'left'
showLabelbooleantrueShow the label
paddingnumber4Padding between debug text and background
fontstring10pt Lucida Console, monospaceThe font to use
foregroundColourstring#fffThe colour of the text
backgroundColourstring#333The colour of the background

Marker options

const options = { ... };
Debug.marker('player', player.name, player.position, options);
OptionTypeDefaultDescription
showLabelbooleantrueShow the label
showValuebooleantrueShow the value
showMarkerbooleantrueShow a marker icon
markerSizenumber6The size of the marker icon in px
markerStyle`'x''+''.'`
markerColourstring#cccThe colour of the marker icon
space`'world''screen'`'world'
paddingnumber4Padding between debug text and background
fontstring10pt Lucida Console, monospaceThe font to use
labelOffsetvec{ x: 10, y: 10 }The offset of the label from the marker
foregroundColourstring#fffThe colour of the text
backgroundColourstring#333The colour of the background

Other components

  • Camera
  • Content Manager
  • Debug
  • Input Manager
  • Scene Manager

FAQs

Last updated on 29 Sep 2023

Did you know?

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc