Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

console-game-engine

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-game-engine

A basic console game engine for Node.js.

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Node.js Console Game Engine

A basic console game engine for Node.js.

Installation

You can use npm to install Engine: npm install console-game-engine

Quick start

const ConsoleGame = require("console-game-engine");
//New game object
const game = new ConsoleGame();
//First render.
game.render();
/*Result of this render:
████████████████
████████████████
████████████████
████████████████
████████████████
████████████████
████████████████
████████████████
*/

const write = [[1, 2], [2, 3], [3, 4], [4, 5]];


for (const [x, y] of write) {
    game.set(x, y);
}
/*Result of this:
████████████████
████████████████
█ ██████████████
██ █████████████
███ ████████████
████ ███████████
████████████████
████████████████
*/

for (const [x, y] of write){
    game.set(x + 6, y);
}
/*Result of this:
████████████████
████████████████
█ █████ ████████
██ █████ ███████
███ █████ ██████
████ █████ █████
████████████████
████████████████
*/
Result:

image

Usage:

New Game:

For creating new game map.

//Default values for Class:
const width=16, height=8, backgroundChracter = "█";

const game = new ConsoleGame(width,height, BackgroundChracter);

Render:

For write map to console.

 game.render();

Clear:

For clearing console. No effect to map.

 game.clear();

Reset:

For resetting, backing first version of map (Defined in new ConsoleGame()):

 game.reset();

Set:

Setting a Chracter in map:

//Default values for this:
const x=1,y=1, chracter = " ";

 game.set(x,y,chracter );

WARNING: No need to use the render function, it has render in itself.

Get:

Getting a Chracter from map:

 const chracter= game.get(1,1);
 console.log(chracter)

WARNING: It has not default parameters.

Keywords

FAQs

Package last updated on 16 Feb 2022

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