find-thrash/findthrash.bas

217 lines
3.5 KiB
QBasic

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
win=false
score=0
pl={hp:30,hpx:30,name:"testacles",
dmg:3}
mob={}
robx=fix(rnd*colnb)
roby=fix(rnd*linenb)
kitx=fix(rnd*colnb)
kity=fix(rnd*linenb)
kitchar = charget
' amount mob
amob = 7
' amount thrash (items)
amount = 5
endgame=false
thrash = array("{0:{}}")
map={}
rem prg start
genThrash(amount)
borderscr()
dbinit()
rem grafx loop waiting for win
repeat
' if win
if robx = kitx AND roby = kity then
win=true
endgame=true
locate linenb,1
print " You found kitten!"
fi
kbctrl()
printobj()
printui()
printrob()
itemcolscan()
until win
REM ======FUNCTION SPACE =========-
sub remtrash(x,y)
locate thrash[y].y,thrash[x].x
? " "
end
' scan if ypur om 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
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"
' debug show all continupusly updated content on screen
locate 3,3
print "testt"
end select
' print again to show changes
printrob()
end
sub printui()
locate linenb+2,1
print "HP: "+pl.hp
locate linenb+2,8
? "dmg"+pl.dmg
locate linenb+3,1
print pl.name
end
sub monscan(arg)
end
sub printrob()
locate roby,robx
print "@"
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
rem and aftr print kitty
locate kity,kitx
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].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
next
func genitem()
local proto={}
proto = weap.knife
return proto
end
end
func dbinit()
' tload weapdb.dat, byref weap
weap={}
weap.knife = {name:knife,dmg:3}
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 = 0 to amob
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
next
end