41 lines
896 B
Plaintext
41 lines
896 B
Plaintext
|
array levelfile 13 allot
|
||
|
var ilevelfile
|
||
|
: emit-levelfile ( c -- )
|
||
|
dup sp != if
|
||
|
ilevelfile @ levelfile + b!
|
||
|
1 ilevelfile +!
|
||
|
0 ilevelfile @ levelfile + b!
|
||
|
else drop then ;
|
||
|
|
||
|
: 0padplace ( n place -- ) < if [ key 0 lit ] emit then ;
|
||
|
: 0pad ( n -- )
|
||
|
dup 10 0padplace
|
||
|
dup 100 0padplace
|
||
|
dup 1000 0padplace
|
||
|
dup 10000 0padplace
|
||
|
. ;
|
||
|
|
||
|
: genlevelfn ( n ext -- s )
|
||
|
0 ilevelfile !
|
||
|
task-emit @ >rot ' emit-levelfile task-emit !
|
||
|
s" lev" type swap 0pad type
|
||
|
task-emit ! levelfile ;
|
||
|
|
||
|
: levelsrc ( n -- ) s" .jor" genlevelfn ;
|
||
|
: levelmap ( n -- ) s" .map" genlevelfn ;
|
||
|
|
||
|
intern end.jor
|
||
|
|
||
|
-1 const LEV_END
|
||
|
|
||
|
var current-level
|
||
|
: load-new-level ( n -- )
|
||
|
dup current-level !
|
||
|
dup 0 > if dup levelmap load-map then
|
||
|
dup LEV_END =
|
||
|
if drop end.jor
|
||
|
else levelsrc
|
||
|
then loadfile ;
|
||
|
|
||
|
: save-level ( -- ) current-level @ levelmap save-map ;
|