RL game in small basic
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
find-thrash/findthrash.bas

241 lines
3.9 KiB

REM SmallBASIC
REM Small RL game forked of my Robotfindskitten game
REM BY ASCIIBENEFACTOR
rem unfinished !
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,nextinv:1}
mob={}
robx=fix(rnd*colnb)
roby=fix(rnd*linenb)
' amount mob
amob = 2
' amount thrash (items)
amount = 5
endgame=false
thrash = array("{0:{}}")
map={}
rem prg start
label start
dbinit()
genThrash(amount)
' mob = genmob(1)
rem grafx loop waiting for win
borderscr()
repeat
' if dead
if pl.hp =< 0 then
win=false
endgame=true
locate linenb,1
print " You died"
fi
itemcolscan()
kbctrl()
printobj()
' printmob()
printui()
until endgame
REM ======FUNCTION SPACE =========-
' scan if your on the same tile as item
sub itemcolscan()
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
' delete old rob
locate roby,robx
? " "
select case kb
case "h"
if robx > 0 then
robx = robx-1
fi
' if monstscan(dirP
case "j"
if roby < linenb then
roby = roby+1
fi
case "k"
if roby > 0 then
roby = roby-1
dir="y-"
fi
case "l"
if robx < colnb then
robx = robx+1
dir="y+"
fi
case "q"
cls
locate 3,3
print "buyyyyyye"
stop
case "p"
printinfo()
case "t"
takeitem()
end select
end
sub printui()
locate linenb+2,1
print "HP: "+pl.hp
locate linenb+2,8
? "dmg"+pl.dmg
' status bar 1
locate linenb+3,1
print "~~~~~~~~~~~~~~~~~~"
' status bar 2 is inside the bottom wall... so linenb+1
end
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
if thrash[it].onscreen then
local objx = thrash[it].x
local objy = thrash[it].y
locate objy,objx
print thrash[it].ch
else
' put the item in the unaccesible region of screen
thrash[it].x = 0
thrash[it].y = 0
fi
next
locate roby,robx
print "@"
end
func charget()
select case fix(rnd*6)
case 1
return "&"
case 2
return "%"
case 3
return "#"
case 4
return "?"
case 5
return "+"
case 6
return "$"
end select
end
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)
for index = 1 to amount
local tx = fix(rnd*colnb)
local ty = fix(rnd*linenb)
thrash[index].name = "def"
thrash[index].obj = weap.knife
thrash[index].x = tx
thrash[index].y = ty
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()
proto={}
proto = weap.knife
return proto
end
end
func dbinit()
' tload weapdb.dat, byref weap
weap={}
weap.knife = {name:knife,dmg:3}
inv={}
end
sub borderscr()
cls
for i = 0 to linenb+1
locate i+1,colnb+1
? "#"
for i2 = 0 to colnb+1
locate linenb+1,i2
print "X"
next
next
end
func genmob(lvl)
for i = 1 to amob
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
return pmob
end
sub printinfo()
cls
repeat
locate 3,3
print inv
until inkey == "v"
stop
end