Engine render, fps and I/O on terminal.

Overview

typesgine-ascii - Game ASCII engine for terminal

About   |    technologies   |    Features   |    Examples   |    Functions   |    License

📓 About

Typesgine is engine for create games ascii into terminal with IO, FPS and render.

technologies 🐱‍🏍 🎂

Features

Functions

  • FrameHandler.Handler

This function is called every frame. It's used to render the game. It must execute the render function that needs to receive an Array [][] / [[]] or a String containing the ASCII to be rendered.

If Array [][] / [[]] dont set the width and height of the screen, the engine will set it automatically.

If String set the width and height of the screen.

/// typesgine.FrameHandler.Handler(callback(engineIo))

const frameHandler = typesgine.FrameHandler.Handler((engineIo) => {
  engineIo.render("1234", 24, 16);
});

let Graph = [
  ["㊗", "2", "㊗", "㊗", "\n"],
  ["㊗", "㊗", "3", "㊗", "\n"],
  ["㊗", "4", "㊗", "㊗", "\n"],
];

const frameHandler = typesgine.FrameHandler.Handler((engineIo) => {
  engineIo.render(Graph);
});
  • InputHandler.Handler

It's used to handle the input. Because this function return a Keypress

/// typesgine.InputHandler.Handler(callback(engineIo, keyPress))

const inputHandler = typesgine.InputHandler.Handler((engineIo, keyPress) => {
  console.log("KeyPress: ", keyPress);

  if (keyPress === "a") console.log("Moving player");
  if (keyPress === "Escape") process.exit();
});
  • EngineIo

It's used to handle the input. Because this function return a Keypress

new typesgine.EngineIo({
  fps: 60, // Frame per second

  //Set the render handler, use peer default is typesgine.RenderTerminal for terminal.
  renderHandler: new typesgine.Render(new typesgine.RenderTerminal()),

  frameHandler: frameHandler, // - FrameHandler.Handler
  keypressHandler: inputHandler, // - InputHandler.Handler
});

Exemple

See Folder Exemple in the root of the project to see how to use the engine.

Simplest example

import typesgine from "typesgine-ascii";

console.clear();

const render = () => {
  let final = "";
  for (let i = 0; i < 16; i++) {
    for (let j = 0; j < 24; j++) {
      final += `${Math.round(Math.random() * (0 - 9) + 9)}`;
    }
  }

  return final;
};

const frameHandler = typesgine.FrameHandler.Handler((engineIo) => {
  engineIo.render(render(), 24, 16);
});

const inputHandler = typesgine.InputHandler.Handler((engineIo, keyPress) => {
  console.log("KeyPress: ", keyPress);
});

new typesgine.EngineIo({
  fps: 60,
  renderHandler: new typesgine.Render(new typesgine.RenderTerminal()),
  frameHandler: frameHandler,
  keypressHandler: inputHandler,
});

Simplest example, using Arrays for render

import typesgine from "typesgine-ascii";

console.clear();

const render = () => {
  let final = [
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  ];

  for (let i = 0; i < 8; i++) {
    for (let j = 0; j < 24; j++) {
      final[i][j] = Math.round(Math.random() * (0 - 9) + 9);
    }
    final[i][final[i].length - 1] = "\n";
  }

  return final;
};

const frameHandler = typesgine.FrameHandler.Handler((engineIo) => {
  engineIo.render(render(), 24, 16);
});

const inputHandler = typesgine.InputHandler.Handler((engineIo, keyPress) => {
  console.log("KeyPress: ", keyPress);
});

new typesgine.EngineIo({
  fps: 60,
  renderHandler: new typesgine.Render(new typesgine.RenderTerminal()),
  frameHandler: frameHandler,
  keypressHandler: inputHandler,
});

License

MIT LICENSE

You might also like...

Svelte component to render markdown.

svelte-exmarkdown Svelte component to render markdown. Motivation svelte-markdown is a good component package. However, it is not extensible. You cann

Jan 6, 2023

Render arbitrary Markdown content in Astro, optionally integrating with any existing configuration.

Astro Markdown Astro Markdown lets you render arbitrary Markdown content in Astro, optionally integrating with any existing configuration. --- import

Dec 22, 2022

Render e-books in the browser

foliate-js Library for rendering e-books in the browser. Features: Supports EPUB, MOBI, KF8, FB2, CBZ Pure JavaScript Small and modular No dependencie

Dec 26, 2022

Making webshell and terminal supports trzsz ( trz / tsz ), which similar to rz / sz, and compatible with tmux.

Making webshell and terminal supports trzsz ( trz / tsz ), which similar to rz / sz, and compatible with tmux.

trzsz.js Making webshell and terminal supports trzsz ( trz / tsz ), which similar to ( rz / sz ), and compatible with tmux. Why? Considering laptop -

Jan 3, 2023

Manage and monitorize your notification using only your terminal :3

Manage and monitorize your notification using only your terminal :3

