From 1e897d0ee0a942808b4e5c7cb9af0ce10ad5458e Mon Sep 17 00:00:00 2001 From: ascii benefactor Date: Fri, 25 Jun 2021 19:50:24 -0400 Subject: [PATCH] added inventory --- findthrash.bas | 129 +++++++++++++++++++++++++++++-------------------- 1 file changed, 77 insertions(+), 52 deletions(-) diff --git a/findthrash.bas b/findthrash.bas index d0b15d8..c3840e4 100644 --- a/findthrash.bas +++ b/findthrash.bas @@ -9,18 +9,16 @@ REM GET DICT FILE WITH ITEM NAMES ' x:28,y14 linenb=10 colnb=18 +statln=linenb+3 win=false score=0 pl={hp:30,hpx:30,name:"testacles", -dmg:3} +dmg:3,nextinv:1} mob={} robx=fix(rnd*colnb) roby=fix(rnd*linenb) -kitx=fix(rnd*colnb) -kity=fix(rnd*linenb) -kitchar = charget ' amount mob -amob = 7 +amob = 2 ' amount thrash (items) amount = 5 endgame=false @@ -28,47 +26,56 @@ thrash = array("{0:{}}") map={} rem prg start -genThrash(amount) -borderscr() +label start dbinit() +genThrash(amount) + +' mob = genmob(1) rem grafx loop waiting for win + +borderscr() repeat - ' if win - if robx = kitx AND roby = kity then - win=true + ' if dead + if pl.hp =< 0 then + win=false endgame=true locate linenb,1 - print " You found kitten!" + print " You died" fi - + itemcolscan() kbctrl() printobj() + ' printmob() printui() - printrob() - itemcolscan() -until win +until endgame REM ======FUNCTION SPACE =========- -sub remtrash(x,y) - locate thrash[y].y,thrash[x].x - ? " " -end -' scan if ypur om the same tile as item +' scan if your on the same tile as item sub itemcolscan() - for i = 1 to amount - if robx=thrash[i].x and roby=thrash[i].y then - locate linenb+3,2 - print thrash[i].text - thrash[i].onscreen = false -fi -next - + for iscan = 0 to amount + if robx=thrash[iscan].x and roby=thrash[iscan].y then + ' if @ is on item note item num + locate linenb+3,2 + print thrash[iscan].name + onitem=iscan + fi +next + end + +sub takeitem() + locate statln,1 + print "you take " + thrash[onitem].onscreen=false + inv[pl.nextinv] =thrash[onitem].obj + pl.nextinv = pl.nextinv + 1 +end + ' KEYBOARD CMD and scr bounds scan sub kbctrl() kb = inkey @@ -97,13 +104,16 @@ sub kbctrl() dir="y+" fi case "q" - ' debug show all continupusly updated content on screen + + cls locate 3,3 - print "testt" - + print "buyyyyyye" + stop + case "p" + printinfo() + case "t" + takeitem() end select -' print again to show changes - printrob() end sub printui() @@ -111,21 +121,22 @@ sub printui() print "HP: "+pl.hp locate linenb+2,8 ? "dmg"+pl.dmg + ' status bar 1 locate linenb+3,1 - print pl.name -end - -sub monscan(arg) - + print "~~~~~~~~~~~~~~~~~~" + ' status bar 2 is inside the bottom wall... so linenb+1 end -sub printrob() - locate roby,robx - print "@" +sub printmob() + for i=1 to amob + my = mob[i].y + mx = mob[i].x + locate my,mx + print mob[i].ch + next end - sub printobj() rem print thrash for it=1 to amount @@ -140,9 +151,8 @@ sub printobj() thrash[it].y = 0 fi next - rem and aftr print kitty - locate kity,kitx - print "@" + locate roby,robx + print "@" end func charget() @@ -168,17 +178,19 @@ sub genthrash(amount) for index = 1 to amount local tx = fix(rnd*colnb) local ty = fix(rnd*linenb) + thrash[index].name = "def" thrash[index].obj = weap.knife - itnam=thrash[index].obj.name thrash[index].x = tx thrash[index].y = ty - thrash[index].ch = charge - thrash[index].text = itnam - thrash[index].onscreen = true + thrash[index].ch = charget + thrash[index].text = "testtext" + thrash[index].onscreen = true + thrash[index].take = false next - +' proto represents the base item +' before stat mod from algory func genitem() - local proto={} + proto={} proto = weap.knife return proto end @@ -188,6 +200,7 @@ func dbinit() ' tload weapdb.dat, byref weap weap={} weap.knife = {name:knife,dmg:3} + inv={} end sub borderscr() @@ -203,7 +216,8 @@ next end func genmob(lvl) - for i = 0 to amob + for i = 1 to amob + pmob={} pmob[i] = {dmg:2,hpx:30} pmob[i] = {hp: 30,name:jello} @@ -211,6 +225,17 @@ func genmob(lvl) pmob[i].y =fix(rnd*linenb) pmob[i].alive = true pmob[i].onscreen = true + pmob[i].ch="!" next + return pmob +end + +sub printinfo() + cls + repeat + locate 3,3 + print inv + until inkey == "v" + stop end