console-game-engine

1.1.0 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i console-game-engine

      Weekly Downloads

      1

      Version

      1.1.0

      License

      GPL-3.0-or-later

      Unpacked Size

      5.97 kB

      Total Files

      4

      Last publish

      Collaborators

      • akif9748