Compare commits

...

2 Commits

Author SHA1 Message Date
ascii benefactor
1e897d0ee0 added inventory 2021-06-25 19:50:24 -04:00
ascii benefactor
3b19e00caa changed file 2021-06-24 01:02:24 -04:00

View File

@ -9,18 +9,16 @@ REM GET DICT FILE WITH ITEM NAMES
' x:28,y14 ' x:28,y14
linenb=10 linenb=10
colnb=18 colnb=18
statln=linenb+3
win=false win=false
score=0 score=0
pl={hp:30,hpx:30,name:"testacles", pl={hp:30,hpx:30,name:"testacles",
dmg:3} dmg:3,nextinv:1}
mob={} mob={}
robx=fix(rnd*colnb) robx=fix(rnd*colnb)
roby=fix(rnd*linenb) roby=fix(rnd*linenb)
kitx=fix(rnd*colnb)
kity=fix(rnd*linenb)
kitchar = charget
' amount mob ' amount mob
amob = 7 amob = 2
' amount thrash (items) ' amount thrash (items)
amount = 5 amount = 5
endgame=false endgame=false
@ -28,45 +26,57 @@ thrash = array("{0:{}}")
map={} map={}
rem prg start rem prg start
label start
dbinit()
genThrash(amount) genThrash(amount)
borderscr()
' mob = genmob(1)
rem grafx loop waiting for win rem grafx loop waiting for win
borderscr()
repeat repeat
if robx = kitx AND roby = kity then ' if dead
win=true if pl.hp =< 0 then
win=false
endgame=true endgame=true
locate linenb,1 locate linenb,1
print " You found kitten!" print " You died"
fi fi
itemcolscan()
kbctrl()
printobj() printobj()
' printmob()
printui() printui()
printrob()
collscan()
kbctrl
until win until endgame
REM ======FUNCTION SPACE =========- REM ======FUNCTION SPACE =========-
sub remtrash(x,y) ' scan if your on the same tile as item
locate thrash[y].y,thrash[x].x sub itemcolscan()
? " " for iscan = 0 to amount
end if robx=thrash[iscan].x and roby=thrash[iscan].y then
' if @ is on item note item num
sub collscan() locate linenb+3,2
for i = 1 to amount print thrash[iscan].name
if robx=thrash[i].x and roby=thrash[i].y then onitem=iscan
locate linenb+3,2 fi
print thrash[i].text
thrash[i].active = false
fi
next next
end 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() sub kbctrl()
kb = inkey kb = inkey
' delete old rob ' delete old rob
@ -76,16 +86,16 @@ sub kbctrl()
case "h" case "h"
if robx > 0 then if robx > 0 then
robx = robx-1 robx = robx-1
dir="x-"
fi fi
' if monstscan(dirP
case "j" case "j"
if roby < linenb then if roby < linenb then
roby = roby+1 roby = roby+1
dir="x+"
fi fi
case "k" case "k"
if roby > 0 then if roby > 0 then
roby = roby-1 roby = roby-1
dir="y-" dir="y-"
fi fi
case "l" case "l"
@ -94,9 +104,16 @@ sub kbctrl()
dir="y+" dir="y+"
fi fi
case "q" case "q"
print "testt"
cls
locate 3,3
print "buyyyyyye"
stop
case "p"
printinfo()
case "t"
takeitem()
end select end select
printrob()
end end
sub printui() sub printui()
@ -104,33 +121,38 @@ sub printui()
print "HP: "+pl.hp print "HP: "+pl.hp
locate linenb+2,8 locate linenb+2,8
? "dmg"+pl.dmg ? "dmg"+pl.dmg
' status bar 1
locate linenb+3,1 locate linenb+3,1
print pl.name print "~~~~~~~~~~~~~~~~~~"
' status bar 2 is inside the bottom wall... so linenb+1
end end
sub printrob() sub printmob()
locate roby,robx for i=1 to amob
print "@" my = mob[i].y
mx = mob[i].x
locate my,mx
print mob[i].ch
next
end end
sub printobj() sub printobj()
rem print thrash rem print thrash
for it=1 to amount for it=1 to amount
if thrash[it].active then if thrash[it].onscreen then
local objx = thrash[it].x local objx = thrash[it].x
local objy = thrash[it].y local objy = thrash[it].y
locate objy,objx locate objy,objx
print thrash[it].ch print thrash[it].ch
else else
' put the item in the unaccesible region of screen
thrash[it].x = 0 thrash[it].x = 0
thrash[it].y = 0 thrash[it].y = 0
fi fi
next next
rem print kitty locate roby,robx
locate kity,kitx print "@"
print kitchar
end end
func charget() func charget()
@ -144,36 +166,48 @@ func charget()
case 4 case 4
return "?" return "?"
case 5 case 5
return "÷" return "+"
case 6 case 6
return "$" return "$"
end select end select
end end
rem Items are represented by thrash rem Items are represented by thrash so this func also gens items stats
' assisigning it to the thrash[x].obj object. which will then go as such in the pl inv
sub genthrash(amount) sub genthrash(amount)
for index = 1 to amount for index = 1 to amount
local tx = fix(rnd*colnb) local tx = fix(rnd*colnb)
local ty = fix(rnd*linenb) local ty = fix(rnd*linenb)
thrash[index].name = "def"
thrash[index].obj = weap.knife
thrash[index].x = tx thrash[index].x = tx
thrash[index].y = ty thrash[index].y = ty
thrash[index].ch = charget thrash[index].ch = charget
thrash[index].text = "lazy" thrash[index].text = "testtext"
thrash[index].active = true thrash[index].onscreen = true
rem thrash[index].item = get thrash[index].take = false
next next
' proto represents the base item
' before stat mod from algory
func genitem()
proto={}
proto = weap.knife
return proto
end
end end
func textget() func dbinit()
r = rnd()*len(dict) ' tload weapdb.dat, byref weap
return 'placeholder' weap={}
weap.knife = {name:knife,dmg:3}
inv={}
end end
sub borderscr() sub borderscr()
cls cls
for i = 0 to linenb+1 for i = 0 to linenb+1
locate i+1,colnb+1 locate i+1,colnb+1
? "X" ? "#"
for i2 = 0 to colnb+1 for i2 = 0 to colnb+1
locate linenb+1,i2 locate linenb+1,i2
print "X" print "X"
@ -182,7 +216,26 @@ next
end end
func genmob(lvl) func genmob(lvl)
for i = 0 to amob for i = 1 to amob
pmob[i] = {hp:30,name:jello} pmob={}
pmob[i] = {dmg:2,hpx:30}
pmob[i] = {hp:
30,name:jello}
pmob[i].x = fix(rnd*colnb)
pmob[i].y =fix(rnd*linenb)
pmob[i].alive = true
pmob[i].onscreen = true
pmob[i].ch="!"
next next
end return pmob
end
sub printinfo()
cls
repeat
locate 3,3
print inv
until inkey == "v"
stop
end