Skip to content

Commit b397045

Browse files
authored
Update README.md
1 parent 02d20bf commit b397045

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
NodeToJS is a module/library at once: a module for NodeJS and a library for Javascript (JS). It allows to create text based apps/games that can be executed and work both in the terminal (for Windows, Linux or Mac) and in a web browser. That is, with the same code you will create a CLI app/game and a text-based webapp/webgame.
33

44
### Use:
5-
The minimum files you need are three: a wrap file (game.html), the NodeToJS module/library (NODEtoJS.js), and a NodeJS or Javascript file that starts your js application.
5+
The minimum files you need are four:
6+
- A wrap file: app.html
7+
- A monospace font. I recommend: HP_100LX_10x11.woff
8+
You can get old PC fonts here: https://int10h.org/oldschool-pc-fonts/fontlist/
9+
- The NodeToJS module/library: NODEtoJS.js
10+
- Your main .js file. app.js
11+
12+
### Hello world example.
613

714
1. Your HTML wrap file (for example app.html) will load the NodeToJS library (NodeToJS.js) and will load the starter NodeJS/Javascript script of yout app (app.js in this example). You also have to add NodeToJS.HTMLMODE=1 right after loading the library/module and before loading your scripts.
815

@@ -13,11 +20,26 @@ app.html
1320
<script src="app.js></script>
1421
```
1522
2. Your apps.js must contain at least the following code. It is the first thing that has to be executed.
23+
24+
app.js
1625
```
26+
function readKey(){
27+
NodeToJS.readkey(function(k){
28+
if(k=="x"){NodeToJS.exit()}
29+
})
30+
}
1731
function init(){
18-
// Your code
32+
// NodeToJS.scaleFullScreen();
33+
NodeToJS.cleanScreen();
34+
NodeToJS.draw([
35+
{c:31,b:35,y:3,x:8,t: "┌─────────────┐"},
36+
{c:31,b:35,y:4,x:10,t:"│ Hello world │"},
37+
{c:31,b:35,y:5,x:10,t:"└─────────────┘"}
38+
{c:32,b:30,y:6,x:10,t:"Press 'x' to exit."}
39+
]);
40+
readKey();
1941
}
20-
if(typeof(NodeToJS)=="undefined"){NodeToJS=require('./NODEtoJS').NodeToJS;}
42+
if(typeof(NodeToJS)=="undefined"){NodeToJS=require('./NODEtoJS').NodeToJS}
2143
NodeToJS.start(32,104,"./HP_100LX_10x11.woff",10,11,function(){
2244
// 32 and 104 are the maximum rows and the columns of the simulated terminal
2345
// HP_100LX_10x11.woff is a monospace font that I recommend to use.

0 commit comments

Comments
 (0)