Skip to content

mkalam-alami/ohtge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

One Hour Text Game Engine

A small wrapper for xterm.js to make small terminal games using a trivial API. Docs available here.

Example game.js file

/// <reference path="node_modules/ohtge/lib/ohtge.d.ts" />

title("test.exe")
loop()

async function loop() {
    while (1) {
        write("Hello world")
        color("yellow")
        const a = await input("Say something?") // `input(string, callback)` syntax also supported
        color("white")
        write("You said " + a)
        write()
        await pause()
    }
}

Simple setup

  1. Download the zip
  2. Only keep the files you want (typically dist/ + one of the examples)
  3. Make a game!

Setup from scratch

  1. npm install ohtge (Optional, only used as reference for IDE auto-completion)
  2. Insert the following HTML in your web page:
<div class="ohtge-window cloaked">
    <div class="ohtge-title"></div>
    <div class="ohtge-terminal"></div>
</div>

<script src="https://cdn.jsdelivr.net/npm/ohtge"></script>
<script src="[ YOUR OWN GAME SCRIPT ]"></script>
  1. Insert the following at the top of your own script (either JS or TS):
/// <reference path="node_modules/ohtge/lib/ohtge.d.ts" />

write('Hello world!');

Complete API

Made with ohtge