New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nona-ascii

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nona-ascii

A renderer, components, and more to use with nona-core

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Nona ASCII

A renderer for nona-core that renders in a browser what looks like a terminal output.

Basic Usage
import Engine from 'nona-core';
import {
  renderer,
  components,
  assemblages,
  keyIsDown,
} from 'nona-ascii';

// Create a new Game instance
const engine = new Engine({
  renderer: renderer({
    attachPoint,
    width: 80,
    height: 30,
  }),
  update: ({
    // Entities and component data
  }) => {
    // Modify entity-component data here
    if (keyIsDown(39)) { // Arrow Right
      // Move carla right
    }
  },
  components,
  assemblages,
});

// Add components
engine.createComponent({
  name: 'Transform',
  description: 'Track entity position',
  state: {
    x: 0,
    y: 0,
  },
});

// Create an entity
const carla = engine.addEntity('Carla');
// Add a component to an entity
engine.addComponentToEntity('Transform', carla);
// Start your engine
engine.startGame();
API

Exports:

NameTypeDescription
rendererFunctionTakes arguments for rendering and returns a function to be passed to nona-core's renderer.
componentsArrayAn array of core components used for drawing and more.
assemblagesArrayAn array of core assemblages used for drawing and more.
keyIsDownFunctionTakes a keyCode and return a boolean.
keyIsUpFunctionTakes a keyCode and return a boolean.
renderer({ attachPoint, [width], [height], [color], [backgroundColor] })

attachPoint is a DOM element to which everything will be drawn.

components
[
  {
    name: 'Transform',
    description: `A component for storing the 2D position.
Default: state: { x: 0, y: 0 }
Types: state: { x: <integer>, y: <integer> }`,
    state: {
      x: 0,
      y: 0,
    },
  },
  {
    name: 'Renderer',
    description: `A component for renderer an ascii character.
Default: state: { char: '#' }
Types: state: { char: <char> }`,
    state: {
      char: '#',
    },
  },
]
assemblages
[
  {
    label: 'GameObject',
    description: `An assemblage for positioning and rendering an entity.
Coponents: ['Transform', 'Renderer']`,
    components: new Set([
      'Transform',
      'Renderer',
    ]),
  },
]
keyIsDown(keyCode)

Takes an integer keyCode and returns a boolean.

keyIsUp(keyCode)

Takes an integer keyCode and returns a boolean.

Author: Wolfgang Schuster

Keywords

FAQs

Package last updated on 24 Dec 2017

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

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc