we’re getting very close to having item generation finished.
changed the colour scheme a bit too.
0 rem bagquest
9 rem constants
10 white = 5
11 red = 28
12 yellow = 158
13 blue = 154
14 green = 30
15 lightred = 150
16 purple = 156
17 dark = 151
19 brown = 129
rem 0 - black
rem 1 - white
rem 2 - red
rem 3 - cyan
rem 4 - purple
rem 5 - green
rem 6 - blue
rem 7 - yellow
rem 8 - orange
rem 9 - brown
rem 10 - light red
rem 11 - dark grey
rem 12 - grey
rem 13 - light green
rem 14 - light blue
rem 15 - light grey
99 rem initialisation
100 print chr$(147)
110 poke 53280,7:rem set border yellow
120 poke 53281,14:rem set bg light blue
130 dim w(40,10):rem world array
140 dim b(10):rem bag parent connection
150 dim bx(10):rem bag entry positions
160 dim by(10):rem bag exit positions
170 cb = 1:rem start in bag 1 (main world)
180 p = int(rnd(1)*40)+1:rem player position on init
190 hb=10:rem start with 10 bags (??)
200 bf=1
499 rem initialise bags
500 for i=1 to 10
510 for j=1 to 40
520 w(j,i)=0
530 next j
540 b(i)=0
550 bx(i)=0
560 by(i)=0
570 next i
580 w(p,1)=1:rem place player in bag 1
590 rem add items to bags, 10 items each
600 for i=1 to 10:rem 10 bags
610 for j=1 to 10:rem 10 items
620 q=int(rnd(1)*40)+1
630 if w(q,i)=0 then w(q,i)=int(rnd(1)*6)+4:goto 650
640 goto 620
650 next j
660 next i
rem 0 = . empty space
rem 1 = @ player
rem 2 = B placed bag
rem 3 = X bag exit
rem 4 = L loot
rem 5 = K key
rem 6 = G goblin
rem 7 = D door
rem 8 = W magic wand
rem 9 = M treasure map
999 rem draw current bag
1000 rem cls
1010 print tab(10);chr$(yellow);"*** bagquest ***":print
1015 print tab(20);chr$(white);" -> bag: ";cb;"."
1020 print chr$(yellow);"=-=-=-=-========================-=-=-=-="
1030 for i=1 to 40
1040 if w(i,cb)=0 then print chr$(dark);".";:goto 1500
1050 if w(i,cb)=1 then print chr$(white);"@";:goto 1500
1060 if w(i,cb)=2 then print chr$(blue);"b";:goto 1500
1070 if w(i,cb)=3 then print chr$(purple);"x";:goto 1500
1080 if w(i,cb)=4 then print chr$(yellow);"l";:goto 1500
1090 if w(i,cb)=5 then print chr$(red);"k";:goto 1500
1100 if w(i,cb)=6 then print chr$(green);"g";:goto 1500
1110 if w(i,cb)=7 then print chr$(brown);"d";:goto 1500
1120 if w(i,cb)=8 then print chr$(red);"w";:goto 1500
1130 if w(i,cb)=9 then print chr$(brown);"m";:goto 1500
1500 next i
1510 print
1520 print chr$(yellow);"=-=-=-=-========================-=-=-=-="
1999 rem status display
2000 print chr$(white);"you have ";hb;" bag(s)."
2010 print chr$(white);"you have found ";bf;" bag-worlds."
2020 print chr$(white);"position: ";p
2030 print
2040 print chr$(yellow);"=-=-=-=-========================-=-=-=-="
2050 if cb > 1 then print chr$(white);"find exit (x) to return."
2060 print chr$(white);"controls: a/d=move. i=info. q=quit."
2999 rem input
3000 get a$:if a$="" then 3000
3010 op=p
3020 if a$="a" and p>1 then w(p,cb)=0:p=p-1:gosub 4000:goto 1000
3030 if a$="d" and p<40 then w(p,cb)=0:p=p+1:gosub 4000:goto 1000
3040 if a$="i" then gosub 8000
3050 if a$="b" then and hb>0 gosub 5000
3060 if a$="x" then gosub 7000
3070 if a$="q" then print "game over":end
3080 goto 1000
3999 rem collisions
4000 if w(p,cb)=0 then w(p,cb)=1:return
4010 if w(p,cb)=2 then gosub 6000:return
4020 if w(p,cb)=3 then gosub 7000:return
4030 if w(p,cb)=4 then l=l+1:w(p,cb)=1:return
4040 if w(p,cb)=5 then k=k+1:w(p,cb)=1:return
4050 if w(p,cb)=6 then print chr$(green);"a goblin!":gosub 9100:return
4060 if w(p,cb)=7 then gosub 9200:return
4070 if w(p,cb)=8 then mw=mw+1:w(p,cb)=1:print chr$(red);"wand!":gosub 9000:return
4080 if w(p,cb)=9 then m=m+1:w(p,cb)=1:print chr$(brown);"map!":gosub 9000:return
4090 return
4999 rem place a bag
5000 if w(p,cb)<>0 then print "cannot place bag here.":return
5010 if hb<=0 then print "you have no bags.":return
5020 for newbag=1 to 10
5030 if newbag=cb then goto 5050
5040 if b(newbag)=0 then goto 5080
5050 next newbag
5060 rem fall into here
5070 print "too many bags already.":return
5080 rem record where this bag leads
5090 b(newbag)=cb
5100 bx(newbag)=p
5110 by(newbag)=cb
5120 rem create new empty bag
5130 for i=1 to 40:w(i,newbag)=0:next i
5140 rem place exit in new bag
5150 bagexit=int(rnd(1)*40)+1
5160 w(bagexit,newbag)=3
5170 rem place entry in current bag
5180 w(p,cb)=2
5190 hb=hb-1
5200 bf=bf+1
5210 print "bag placed. step on b to enter new bag."
5220 return
5999 rem enter placed bag
6000 for newbag=1 to 10
if newbag=cb then goto
if bx(newbag)=p and by(newbag)=cb then goto
next newbag
print "error: broken bag link.":return
rem switch to the new bag
w(p,cb)=0
cb=newbag
p=int(rnd(1)*40)+1
rem find empty spot in existing bag
for try=1 to 100
if w(p,cb)=0 then goto
p=int(rnd(1)*40)+1
next try
w(p,cb)=1
print "you enter a new bag..."
return
6999 rem use bag exit
7000
7999 rem info screen
8000