npm i ascii-game
// Dependencies
const A = require('ascii-game');
// AsciiGame.Display takes an object with properties *w* and *h* to determine the dimensions of the display
const display = new A.Display(w <int cols>, h <int rows>);
// AsciiGame.Model takes and stores a two-dimensional array of single-character strings
const model = new A.Model([
"+-+",
"| |",
"| |",
"+-+"
]);
s
: character being appendedx
: x-position in the display datay
: y-position in the display data- returns nothing
model
: instance of theAsciiGame.Model
classx
: x-position in the display datay
: y-position in the display data- returns nothing
appendations
:[{model, x, y}, ...]
- returns nothing
- returns a new instance of the
AsciiGame.Model
class of the current display data
- clears all of the cells in the display data
- returns nothing
- returns stringified rendition of the display data that can be immediately printed to the console
- returns html element rendition of the display data
- updates the instance's
el
property - returns nothing
- prints the current display data in the console
- returns nothing
sel
: query selector of element that the display data will render to- returns nothing
- prints the current model data in the console
- returns nothing
<div id="game"></div>
const A = require('ascii-game');
const display = new A.Display({"w": 32, "h": 18});
const helloWorld = new A.Model([
"Hello",
"World"
]);
display.appendModel(helloWorld, 16, 8);
display.flush();
display.render("#game");
Engineered with ♥ by @EthanThatOneKid