neuttower/level.jor

43 lines
975 B
Plaintext
Raw Normal View History

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
2020-04-10 15:27:25 +00:00
-2 const LEV_QUIT
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 ;
2020-04-10 15:27:25 +00:00
: savegame save.sav overwrite current-level @ fput close ;