Notifications Monitor Monitor your notifications and get a temporary list of the notifications. Dependencies Node.js (to run the program; by default,

Apr 12, 2022

A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

A Hackable Markdown Note Application for Programmers. Version control, AI completion, mind map, documents encryption, code snippet running, integrated terminal, chart embedding, HTML applets, plug-in, and macro replacement.

Yank Note A hackable markdown note application for programmers Download | Try it Online Not ecommended English | 中文说明 [toc]{level: [2]} Highlights

Dec 31, 2022

Small PNG to WEBP converter, terminal based and handy for a frontend developer :D

Image Utils A small util i used while making antstack.com What does it do and how to use? It basically converts .png files to .webp Read about Webp he

Aug 24, 2022

All terminal commands in one place (you can Contribute to it by putting latest commands and adding Readme)

Terminal-Commands All basic terminal commands in one place Show some ❤ by some repositories You can contribute to this readme If you to contribute wit

Dec 15, 2022

🥰 Mini world simulator is a terminal application made in JavaScript to control the world that is being generated.

Mini-world "Simulator" Mini world simulator is a terminal application made in JavaScript to control the world that is being generated. It has no other

Mar 14, 2022
Releases(2.0.1)
  • 2.0.1(Dec 14, 2022)

  • 2.0.0(Dec 13, 2022)

    What's Changed

    • Creating readme and setting project by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/8
    • Fix bugs by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/9
    • Fix bug render infinite by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/10
    • 11 fix error into use import default by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/12
    • improving use of library by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/15
    • cross platform by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/16
    • Fix: Errors, Feature: Docs by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/17

    Full Changelog: https://github.com/Colgate13/typesgine-ascii/compare/v2...2.0.0

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0lts(Jun 6, 2022)

    • [x] #1
    • [x] Render into terminal
    • [x] FPS
    • [x] IO - Render
    • [x] IO - Keyboard Input

    What's Changed

    • Create engine by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/2
    • update by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/3
    • Updates by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/4
    • Publish npm using actions by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/5
    • Update package.json by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/6
    • Update publish.yml by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/7
    • Creating readme and setting project by @Colgate13 in https://github.com/Colgate13/typesgine-ascii/pull/8

    Full Changelog: https://github.com/Colgate13/typesgine-ascii/compare/v1.0.0...v1

    New Contributors

    • @Colgate13 made their first contribution in https://github.com/Colgate13/typesgine-ascii/pull/2

    Full Changelog: https://github.com/Colgate13/typesgine-ascii/commits/v1.0.0lts

    Source code(tar.gz)
    Source code(zip)
Owner
Gabriel Barros Feitosa Sá
My name is Gabriel Barros F. Sá, I'm a programmer student
Gabriel Barros Feitosa Sá
Render readable & responsive tables in the terminal

terminal-columns Readable tables for the terminal. Tables can be automatically responsive! Features Content wrapped to fit column width Column widths

hiroki osame 28 Oct 28, 2022
The project integrates workflow engine, report engine and organization authority management background, which can be applied to the development of OA, HR, CRM, PM and other systems. With tlv8 IDE, business system development, testing and deployment can be realized quickly.

介绍 项目集成了工作流引擎、报表引擎和组织机构权限管理后台,可以应用于OA、HR、CRM、PM等系统开发。配合使用tlv8 ide可以快速实现业务系统开发、测试、部署。 后台采用Spring MVC架构简单方便,前端使用流行的layui界面美观大方。 采用组件开发技术,提高系统的灵活性和可扩展性;采

Qian Chen 38 Dec 27, 2022
Render (GitHub Flavoured with syntax highlighting) Markdown, and generate CSS for each of GitHub’s themes.

render-gfm Render (GitHub Flavoured with syntax highlighting) Markdown, and generate CSS for each of GitHub’s themes. GitHub Repository npm Package Do

Shaun Bharat 12 Oct 10, 2022
Detect browser, and render view according to the detected browser type.

react-browser-detector Detect browser, and render view according to the detected browser type. Installation To install, you can use npm or yarn: npm i

kirillsaint 5 Jul 13, 2022
Another table select prompt plugin of inquirer.js, with powerful table render and filters.

inquirer-table-select-prompt Table row selection prompt for Inquirer.js 动机 现有的 inquirer.js 没有支持表格行选中的命令行交互的插件. 社区内能查找到的,只有一个二维数组的 checkbox,eduardobouc

锂电 3 Jan 7, 2023
Portfolio page using React.js to render dynamic HTML

Meta-Portfolio Portfolio page using React.js to render dynamic HTML Version 1.0 Note You are important. Installation Instructions No installation nece

Andrew Tran 0 May 17, 2022
Websheetjs - Lightweight JS library to render website sections with data from Google Spreadsheets

websheet.js Render website sections with lazy-loaded data from Google Spreadsheets It's lightweight, fast, free and open-source ! See how it works, fu

Pierre Avinain 29 Oct 4, 2022
Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Html Mermaid Dokka plugin Mermaid-Dokka MermaidJS 0.2.2 8.14.0 0.3.0 9.0.0 Step 1: install dependencies { dokkaPlugin("com.glureau:html-mermaid-dokk

Grégory Lureau 23 Sep 16, 2022
A plugin for the Obsidian markdown note application, adding functionality to render markdown documents with multiple columns of text.

Multi-Column Markdown Take your boring markdown document and add some columns to it! With Multi Column Markdown rather than limiting your document lay

Cameron Robinson 91 Jan 2, 2023
Given a list of items, only render what's visible on the screen while allowing scrolling the whole list.

Solid Windowed Given a list of items, only render what's visible on the screen while allowing scrolling the whole list. A Solid component. See https:/

Tito 40 Dec 21, 2022