CMM2: Maze Generating Program


Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1112
Posted: 05:18am 09 Jun 2020      

Good modification, but I can't get it to work, partially because the maze is printed line by line as it is generated.

Try the following instead:
SUB SetEndpoints
 Local integer cx,cy,px,py
 
 cx = MM.HRes/(WIDTH*3)
 cy = MM.VRes/(LENGTH*2.8)

 ' Door on right side
 px = (WIDTH * 2 + 1) * cx + 20
 py = RND() * LENGTH
 py = py * 2
 mid$(m$(py),len(m$(py))) = " "
 py = py * cy
 box px,py,cx,cy,1,rgb(black),rgb(black)
 
 ' Door on left side
 px = cx + 20
 py = rnd() * LENGTH
 py = py * 2
 mid$(m$(py),1) = " "
 py = py * cy
 box px,py,cx,cy,1,rgb(black),rgb(black)
   
END SUB

The subroutine can be placed at the very end of the program and called just before the "print @(10,530..." line. It makes the openings left and right on screen and in the m$ array. Note there is an awesome new MID$ command!