settings$
= "maze.set":
GOSUB re
'preparation -------------------------------------------------------------------------------------------------------------------------------------------
IF maze_x
/ 2 = INT(maze_x
/ 2) THEN maze_x
= maze_x
+ 1 IF maze_y
/ 2 = INT(maze_y
/ 2) THEN maze_y
= maze_y
+ 1 monx
= (maze_x
+ 10) * 8: mony
= (maze_y
+ 9) * 16: kep
= _NEWIMAGE(monx
, mony
, 32):
SCREEN kep
d(0, 0) = 0: d(0, 1) = -1: d(1, 0) = 0: d(1, 1) = 1: d(2, 0) = -1: d(2, 1) = 0: d(3, 0) = 1: d(3, 1) = 0
k$(0) = "±" 'fal / adjustable wall
k$(1) = " " 'nem bejart ureg / non walked road
k$(2) = "W" 'lehetoseg / possible way
k$(3) = "Ű" 'szilard fal / standard wall
k$(4) = " " 'bejart ureg / walked road
k$(5) = " " 'belepesi pont / entry point
k$(6) = "X" 'enemies
k$(7) = "<" 'me left
k$(8) = ">" 'me right
mea = 8
DIM maze
(maze_x
- 1, maze_y
- 1) AS _BYTE '0-fal 1-ureg 2-lehetoseg DIM en
(enemies
- 1, 2) '0-x 1-y 2-vector (d-array)
'create empty maze --------------------------------------------------------------------------------------------------------------------------------------
FOR tx
= 0 TO maze_x
- 1:
FOR ty
= 0 TO maze_y
- 1: k
= 0 IF tx
= 0 OR ty
= 0 OR tx
= maze_x
- 1 OR ty
= maze_y
- 1 THEN k
= 3 maze
(tx
, ty
) = k:
NEXT ty
, tx
'start position -----------------------------------------------------------------------------------------------------------------------------------------
'way searching ------------------------------------------------------------------------------------------------------------------------------------------
FOR tx
= 0 TO maze_x
- 1:
FOR ty
= 0 TO maze_y
- 1 van = 0
vpx1 = tx + d(t, 0): vpy1 = ty + d(t, 1): vpx2 = tx + d(t, 0) * 2: vpy2 = ty + d(t, 1) * 2
f
= (vpx2
> maze_x
- 1 OR vpx2
< 0) OR (vpy2
> maze_y
- 1 OR vpy2
< 0) IF maze
(vpx1
, vpy1
) = 0 AND maze
(vpx2
, vpy2
) = 1 THEN FOR t2
= 0 TO 3: vpx3
= vpx2
+ d
(t2
, 0): vpy3
= vpy2
+ d
(t2
, 1):
IF maze
(vpx3
, vpy3
) = 4 THEN GOTO kovi
maze(vpx1, vpy1) = 2: way(wdb, 0) = tx: way(wdb, 1) = ty: way(wdb, 2) = t: wdb = wdb + 1
kovi:
hovax = way(aw, 0) + d(way(aw, 2), 0) * t: hovay = way(aw, 1) + d(way(aw, 2), 1) * t
IF (maze
(hovax
, hovay
) = 2) OR (maze
(hovax
, hovay
) = 1) THEN maze
(hovax
, hovay
) = 4
FOR tx
= 0 TO maze_x
- 1:
FOR ty
= 0 TO maze_y
- 1:
IF maze
(tx
, ty
) = 2 THEN maze
(tx
, ty
) = 0
'entry point 1
sx
= 0: sy
= 3:
IF maze
(sx
+ 1, sy
) <> 4 THEN sy
= sy
+ 1maze(sx, sy) = 5
mex = sx: mey = sy 'my start position
'entry point 2
sx
= maze_x
- 1: sy
= maze_y
- 3:
IF maze
(sx
- 1, sy
) <> 4 THEN sy
= sy
- 1maze(sx, sy) = 5
endx = sx: endy = sy
' it has taken so far to build the maze. contained in the maze array ------------------------------------------------------------------------------------------------
'create enemies
en
(t
, 0) = sx: en
(t
, 1) = sy: en
(t
, 2) = INT(4 * RND(1)): maze
(sx
, sy
) = 6:
NEXT t
'inkey-commands
CASE "q": enemies
= enemies
- 1:
GOTO wr:
CASE "w": enemies
= enemies
+ 1:
GOTO wr
'moving enemies
vpx
= en
(t
, 0) + d
(en
(t
, 2), 0): vpy
= en
(t
, 1) + d
(en
(t
, 2), 1): f1
= (vpx
> maze_x
- 2 OR vpx
< 1) OR (vpy
> maze_y
- 2 OR vpy
< 1) f2
= (maze
(vpx
, vpy
) = 0 OR maze
(vpx
, vpy
) = 3) OR INT(5 * RND(1)) = 0 'f2 = (maze(vpx, vpy) <> 4) AND (maze(vpx, vpy) <> 6)
maze(en(t, 0), en(t, 1)) = 4: en(t, 0) = en(t, 0) + d(en(t, 2), 0): en(t, 1) = en(t, 1) + d(en(t, 2), 1): maze(en(t, 0), en(t, 1)) = 6
'moving me
t = 4 't is my array vector
vpx = mex + d(t, 0): vpy = mey + d(t, 1)
maze(mex, mey) = 4: mex = mex + d(t, 0): mey = mey + d(t, 1): maze(mex, mey) = mea
12:
drawing: 'drawing
sx
= INT((monx
/ 8 - maze_x
) / 2) + 1: sy
= 2PRINT "N - new track":
PRINT "Q/W - pieces of enemies"; enemies:
PRINT "A/S - maze X"; maze_x
PRINT "Y/X - maze Y"; maze_y:
PRINT "+/- - speed"; speed:
PRINT "R - reset settings"
wr:
IF maze_x
< 17 THEN maze_x
= 17 IF enemies
< 0 THEN enemies
= 0