Skip to content

Commit c88a08e

Browse files
authored
Update README.md
1 parent 26d31d0 commit c88a08e

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

README.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# NodeToJS
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

4+
Features:
5+
- Use canvas to simulate the terminal.
6+
- Draw text with foreground color and background color.
7+
- Read key events
8+
- It has no user text input fields (for now).
9+
410
### Use:
511
The minimum files you need are four:
612
- A wrap file: app.html
7-
- A monospace font. I recommend: HP_100LX_10x11.woff
13+
- A monospace font. I recommend woff files. For example: WebPlus_ToshibaSat_9x16.woff
814
You can get old PC fonts here: https://int10h.org/oldschool-pc-fonts/fontlist/
915
- The NodeToJS module/library: NODEtoJS.js
1016
- Your main .js file. app.js
@@ -16,35 +22,40 @@ The minimum files you need are four:
1622
app.html
1723
```
1824
<!DOCTYPE html><html><head><meta charset="utf-8"></head><body></body></html>
19-
<script src="NODEToJS.js"></script><script>NodeToJS.HTMLMODE=1</script>
25+
<script src="NodeToJS.js"></script><script>NodeToJS.HTMLMODE=1</script>
2026
<script src="app.js"></script>
2127
```
22-
2. Your apps.js must contain at least the following code. It is the first thing that has to be executed.
28+
2. Your apps.js. This file is an example to demonstrate the main functions of NodeToJS module/library.
2329

2430
app.js
2531
```
2632
function readKey(){
27-
NodeToJS.readkey(function(k){
28-
if(k=="x"){NodeToJS.exit()}
33+
NodeToJS.readkey(function(k){ // k is the key pressed
34+
if(k=="x"){
35+
NodeToJS.cleanScreen(0);
36+
NodeToJS.draw([{c:1,b:7,y:1,x:1,t:" See you soon! "}])
37+
NodeToJS.exit()
38+
}
2939
})
3040
}
3141
function init(){
3242
// NodeToJS.scaleFullScreen();
33-
NodeToJS.cleanScreen();
43+
NodeToJS.cleanScreen(16); // 16 is the background color used to clean the terminal
3444
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."}
45+
// c is the foreground color, b is the background color, y and x are the terminal coordinates, t is the text to draw
46+
{c:0,b:17,y:5,x:10, t:"┌─────────────┐"},
47+
{y:6,x:10, t:"│ Hello world │"},
48+
{y:7,x:10, t:"└─────────────┘"},
49+
{c:7,b:6,y:9,x:8,t:" Press 'x' to exit "}
3950
]);
4051
readKey();
4152
}
42-
if(typeof(NodeToJS)=="undefined"){NodeToJS=require('./NODEtoJS').NodeToJS}
43-
NodeToJS.start(32,104,"./HP_100LX_10x11.woff",10,11,function(){
44-
// 32 and 104 are the maximum rows and the columns of the simulated terminal
45-
// HP_100LX_10x11.woff is a monospace font that I recommend to use.
46-
// Font downloaded from https://int10h.org/oldschool-pc-fonts/fontlist/font?hp_100lx_10x11#-
47-
// 10 and 11 are the width and height of each character of the loaded font, measured in pixels
53+
if(typeof(NodeToJS)=="undefined"){NodeToJS=require('./NodeToJS.js').NodeToJS}
54+
NodeToJS.start(35,14,"./WebPlus_ToshibaSat_9x16.woff",9,16,function(){
55+
// 35 and 14 are the maximum rows and the columns of the simulated terminal
56+
// WebPlus_ToshibaSat_9x16.woff is a monospace font that my simulated terminal will use.
57+
// Downloaded from https://int10h.org/oldschool-pc-fonts/download/oldschool_pc_font_pack_v2.2_web.zip
58+
// 9 and 16 are the width and height of each character of the chosen font, measured in pixels.
4859
init()
4960
});
5061
```

0 commit comments

Comments
 (0)