find-thrash/findthrash.bas

242 lines
3.9 KiB
QBasic
Raw Permalink Normal View History

2021-06-15 01:12:02 -04:00
REM SmallBASIC
2021-06-16 05:04:12 -04:00
REM Small RL game forked of my Robotfindskitten game
2021-06-15 01:12:02 -04:00
REM BY ASCIIBENEFACTOR
2021-06-16 05:04:12 -04:00
rem unfinished !
2021-06-15 01:12:02 -04:00
REM GET DICT FILE WITH ITEM NAMES
' x:28,y14
linenb=10
2021-06-16 05:04:12 -04:00
colnb=18
2021-06-25 19:50:24 -04:00
statln=linenb+3
2021-06-15 01:12:02 -04:00
win=false
score=0
2021-06-16 05:04:12 -04:00
pl={hp:30,hpx:30,name:"testacles",
2021-06-25 19:50:24 -04:00
dmg:3,nextinv:1}
2021-06-16 05:04:12 -04:00
mob={}
2021-06-15 01:12:02 -04:00
robx=fix(rnd*colnb)
roby=fix(rnd*linenb)
2021-06-16 05:04:12 -04:00
' amount mob
2021-06-25 19:50:24 -04:00
amob = 2
2021-06-16 05:04:12 -04:00
' amount thrash (items)
2021-06-15 01:12:02 -04:00
amount = 5
2021-06-16 05:04:12 -04:00
endgame=false
2021-06-15 01:12:02 -04:00
thrash = array("{0:{}}")
2021-06-15 04:58:16 -04:00
map={}
2021-06-15 01:12:02 -04:00
rem prg start
2021-06-25 19:50:24 -04:00
label start
2021-06-24 01:02:24 -04:00
dbinit()
2021-06-25 19:50:24 -04:00
genThrash(amount)
' mob = genmob(1)
2021-06-15 01:12:02 -04:00
rem grafx loop waiting for win
2021-06-25 19:50:24 -04:00
borderscr()
2021-06-15 01:12:02 -04:00
repeat
2021-06-25 19:50:24 -04:00
' if dead
if pl.hp =< 0 then
win=false
2021-06-16 05:04:12 -04:00
endgame=true
2021-06-15 04:58:16 -04:00
locate linenb,1
2021-06-25 19:50:24 -04:00
print " You died"
2021-06-15 01:12:02 -04:00
fi
2021-06-24 01:02:24 -04:00
2021-06-25 19:50:24 -04:00
itemcolscan()
2021-06-24 01:02:24 -04:00
kbctrl()
2021-06-15 01:12:02 -04:00
printobj()
2021-06-25 19:50:24 -04:00
' printmob()
2021-06-15 01:12:02 -04:00
printui()
2021-06-25 19:50:24 -04:00
until endgame
2021-06-15 01:12:02 -04:00
REM ======FUNCTION SPACE =========-
2021-06-25 19:50:24 -04:00
' scan if your on the same tile as item
2021-06-24 01:02:24 -04:00
sub itemcolscan()
2021-06-25 19:50:24 -04:00
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
2021-06-15 01:12:02 -04:00
end
2021-06-25 19:50:24 -04:00
sub takeitem()
locate statln,1
print "you take "
thrash[onitem].onscreen=false
inv[pl.nextinv] =thrash[onitem].obj
pl.nextinv = pl.nextinv + 1
end
2021-06-24 01:02:24 -04:00
' KEYBOARD CMD and scr bounds scan
2021-06-15 01:12:02 -04:00
sub kbctrl()
kb = inkey
' delete old rob
locate roby,robx
? " "
select case kb
case "h"
if robx > 0 then
robx = robx-1
fi
2021-06-24 01:02:24 -04:00
' if monstscan(dirP
2021-06-15 01:12:02 -04:00
case "j"
if roby < linenb then
roby = roby+1
fi
case "k"
if roby > 0 then
2021-06-24 01:02:24 -04:00
roby = roby-1
2021-06-15 01:12:02 -04:00
dir="y-"
fi
case "l"
if robx < colnb then
robx = robx+1
dir="y+"
fi
2021-06-15 04:58:16 -04:00
case "q"
2021-06-25 19:50:24 -04:00
cls
2021-06-24 01:02:24 -04:00
locate 3,3
2021-06-25 19:50:24 -04:00
print "buyyyyyye"
stop
case "p"
printinfo()
case "t"
takeitem()
2021-06-15 01:12:02 -04:00
end select
end
sub printui()
2021-06-16 05:04:12 -04:00
locate linenb+2,1
print "HP: "+pl.hp
locate linenb+2,8
? "dmg"+pl.dmg
2021-06-25 19:50:24 -04:00
' status bar 1
2021-06-16 05:04:12 -04:00
locate linenb+3,1
2021-06-25 19:50:24 -04:00
print "~~~~~~~~~~~~~~~~~~"
' status bar 2 is inside the bottom wall... so linenb+1
2021-06-24 01:02:24 -04:00
end
2021-06-25 19:50:24 -04:00
sub printmob()
for i=1 to amob
my = mob[i].y
mx = mob[i].x
locate my,mx
print mob[i].ch
next
2021-06-15 01:12:02 -04:00
end
sub printobj()
rem print thrash
for it=1 to amount
2021-06-24 01:02:24 -04:00
if thrash[it].onscreen then
2021-06-15 01:12:02 -04:00
local objx = thrash[it].x
local objy = thrash[it].y
locate objy,objx
print thrash[it].ch
2021-06-16 05:04:12 -04:00
else
2021-06-24 01:02:24 -04:00
' put the item in the unaccesible region of screen
2021-06-16 05:04:12 -04:00
thrash[it].x = 0
thrash[it].y = 0
fi
2021-06-15 01:12:02 -04:00
next
2021-06-25 19:50:24 -04:00
locate roby,robx
print "@"
2021-06-15 01:12:02 -04:00
end
func charget()
2021-06-16 05:04:12 -04:00
select case fix(rnd*6)
2021-06-15 01:12:02 -04:00
case 1
return "&"
case 2
return "%"
case 3
return "#"
case 4
return "?"
2021-06-16 05:04:12 -04:00
case 5
2021-06-24 01:02:24 -04:00
return "+"
2021-06-16 05:04:12 -04:00
case 6
return "$"
2021-06-15 01:12:02 -04:00
end select
end
2021-06-24 01:02:24 -04:00
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
2021-06-15 01:12:02 -04:00
sub genthrash(amount)
for index = 1 to amount
local tx = fix(rnd*colnb)
local ty = fix(rnd*linenb)
2021-06-25 19:50:24 -04:00
thrash[index].name = "def"
2021-06-24 01:02:24 -04:00
thrash[index].obj = weap.knife
2021-06-15 01:12:02 -04:00
thrash[index].x = tx
thrash[index].y = ty
2021-06-25 19:50:24 -04:00
thrash[index].ch = charget
thrash[index].text = "testtext"
thrash[index].onscreen = true
thrash[index].take = false
2021-06-15 01:12:02 -04:00
next
2021-06-25 19:50:24 -04:00
' proto represents the base item
' before stat mod from algory
2021-06-24 01:02:24 -04:00
func genitem()
2021-06-25 19:50:24 -04:00
proto={}
2021-06-24 01:02:24 -04:00
proto = weap.knife
return proto
end
2021-06-15 01:12:02 -04:00
end
2021-06-24 01:02:24 -04:00
func dbinit()
' tload weapdb.dat, byref weap
weap={}
weap.knife = {name:knife,dmg:3}
2021-06-25 19:50:24 -04:00
inv={}
2021-06-15 01:12:02 -04:00
end
sub borderscr()
cls
for i = 0 to linenb+1
2021-06-16 05:04:12 -04:00
locate i+1,colnb+1
2021-06-24 01:02:24 -04:00
? "#"
2021-06-15 01:12:02 -04:00
for i2 = 0 to colnb+1
locate linenb+1,i2
print "X"
next
next
2021-06-16 05:04:12 -04:00
end
func genmob(lvl)
2021-06-25 19:50:24 -04:00
for i = 1 to amob
pmob={}
2021-06-24 01:02:24 -04:00
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
2021-06-25 19:50:24 -04:00
pmob[i].ch="!"
2021-06-16 05:04:12 -04:00
next
2021-06-25 19:50:24 -04:00
return pmob
end
sub printinfo()
cls
repeat
locate 3,3
print inv
until inkey == "v"
stop
2021-06-24 01:02:24 -04:00
end