Improvements...

This commit is contained in:
asciibene 2022-04-11 23:02:57 -04:00
parent 640c3071a4
commit 6fbccc1123
1 changed files with 31 additions and 11 deletions

View File

@ -37,12 +37,12 @@ end
-- -------------- START FUNC ----------- -- -------------- START FUNC -----------
function start() function start()
nc.setcurshape("BLOCK") nc.setcurshape("BAR")
nc.clrscr() nc.clrscr()
-- Make X functions -- Make X functions
map=mkmat() map=mkmat()
p=mkpointer() p=mkpointer()
-- Now main loop -- Now main loop
main() main()
end end
@ -56,6 +56,9 @@ function drawmap()
print(map[ix][iy]) print(map[ix][iy])
end end
end end
-- XXX draw last info line XXX
nc.gotoxy(0,MSIZE_Y+1)
print(p.x.." . "..p.y.." ")
end end
function drawmap_fg() -- Draw map foreground function drawmap_fg() -- Draw map foreground
@ -65,12 +68,10 @@ end
----------- main func ----- ----------- main func -----
function main() function main()
while exitbool~=true do while exitbool~=true do
if see==false then if await_cmd()~=0 then
drawmap() drawmap()
drawmap_fg() drawmap_fg()
see=true end
end
await_cmd()
end end
exit() exit()
end end
@ -79,8 +80,6 @@ end
function exit() -- Exits gracefully function exit() -- Exits gracefully
nc.clrscr() nc.clrscr()
printul("Goodbye...") printul("Goodbye...")
end end
function mkpointer(pn) function mkpointer(pn)
@ -108,21 +107,42 @@ function await_cmd()
exitbool=true exitbool=true
elseif k=="t" then elseif k=="t" then
showmesg("This is a test") showmesg("This is a test")
elseif k=="c" then
changep()
elseif k=="." then
paint(p.x,p.y,p.glyph)
elseif k=="x" then
paint(p.x,p.y," ")
elseif k=="o" then
-- TODO Set color
else
return 0
end end
end
function paint(px,py,pg)
map[px][py]=pg
end end
function movep(dx,dy) function movep(dx,dy)
p.x=p.x+dx p.x=p.x+dx
p.y=p.y+dy p.y=p.y+dy
see=false end
function changep()
local c
showmesg("Press Enter and a new char:")
while c==nil do
c=string.char(nc.getch())
end
p.glyph=c
end end
function showmesg(msg) function showmesg(msg)
nc.gotoxy(1,1) nc.gotoxy(1,1)
print(msg) print(msg)
nc.wait() nc.wait()
see=false
end end
-- ------------------------------------------ -- ------------------------------------------