diff options
-rw-r--r-- | functions.cpp | 12 | ||||
-rw-r--r-- | tetris/blocks.prn | 20 | ||||
-rw-r--r-- | tetris/io.prn | 1 | ||||
-rw-r--r-- | tetris/tetris.prn | 1 |
4 files changed, 20 insertions, 14 deletions
diff --git a/functions.cpp b/functions.cpp index 261405e..bd718f8 100644 --- a/functions.cpp +++ b/functions.cpp @@ -428,18 +428,18 @@ unordered_map<string,function<void(vector<Stackitem>&,unordered_map<string,Stack S.emplace_back(S.back().arrval.size()); }}, //leaves the array on the stack, obviously - {"push",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ - BUILTIN_GUARD_STACKSIZE("push",2) + {"arrpush",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ + BUILTIN_GUARD_STACKSIZE("arrpush",2) if(S[S.size()-2].type!=SIT_ARR) - throw string("Top of stack is not an array in builtin 'push'"); + throw string("Top of stack is not an array in builtin 'arrpush'"); S[S.size()-2].arrval.push_back(move(S.back())); S.pop_back(); }}, //leaves the array on the stack, obviously - {"pop",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ - BUILTIN_GUARD_STACKSIZE("pop",1) + {"arrpop",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ + BUILTIN_GUARD_STACKSIZE("arrpop",1) if(S.back().type!=SIT_ARR) - throw string("Top of stack is not an array in builtin 'pop'"); + throw string("Top of stack is not an array in builtin 'arrpop'"); S.back().arrval.pop_back(); }}, {"rand",[](vector<Stackitem> &S,unordered_map<string,Stackitem> &variables){ diff --git a/tetris/blocks.prn b/tetris/blocks.prn index bc37cb9..021a9b5 100644 --- a/tetris/blocks.prn +++ b/tetris/blocks.prn @@ -2,16 +2,20 @@ 7 "b_nblocks" store -15 "b_block1" store 6 "b_block1c" store #I: cyan -23 "b_block2" store 3 "b_block2c" store #L: orange -71 "b_block3" store 4 "b_block3c" store #J: blue -51 "b_block4" store 7 "b_block4c" store #O: yellow (ish) -54 "b_block5" store 2 "b_block5c" store #S: lime -99 "b_block6" store 1 "b_block6c" store #Z: red -114 "b_block7" store 5 "b_block7c" store #T: purple +15 23 71 51 54 99 114 +b_nblocks mkarrayp "b_blocks" store + +6 3 4 7 2 1 5 +b_nblocks mkarrayp "b_blockclrs" store @defun "b_getblock" { #arg: block idx [1..7] - "b_block" swap + get + "b_blocks" + swapoutvar + swap + arridx + swap + "b_blocks" + gstore } @defun "b_drawblock" { #args: x y blockidx diff --git a/tetris/io.prn b/tetris/io.prn index 0d18c44..8c6a320 100644 --- a/tetris/io.prn +++ b/tetris/io.prn @@ -45,6 +45,7 @@ "-" print 1 + dup w < end + pop "+" print #1000000 sleep diff --git a/tetris/tetris.prn b/tetris/tetris.prn index 729f491..ef56158 100644 --- a/tetris/tetris.prn +++ b/tetris/tetris.prn @@ -6,6 +6,7 @@ i 8 < while io_clearscreen io_windowbox + stackdump 0 0 i b_drawblock 1000000 sleep i 1 + "i" store |