update docs
This commit is contained in:
parent
b79d60fab5
commit
9a099f66cb
10
README.md
10
README.md
|
@ -114,6 +114,14 @@ Or use this in __`linux/macOS/Unix`__
|
|||
|
||||
> [cpp compiler] -std=c++11 -O3 main.cpp -o nasal -fno-exceptions -ldl
|
||||
|
||||
Or using makefile,`mingw32-make` is __`Windows`__ platform's `make`:
|
||||
|
||||
> mingw32-make nasal.exe
|
||||
|
||||
in __`linux/macOS/Unix`__:
|
||||
|
||||
> make nasal
|
||||
|
||||
## __How to Use__
|
||||
|
||||
First we should learn how to write a program using this language,
|
||||
|
@ -1584,11 +1592,11 @@ vm stack(limit 5, total 0)
|
|||
If want help, input `h` to get help.
|
||||
|
||||
```bash
|
||||
>> h
|
||||
<option>
|
||||
h, help | get help
|
||||
bt, backtrace | get function call trace
|
||||
c, continue | run program until break point or exit
|
||||
f, file | see all the compiled files
|
||||
g, global | see global values
|
||||
l, local | see local values
|
||||
u, upval | see upvalue
|
||||
|
|
2
makefile
2
makefile
|
@ -1,6 +1,8 @@
|
|||
.PHONY=test
|
||||
nasal:main.cpp nasal_ast.h nasal_err.h nasal_builtin.h nasal_opt.h nasal_codegen.h nasal_gc.h nasal_import.h nasal_lexer.h nasal_parse.h nasal_vm.h nasal_dbg.h nasal.h
|
||||
clang++ -std=c++11 -O3 main.cpp -o nasal -fno-exceptions -ldl -Wshadow -Wall
|
||||
nasal.exe:main.cpp nasal_ast.h nasal_err.h nasal_builtin.h nasal_opt.h nasal_codegen.h nasal_gc.h nasal_import.h nasal_lexer.h nasal_parse.h nasal_vm.h nasal_dbg.h nasal.h
|
||||
g++ -std=c++11 -O3 main.cpp -o nasal.exe -fno-exceptions -Wshadow -Wall -static
|
||||
test:nasal
|
||||
@ ./nasal -op -e test/ascii-art.nas
|
||||
@ ./nasal -op -c test/bf.nas
|
||||
|
|
|
@ -166,6 +166,7 @@ struct nasal_obj
|
|||
if(destructor && ptr)
|
||||
{destructor(ptr);}
|
||||
ptr=nullptr;
|
||||
destructor=nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -57,21 +57,16 @@ var blockshape=[
|
|||
[[0,0],[1,0],[0,1],[-1,1]]
|
||||
];
|
||||
|
||||
var stick_count=0; # make sure one stick in 10 tries
|
||||
var color_count=0;
|
||||
var last_type=-1;
|
||||
var typechange=func(t){
|
||||
if(t==last_type)
|
||||
t=int(rand()*size(blocktype));
|
||||
if(t!=3){
|
||||
stick_count+=1;
|
||||
if(stick_count==8)
|
||||
(t,stick_count)=(3,0);
|
||||
}else
|
||||
stick_count=0;
|
||||
last_type=t;
|
||||
return t;
|
||||
var counter=0;
|
||||
var package=[0,1,2,3,4,5,6];
|
||||
var exchange=func(){
|
||||
for(var i=6;i>=0;i-=1){
|
||||
var index=int(i*rand());
|
||||
(package[i],package[index])=(package[index],package[i]);
|
||||
}
|
||||
}
|
||||
|
||||
var block={
|
||||
x:0,
|
||||
y:0,
|
||||
|
@ -82,9 +77,13 @@ var block={
|
|||
new:func(x=0,y=0){
|
||||
(me.x,me.y)=(x,y);
|
||||
me.rotate=0;
|
||||
var t=typechange(int(rand()*size(blocktype)));
|
||||
me.type=blocktype[package[counter]];
|
||||
counter+=1;
|
||||
if(counter==7){
|
||||
exchange();
|
||||
counter=0;
|
||||
}
|
||||
|
||||
me.type=blocktype[t];
|
||||
me.shape=blockshape[me.type[me.rotate]];
|
||||
|
||||
me.color=color_count;
|
||||
|
@ -293,7 +292,8 @@ var main=func(){
|
|||
);
|
||||
|
||||
rand(time(0));
|
||||
var map=mapgen(mapx:12,mapy:15);
|
||||
exchange();
|
||||
var map=mapgen(mapx:12,mapy:18);
|
||||
|
||||
libkey.getch();
|
||||
print("\ec");
|
||||
|
|
Loading…
Reference in New Issue