Files
find-thrash/findthrash.bas
T

188 lines
2.8 KiB
VB.net
Raw 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-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",
dmg:3}
mob={}
2021-06-15 01:12:02 -04:00
robx=fix(rnd*colnb)
roby=fix(rnd*linenb)
kitx=fix(rnd*colnb)
kity=fix(rnd*linenb)
kitchar = charget
2021-06-16 05:04:12 -04:00
' amount mob
amob = 7
' 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
genThrash(amount)
2021-06-15 04:58:16 -04:00
borderscr()
2021-06-15 01:12:02 -04:00
rem grafx loop waiting for win
repeat
if robx = kitx AND roby = kity then
win=true
2021-06-16 05:04:12 -04:00
endgame=true
2021-06-15 04:58:16 -04:00
locate linenb,1
print " You found kitten!"
2021-06-15 01:12:02 -04:00
fi
printobj()
printui()
2021-06-15 04:58:16 -04:00
printrob()
2021-06-15 01:12:02 -04:00
collscan()
2021-06-16 05:04:12 -04:00
2021-06-15 01:12:02 -04:00
kbctrl
until win
REM ======FUNCTION SPACE =========-
2021-06-16 05:04:12 -04:00
sub remtrash(x,y)
locate thrash[y].y,thrash[x].x
2021-06-15 01:12:02 -04:00
? " "
end
sub collscan()
2021-06-15 04:58:16 -04:00
for i = 1 to amount
2021-06-15 01:12:02 -04:00
if robx=thrash[i].x and roby=thrash[i].y then
2021-06-15 04:58:16 -04:00
locate linenb+3,2
2021-06-15 01:12:02 -04:00
print thrash[i].text
2021-06-15 04:58:16 -04:00
thrash[i].active = false
2021-06-15 01:12:02 -04:00
fi
next
end
sub kbctrl()
kb = inkey
' delete old rob
locate roby,robx
? " "
select case kb
case "h"
if robx > 0 then
robx = robx-1
dir="x-"
fi
case "j"
if roby < linenb then
roby = roby+1
dir="x+"
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
2021-06-15 04:58:16 -04:00
case "q"
2021-06-16 05:04:12 -04:00
print "testt"
2021-06-15 01:12:02 -04:00
end select
printrob()
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
locate linenb+3,1
print pl.name
2021-06-15 01:12:02 -04:00
end
sub printrob()
locate roby,robx
print "@"
end
sub printobj()
rem print thrash
for it=1 to amount
2021-06-15 04:58:16 -04:00
if thrash[it].active 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
thrash[it].x = 0
thrash[it].y = 0
fi
2021-06-15 01:12:02 -04:00
next
2021-06-16 05:04:12 -04:00
rem print kitty
2021-06-15 04:58:16 -04:00
locate kity,kitx
print kitchar
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
return "÷"
case 6
return "$"
2021-06-15 01:12:02 -04:00
end select
end
2021-06-16 05:04:12 -04:00
rem Items are represented by thrash
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)
thrash[index].x = tx
thrash[index].y = ty
thrash[index].ch = charget
2021-06-15 04:58:16 -04:00
thrash[index].text = "lazy"
thrash[index].active = true
2021-06-16 05:04:12 -04:00
rem thrash[index].item = get
2021-06-15 01:12:02 -04:00
next
end
func textget()
r = rnd()*len(dict)
return 'placeholder'
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-15 01:12:02 -04:00
? "X"
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)
for i = 0 to amob
pmob[i] = {hp:30,name:jello}
next
2021-06-15 01:12:02 -04:00
end