• Please review our updated Terms and Rules here

Applesoft BASIC maze program.

Mister_Alex

Experienced Member
Joined
Sep 1, 2011
Messages
58
Figured I'd share with everyone a simple maze game I coded. The maze itself is unfinished (a random maze generator is in the works) but the programming itself is sound. Please excuse the vague variable names, but 'oldx', 'oldy' and similar names were causing bugs. It would take too long to type this into an actual Apple II, so Calormen's Apple II Javasoft program is the way to go. :)

Anyways, here it is, and I hope people with more time on their hands can update it into something a bit more challenging. :)

Enjoy!

10 home : text
20 dim maze(39,39)
30 c=1 : d=1 : e=1 : f=1

40 htab(11) : vtab(4) : print "'AN UNFINISHED MAZE'"
50 htab(11) : vtab(5) : print "-------------------"
60 htab(5) : vtab(8) : print "* Programmed by Alexander G. Tozzi"
70 htab(5) : vtab(9) : print "* alxmist@aol.com"
80 htab(5) : vtab(10) : print "- - - - - - - - - - - - - - - - -"
90 flash : htab(9) : vtab(16) : print "(PRESS ANY KEY TO BEGIN)" : normal
100 key=peek(49152) : if key<128 then 100
110 poke 49168,0 : gr


140 gosub 1000
150 gosub 2000
160 gosub 3000
170 htab(1) : vtab(21) : print "A: UP"
180 htab(1) : vtab(22) : print "Z: DOWN"
190 htab(10) : vtab(21) : print "J: LEFT Q: QUIT"
200 htab(10) : vtab(22) : print "K: RIGHT"
210 goto 160

1000 for y=0 to 39
1100 for x=0 to 39
1200 read a : maze(x,y)=a
1300 next x : next y
1999 return

2000 for y=0 to 39
2100 for x=0 to 39
2200 a=maze(x,y)
2300 if a=1 then color=2 : plot x,y
2400 if a=0 then color=9 : plot x,y
2500 if a=2 then color=1 : plot x,y
2500 next x : next y
2999 return

3000 key=peek(49152) : if key<128 then key=128
3100 poke 49168,0
3200 button$=chr$(key-128)
3300 if key<>128 then gosub 7000
3400 if button$="A" then if maze(e,f-1)<>1 then f=f-1
3500 if button$="Z" then if maze(e,f+1)<>1 then f=f+1
3600 if button$="J" then if maze(e-1,f)<>1 then e=e-1
3700 if button$="K" then if maze(e+1,f)<>1 then e=e+1
3800 if button$="Q" then end
3900 if maze(e,f)=2 then gosub 8000
3950 color=15 : plot e,f
3999 return

7000 c=e : d=f
7100 color=9 : plot c,d
7999 return

8000 text : home
8100 htab(10) : vtab(5) : print "YOU ESCAPED MY MAZE!"
8200 htab(10) : vtab(6) : print "--------------------"
8300 htab(10) : vtab(10): print "NEXT TIME YOU WON'T"
8400 htab(14) : vtab(11) : PRINT "BE SO LUCKY!"
8500 htab(14) : vtab(12) : print "------------"
8400 flash
8500 htab(9) : vtab(16) : print "(PRESS ANY KEY TO END)"
8600 normal
8700 end

50000 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
50001 data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1
50002 data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1
50003 data 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1
50004 data 1,1,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,1,0,1,0,1,1,1,0,1
50005 data 1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,2,1,0,0,0,1,0,1
50006 data 1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,1,0,1
50007 data 1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1
50008 data 1,1,0,1,0,0,0,1,1,1,1,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1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