A syntax color fix
line:
maze$(INT((currentx% + oldx%) / 2), ((currenty% + oldy%) / 2)) = " "
See at the end, at /2)) the two parenthesis now have the proper different color.
This is the Maze module in info.gsb (included in m2000 installation file)
Module Maze {
width% = 40
height% = 20
\\ we can use DIM maze$(0 to width%,0 to height%)="#"
\\ so we can delete the two For loops
DIM maze$(0 to width%,0 to height%)
FOR x% = 0 TO width%
FOR y% = 0 TO height%
maze$(x%, y%) = "#"
NEXT y%
NEXT x%
currentx% = INT(RND * (width% - 1))
currenty% = INT(RND * (height% - 1))
IF currentx% MOD 2 = 0 THEN currentx%++
IF currenty% MOD 2 = 0 THEN currenty%++
maze$(currentx%, currenty%) = " "
done% = 0
WHILE done% = 0 {
FOR i% = 0 TO 99
oldx% = currentx%
oldy% = currenty%
SELECT CASE INT(RND * 4)
CASE 0
IF currentx% + 2 < width% THEN currentx%+=2
CASE 1
IF currenty% + 2 < height% THEN currenty%+=2
CASE 2
IF currentx% - 2 > 0 THEN currentx%-=2
CASE 3
IF currenty% - 2 > 0 THEN currenty%-=2
END SELECT
IF maze$(currentx%, currenty%) = "#" Then {
maze$(currentx%, currenty%) = " "
maze$(INT((currentx% + oldx%) / 2), ((currenty% + oldy%) / 2)) = " "
}
NEXT i%
done% = 1
FOR x% = 1 TO width% - 1 STEP 2
FOR y% = 1 TO height% - 1 STEP 2
IF maze$(x%, y%) = "#" THEN done% = 0
NEXT y%
NEXT x%
}
FOR y% = 0 TO height%
FOR x% = 0 TO width%
PRINT maze$(x%, y%);
NEXT x%
PRINT
NEXT y%
}
Maze
line:
maze$(INT((currentx% + oldx%) / 2), ((currenty% + oldy%) / 2)) = " "
See at the end, at /2)) the two parenthesis now have the proper different color.
This is the Maze module in info.gsb (included in m2000 installation file)
Module Maze {
width% = 40
height% = 20
\\ we can use DIM maze$(0 to width%,0 to height%)="#"
\\ so we can delete the two For loops
DIM maze$(0 to width%,0 to height%)
FOR x% = 0 TO width%
FOR y% = 0 TO height%
maze$(x%, y%) = "#"
NEXT y%
NEXT x%
currentx% = INT(RND * (width% - 1))
currenty% = INT(RND * (height% - 1))
IF currentx% MOD 2 = 0 THEN currentx%++
IF currenty% MOD 2 = 0 THEN currenty%++
maze$(currentx%, currenty%) = " "
done% = 0
WHILE done% = 0 {
FOR i% = 0 TO 99
oldx% = currentx%
oldy% = currenty%
SELECT CASE INT(RND * 4)
CASE 0
IF currentx% + 2 < width% THEN currentx%+=2
CASE 1
IF currenty% + 2 < height% THEN currenty%+=2
CASE 2
IF currentx% - 2 > 0 THEN currentx%-=2
CASE 3
IF currenty% - 2 > 0 THEN currenty%-=2
END SELECT
IF maze$(currentx%, currenty%) = "#" Then {
maze$(currentx%, currenty%) = " "
maze$(INT((currentx% + oldx%) / 2), ((currenty% + oldy%) / 2)) = " "
}
NEXT i%
done% = 1
FOR x% = 1 TO width% - 1 STEP 2
FOR y% = 1 TO height% - 1 STEP 2
IF maze$(x%, y%) = "#" THEN done% = 0
NEXT y%
NEXT x%
}
FOR y% = 0 TO height%
FOR x% = 0 TO width%
PRINT maze$(x%, y%);
NEXT x%
NEXT y%
}
Maze
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου
You can feel free to write any suggestion, or idea on the subject.