Author Topic: Isometric Demo re-revisited v2.70 added variable grid size  (Read 1326 times)

0 Members and 1 Guest are viewing this topic.

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Isometric Demo re-revisited v2.70 added variable grid size
« on: December 04, 2021, 11:30:25 am »
Just a small update to the tweaked Isometric Mapping Demo code from
https://www.qb64.org/forum/index.php?topic=1903.30

The + and - keys now grow and shrink the grid size.

I started a bigger overhaul (moving to split screen 1-4 players, allow players to rotate angle of view)
and I wanted to post this version, because it could be a while before the next one is working!

Hopefully someone will find this useful. Comments welcome!

Code: QB64: [Select]
  1. ' ################################################################################################################################################################
  2. ' Isomatric mapping demo re-revisited
  3. ' Version 2.70 by madscijr
  4.  
  5. ' Based on Isometric Mapping Demo
  6. ' by SMcNeill, bplus, and others at
  7. ' https://www.qb64.org/forum/index.php?topic=1903.30
  8.  
  9. ' This crude version uses a 3-dimensional array (32x32x32)
  10. ' to store cubes of different colors,
  11. ' and draws them to the screen in 2.5D "isometric".
  12.  
  13. ' -----------------------------------------------------------------------------
  14. ' DONE:
  15. ' * Render cubes that block the view of the player as transparent.
  16. ' * 2-D top down "map" view of the player's current Z slice.
  17. ' * variable grid size
  18.  
  19. ' -----------------------------------------------------------------------------
  20. ' TO DO:
  21. ' * change arrMap to global shared variable (for simpler code) & rename m_arrMap
  22. ' * allow player to rotate their view
  23. ' * auto-rotate view depending on direction player is facing
  24. ' * local multiplayer (2-4 players)
  25. '   - move player info into array
  26. '   - split screen (x2 or x4)
  27. ' * make simple open world (players can add/remove blocks, build in real time, save screens)
  28. ' * add ramp object
  29. ' * gravity (players stay on ground, can fall)
  30. ' * add ability to walk up ramps / climb ladders / etc.
  31. ' * add ability to jump over 1 space
  32. ' * option to remap keys
  33. ' * support game controllers
  34. ' * game controller calibration/mapping function
  35. ' * expand world to bigger than screen (2.5d scrolling view)
  36. ' * option to hide objects out of player's line-of-sight
  37. ' * show player as a stick figure (like "Realm of Impossibility")
  38. ' * walking movement
  39. ' * add objects (water, ladders, ropes, windows, doors, etc.)
  40. ' * simultaneously show additional 1st person view
  41. ' * add ability for tilting head up/down in first person
  42. ' * make simple games (maze craze, capture the flag, snake, surround, 2.5d pong)
  43. ' * make more complex games (berzerk, lode runner, atari combat / tank)
  44. ' * make awesome complex games (2.5d lunar lander, atari adventure, asteroids, gravitar, etc.)
  45.  
  46. ' ################################################################################################################################################################
  47.  
  48. ' =============================================================================
  49. ' GLOBAL DECLARATIONS a$=string, i%=integer, L&=long, s!=single, d#=double
  50. ' div: int1% = num1% \ den1%
  51. ' mod: rem1% = num1% MOD den1%
  52.  
  53. ' -----------------------------------------------------------------------------
  54. ' boolean constants
  55. ' -----------------------------------------------------------------------------
  56. Const FALSE = 0
  57. Const TRUE = Not FALSE
  58.  
  59. ' -----------------------------------------------------------------------------
  60. ' KeyDownConstants
  61. ' -----------------------------------------------------------------------------
  62. Const c_iKeyDown_Esc = 27
  63. Const c_iKeyDown_F1 = 15104
  64. Const c_iKeyDown_F2 = 15360
  65. Const c_iKeyDown_F3 = 15616
  66. Const c_iKeyDown_F4 = 15872
  67. Const c_iKeyDown_F5 = 16128
  68. Const c_iKeyDown_F6 = 16384
  69. Const c_iKeyDown_F7 = 16640
  70. Const c_iKeyDown_F8 = 16896
  71. Const c_iKeyDown_F9 = 17152
  72. Const c_iKeyDown_F10 = 17408
  73. Const c_iKeyDown_Tilde = 96
  74. Const c_iKeyDown_1 = 49
  75. Const c_iKeyDown_2 = 50
  76. Const c_iKeyDown_3 = 51
  77. Const c_iKeyDown_4 = 52
  78. Const c_iKeyDown_5 = 53
  79. Const c_iKeyDown_6 = 54
  80. Const c_iKeyDown_7 = 55
  81. Const c_iKeyDown_8 = 56
  82. Const c_iKeyDown_9 = 57
  83. Const c_iKeyDown_0 = 48
  84. Const c_iKeyDown_Minus = 45
  85. Const c_iKeyDown_EqualPlus = 61
  86. Const c_iKeyDown_BkSp = 8
  87. Const c_iKeyDown_Ins = 20992
  88. Const c_iKeyDown_Home = 18176
  89. Const c_iKeyDown_PgUp = 18688
  90. Const c_iKeyDown_Del = 21248
  91. Const c_iKeyDown_End = 20224
  92. Const c_iKeyDown_PgDn = 20736
  93. Const c_iKeyDown_KEYPAD_7_Home = 18176
  94. Const c_iKeyDown_KEYPAD_8_Up = 18432
  95. Const c_iKeyDown_KEYPAD_9_PgUp = 18688
  96. Const c_iKeyDown_KEYPAD_4_Left = 19200
  97. Const c_iKeyDown_KEYPAD_6_Right = 19712
  98. Const c_iKeyDown_KEYPAD_1_End = 20224
  99. Const c_iKeyDown_KEYPAD_2_Down = 20480
  100. Const c_iKeyDown_KEYPAD_3_PgDn = 20736
  101. Const c_iKeyDown_KEYPAD_0_Ins = 20992
  102. Const c_iKeyDown_KEYPAD_Period_Del = 21248
  103. Const c_iKeyDown_Tab = 9
  104. Const c_iKeyDown_Q = 113
  105. Const c_iKeyDown_W = 119
  106. Const c_iKeyDown_E = 101
  107. Const c_iKeyDown_R = 114
  108. Const c_iKeyDown_T = 116
  109. Const c_iKeyDown_Y = 121
  110. Const c_iKeyDown_U = 117
  111. Const c_iKeyDown_Pipe = 105
  112. Const c_iKeyDown_O = 111
  113. Const c_iKeyDown_P = 112
  114. Const c_iKeyDown_BracketLeft = 91
  115. Const c_iKeyDown_BracketRight = 93
  116. Const c_iKeyDown_Backslash = 92
  117. Const c_iKeyDown_A = 97
  118. Const c_iKeyDown_S = 115
  119. Const c_iKeyDown_D = 100
  120. Const c_iKeyDown_F = 102
  121. Const c_iKeyDown_G = 103
  122. Const c_iKeyDown_H = 104
  123. Const c_iKeyDown_J = 106
  124. Const c_iKeyDown_K = 107
  125. Const c_iKeyDown_L = 108
  126. Const c_iKeyDown_SemiColon = 59
  127. Const c_iKeyDown_Apostrophe = 39
  128. Const c_iKeyDown_Enter = 13
  129. Const c_iKeyDown_Z = 22
  130. Const c_iKeyDown_X = 120
  131. Const c_iKeyDown_C = 99
  132. Const c_iKeyDown_V = 118
  133. Const c_iKeyDown_B = 98
  134. Const c_iKeyDown_N = 110
  135. Const c_iKeyDown_M = 109
  136. Const c_iKeyDown_Comma = 44
  137. Const c_iKeyDown_Period = 46
  138. Const c_iKeyDown_Slash = 47
  139. Const c_iKeyDown_Up = 18432
  140. Const c_iKeyDown_Left = 19200
  141. Const c_iKeyDown_Down = 20480
  142. Const c_iKeyDown_Right = 19712
  143. Const c_iKeyDown_Spacebar = 32
  144.  
  145. ' -----------------------------------------------------------------------------
  146. ' constants for map (MapBlockType.Typ)
  147. ' -----------------------------------------------------------------------------
  148. Const c_iMapType_Empty = 0
  149. Const c_iMapType_Floor_Tiled = 1
  150. Const c_iMapType_Wall = 2
  151. Const c_iMapType_Water = 3
  152. Const c_iMapType_Window = 4
  153. Const c_iMapType_Player1 = 5
  154. Const c_iMapType_Player2 = 6
  155.  
  156. ' -----------------------------------------------------------------------------
  157. ' constants for 2.5D movement
  158. ' -----------------------------------------------------------------------------
  159. Const c_iDir_Down = 1
  160. Const c_iDir_Up = 2
  161. Const c_iDir_Left = 3
  162. Const c_iDir_Right = 4
  163. Const c_iDir_Back = 5
  164. Const c_iDir_Forward = 6
  165. Const c_iDir_Min = 1
  166. Const c_iDir_Max = 6
  167.  
  168. ' -----------------------------------------------------------------------------
  169. ' constants for drawing the 2.5D screen
  170. ' -----------------------------------------------------------------------------
  171. Const cGridOffsetX = 50
  172. Const cGridOffsetY = 50
  173. Const cGridOffsetZ = 0
  174. Const cScreenOffsetX = 500 ' 450
  175. Const cScreenOffsetY = 300 ' 50
  176. Const cScreenOffsetZ = 0
  177.  
  178. ' =============================================================================
  179. ' USER DEFINED TYPES
  180. ' =============================================================================
  181. Type MapBlockType
  182.     Typ As Integer ' c_iMapType_Empty, c_iMap_Floor_Tiled, c_iMap_Wall, etc.
  183.     'Vis As Integer ' TRUE = visible, FALSE = don't render
  184.     'Lit As Long ' light offset
  185.         Color1 As Long ' main color
  186.         Color2 As Long ' secondary color if needed
  187.         Color3 As Long ' third color if needed 
  188.         AlphaOverride As Integer ' can be used to override alpha (0 treated as opaque)
  189. End Type ' MapBlockType
  190.  
  191. ' =============================================================================
  192. ' GLOBAL VARIABLES
  193. Dim Shared m_ProgramPath$ : m_ProgramPath$ = Left$(Command$(0), _InStrRev(Command$(0), "\"))
  194. Dim Shared m_ProgramName$ : m_ProgramName$ = Mid$(Command$(0), _InStrRev(Command$(0), "\") + 1)
  195. Dim Shared m_iGridSize As Integer : m_iGridSize = 10 ' < 10 is causing problems with PAINT
  196. Dim Shared m_iMapMinX As Integer : m_iMapMinX = 0
  197. Dim Shared m_iMapMaxX As Integer : m_iMapMaxX = 32
  198. Dim Shared m_iMapMidX As Integer : m_iMapMidX = (m_iMapMaxX-m_iMapMinX)\2
  199. Dim Shared m_iMapMinY As Integer : m_iMapMinY = 0
  200. Dim Shared m_iMapMaxY As Integer : m_iMapMaxY = 32
  201. Dim Shared m_iMapMidY As Integer : m_iMapMidY = (m_iMapMaxY-m_iMapMinY)\2
  202. Dim Shared m_iMapMinZ As Integer : m_iMapMinZ = 0
  203. Dim Shared m_iMapMaxZ As Integer : m_iMapMaxZ = 32
  204. Dim Shared m_iMapMidZ As Integer : m_iMapMidZ = (m_iMapMaxZ-m_iMapMinZ)\2
  205. Dim Shared m_iGridSizeMin As Integer : m_iGridSizeMin = 1
  206. Dim Shared m_iGridSizeMax As Integer : m_iGridSizeMax = 128
  207.  
  208. ' =============================================================================
  209. ' LOCAL VARIABLES
  210. Dim in$
  211.  
  212. ' ****************************************************************************************************************************************************************
  213. ' ACTIVATE DEBUGGING WINDOW
  214. _Echo "Started " + m_ProgramName$
  215. _Echo "Debugging on..."
  216. ' ****************************************************************************************************************************************************************
  217.  
  218. ' =============================================================================
  219. ' START THE MAIN ROUTINE
  220. main
  221.  
  222. ' =============================================================================
  223. ' FINISH
  224. System ' return control to the operating system
  225. Print m_ProgramName$ + " finished."
  226. Input "Press <ENTER> to continue", in$
  227.  
  228. ' ****************************************************************************************************************************************************************
  229. ' DEACTIVATE DEBUGGING WINDOW
  230. ' ****************************************************************************************************************************************************************
  231.  
  232.  
  233. ' /////////////////////////////////////////////////////////////////////////////
  234.  
  235. Sub main
  236.         Dim RoutineName as String : RoutineName = "main"
  237.     Dim in$
  238.         Dim result$
  239.        
  240.     Screen 0
  241.  
  242.     Do
  243.         Cls
  244.         Print m_ProgramName$
  245.         Print
  246.         Print "Isomatric Mapping Demo Re-visited"
  247.         Print "v2.69, by Softintheheadware (Dec, 2021)"
  248.         Print
  249.         'PRINT "CONTROLS: PRESS <ESC> TO RETURN TO MENU"
  250.         'PRINT "PLAYER  LEFT       RIGHT       UP        DOWN       "
  251.         'PRINT "1       CRSR LEFT  CRSR RIGHT  CRSR UP   CRSR DOWN  "
  252.         'PRINT "2       KEYPAD 4   KEYPAD 6    KEYPAD 8  KEYPAD 2   "
  253.         'PRINT "3       A          S           W         Z          "
  254.         'PRINT "4       J          K           I         M          "
  255.         'PRINT
  256.  
  257.         Print "1. IsometricDemo1"
  258.         Print "2. IsometricDemo2"
  259.         Print "3. Move around in 2.5D"
  260.         Print
  261.         Print "What to do? ('q' to exit)"
  262.  
  263.         Input in$: in$ = LCase$(Left$(in$, 1))
  264.  
  265.         If in$ = "1" Then
  266.             result$ = IsometricDemo1
  267.         ElseIf in$ = "2" Then
  268.             result$ = IsometricDemo2
  269.         ElseIf in$ = "3" Then
  270.             result$ = IsometricDemo3
  271.         End If
  272.                
  273.                 If LEN(result$) > 0 Then
  274.                         PRINT result$
  275.                 End If
  276.                
  277.     Loop Until in$ = "q"
  278. End Sub ' main
  279.  
  280. ' /////////////////////////////////////////////////////////////////////////////
  281.  
  282. Function IsometricDemo1$
  283.     Dim RoutineName As String: RoutineName = "IsometricDemo1"
  284.         Dim sResult AS String : sResult = ""
  285.     Dim arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType
  286.     Dim iX%
  287.     Dim iY%
  288.     Dim iZ%
  289.     Dim iNextX%
  290.     Dim iNextY%
  291.     Dim iNextZ%
  292.     Dim iPosX1%
  293.     Dim iPosX2%
  294.     Dim iPosY1%
  295.     Dim iPosY2%
  296.     Dim iLoopX%
  297.     Dim iLoopY%
  298.     Dim iLoopZ%
  299.     Dim iNextColor&
  300.         Dim iColorScheme%
  301.     Dim bContinue As Integer
  302.     Dim iDirection%
  303.     Dim bFinished As Integer
  304.     Dim iCount%
  305.     Dim iOpen%
  306.     Dim iMove%
  307.         Dim iSegmentLength%
  308.         Dim iMaxLength%
  309.     Dim bFirst As Integer
  310.     Dim bQuit As Integer
  311.     Dim in$
  312.        
  313.     ' INITIALIZE
  314.     'Screen _NewImage(1024, 720, 32) : _ScreenMove _Middle
  315.         Screen _NewImage(1280, 1024, 32)
  316.        
  317.     ' =============================================================================
  318.     ' MAIN LOOP
  319.     bQuit = FALSE
  320.     Do
  321.         Cls
  322.  
  323.         ' -----------------------------------------------------------------------------
  324.         ' INITIALIZE MAP TO EMPTY
  325.         ClearIsometricMap arrMap()
  326.                
  327.         ' -----------------------------------------------------------------------------
  328.         ' DRAW FLOOR
  329.         iZ% = 0
  330.         For iLoopX% = 0 To 32
  331.             For iLoopY% = 0 To 32
  332.                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Floor_Tiled
  333.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color1 = cGray&
  334.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color2 = cLightGray&
  335.             Next iLoopY%
  336.         Next iLoopX%
  337.                
  338.         ' -----------------------------------------------------------------------------
  339.         ' DRAW BLOCKS TO CHECK ORIENTATION
  340.                
  341.                 FOR iLoopZ% = m_iMapMinZ + 1 TO m_iMapMaxZ
  342.                         arrMap(m_iMapMinX, m_iMapMinY, iLoopZ%).Typ = c_iMapType_Wall
  343.                         arrMap(m_iMapMinX, m_iMapMinY, iLoopZ%).Color1 = cRed&
  344.                        
  345.                         arrMap(m_iMapMaxX, m_iMapMinY, iLoopZ%).Typ = c_iMapType_Wall
  346.                         arrMap(m_iMapMaxX, m_iMapMinY, iLoopZ%).Color1 = cBlue&
  347.                        
  348.                         arrMap(m_iMapMinX, m_iMapMaxY, iLoopZ%).Typ = c_iMapType_Wall
  349.                         arrMap(m_iMapMinX, m_iMapMaxY, iLoopZ%).Color1 = cGreen&
  350.                        
  351.                         'arrMap(m_iMapMaxX, m_iMapMaxY, iLoopZ%).Typ = c_iMapType_Wall
  352.                         'arrMap(m_iMapMaxX, m_iMapMaxY, iLoopZ%).Color1 = cYellow&
  353.                        
  354.                         'arrMap(m_iMapMinX, m_iMapMidY, iLoopZ%).Typ = c_iMapType_Wall
  355.                         'arrMap(m_iMapMinX, m_iMapMidY, iLoopZ%).Color1 = cOrange&
  356.                         '
  357.                         'arrMap(m_iMapMaxX, m_iMapMidY, iLoopZ%).Typ = c_iMapType_Wall
  358.                         'arrMap(m_iMapMaxX, m_iMapMidY, iLoopZ%).Color1 = cPurple&
  359.                         '
  360.                         'arrMap(m_iMapMidX, m_iMapMinY, iLoopZ%).Typ = c_iMapType_Wall
  361.                         'arrMap(m_iMapMidX, m_iMapMinY, iLoopZ%).Color1 = cLime&
  362.                         '
  363.                         'arrMap(m_iMapMidX, m_iMapMaxY, iLoopZ%).Typ = c_iMapType_Wall
  364.                         'arrMap(m_iMapMidX, m_iMapMaxY, iLoopZ%).Color1 = cCyan&
  365.                 NEXT iLoopZ%
  366.                
  367.         ' -----------------------------------------------------------------------------
  368.         ' DRAW SOME OBJECTS
  369.         If TRUE = TRUE Then
  370.             iX% = 16
  371.             iY% = 3
  372.                        
  373.             iNextColor& = cRed&
  374.             iLoopZ% = 1
  375.             iLoopY% = iY%
  376.             For iLoopX% = iX% To (iX% + 10)
  377.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall
  378.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = iNextColor&
  379.             Next iLoopX%
  380.                        
  381.             iNextColor& = cBlue&
  382.             iLoopZ% = 1
  383.             iLoopY% = iY% + 8
  384.             For iLoopX% = iX% To (iX% + 10)
  385.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall
  386.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = iNextColor&
  387.             Next iLoopX%
  388.                        
  389.             iNextColor& = cGreen&
  390.             iLoopZ% = 1
  391.             iLoopX% = iX% + 1
  392.             For iLoopY% = (iY% + 1) To (iY% + 7)
  393.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall
  394.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = iNextColor&
  395.             Next iLoopY%
  396.                        
  397.             iNextColor& = cYellow&
  398.             iLoopZ% = 1
  399.             iLoopX% = iX% + 9
  400.             For iLoopY% = (iY% + 1) To (iY% + 7)
  401.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall
  402.                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = iNextColor&
  403.             Next iLoopY%
  404.         End If
  405.                
  406.         ' -----------------------------------------------------------------------------
  407.         ' DRAW A PYRAMID
  408.         If TRUE = TRUE Then
  409.             iX% = 2
  410.             iY% = 18
  411.             iZ% = 1
  412.             iPosX1% = iX%
  413.             iPosX2% = iX% + 10
  414.             iPosY1% = iY%
  415.             iPosY2% = iY% + 10
  416.                         iNextColor& = cRed&
  417.                         iColorScheme% = 1 ' 1 = Rainbow6 #1, 9 = Rainbow6 #2, etc.
  418.                        
  419.             bContinue = TRUE
  420.             Do
  421.                 ' PLOT NEXT LEVEL
  422.                 For iLoopX% = iPosX1% To iPosX2%
  423.                     For iLoopY% = iPosY1% To iPosY2%
  424.                                                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  425.                         arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  426.                     Next iLoopY%
  427.                 Next iLoopX%
  428.                                
  429.                 ' MOVE UP A LEVEL
  430.                 iPosX1% = iPosX1% + 1
  431.                 iPosX2% = iPosX2% - 1
  432.                 iPosY1% = iPosY1% + 1
  433.                 iPosY2% = iPosY2% - 1
  434.                                 DoCycleColor iColorScheme%, iNextColor&
  435.                                
  436.                 ' QUIT AFTER WE REACH THE TOP
  437.                 If (iPosX1% <= iPosX2%) And (iPosY1% <= iPosY2%) Then
  438.                     iZ% = iZ% + 1
  439.                 Else
  440.                     bContinue = FALSE
  441.                 End If
  442.                                
  443.             Loop Until bContinue = FALSE
  444.         End If
  445.  
  446.         ' -----------------------------------------------------------------------------
  447.         ' DRAW PIPES
  448.         If TRUE = TRUE Then
  449.                         ' START POSITION
  450.             iX% = m_iMapMaxX ' 30 ' RandomNumber(0, 32)
  451.             iY% = m_iMapMaxY ' 28 ' RandomNumber(0, 32)
  452.             iZ% = 1 ' 32
  453.                        
  454.                         ' LENGTH OF PIPES
  455.                         iSegmentLength% = 4
  456.                         iMaxLength% = 64
  457.                        
  458.                         ' START COLOR + DEFINE HOW COLOR CHANGES
  459.                         iNextColor& = cRed&
  460.                         iColorScheme% = 2 ' 0 = don't change, 2 = Rainbow18 #1, 10 = Rainbow18 #2, etc.
  461.                        
  462.                         ' INITIALIZE
  463.             bFirst = TRUE
  464.             iCount% = 0
  465.             iMove% = 0
  466.             bFinished = FALSE
  467.             Do
  468.                 iNextX% = iX%
  469.                 iNextY% = iY%
  470.                 iNextZ% = iZ%
  471.                                
  472.                                 ' CHANGE DIRECTION EVERY iSegmentLength% SPACES
  473.                 iMove% = iMove% + 1
  474.                 If iMove% > iSegmentLength% Then
  475.                     iMove% = 0
  476.                                        
  477.                                         ' PICK A DIRECTION
  478.                     If bFirst = TRUE Then
  479.                                                 ' MOVE UP FOR FIRST MOVE
  480.                         iDirection% = c_iDir_Up
  481.                         bFirst = FALSE
  482.                     Else
  483.                                                 ' PICK A RANDOM DIRECTION
  484.                         iDirection% = RandomNumber(c_iDir_Min, c_iDir_Max)
  485.                     End If
  486.                 End If
  487.                                
  488.                 Select Case iDirection%
  489.                     Case c_iDir_Down:
  490.                         If iNextZ% > 0 Then
  491.                             iNextZ% = iNextZ% - 1
  492.                         End If
  493.                     Case c_iDir_Up:
  494.                         If iNextZ% < 32 Then
  495.                             iNextZ% = iNextZ% + 1
  496.                         End If
  497.                     Case c_iDir_Left:
  498.                         If iNextX% > 0 Then
  499.                             iNextX% = iNextX% - 1
  500.                         End If
  501.                     Case c_iDir_Right:
  502.                         If iNextX% < 32 Then
  503.                             iNextX% = iNextX% + 1
  504.                         End If
  505.                     Case c_iDir_Back:
  506.                         If iNextY% > 0 Then
  507.                             iNextY% = iNextY% - 1
  508.                         End If
  509.                     Case Else: ' c_iDir_Forward
  510.                         If iNextY% < 32 Then
  511.                             iNextY% = iNextY% + 1
  512.                         End If
  513.                 End Select
  514.                                
  515.                                 ' CHECK IF NEXT SPACE IS EMPTY
  516.                 If arrMap(iNextX%, iNextY%, iNextZ%).Typ = c_iMapType_Empty Then
  517.                                         ' SPACE IS EMPTY
  518.                                         ' DRAW HERE
  519.                                        
  520.                     iCount% = iCount% + 1
  521.                     iX% = iNextX%
  522.                     iY% = iNextY%
  523.                     iZ% = iNextZ%
  524.                                        
  525.                                         ' GET NEXT COLOR AND DRAW BLOCK
  526.                                         DoCycleColor iColorScheme%, iNextColor&
  527.                                         arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Wall
  528.                                         arrMap(iX%, iY%, iZ%).Color1 = iNextColor&
  529.                                        
  530.                     ' HAVE WE PLACED MAX # OF BLOCKS?
  531.                     If iCount% > iMaxLength% Then
  532.                         bFinished = TRUE
  533.                     End If
  534.                 Else                                   
  535.                                         ' SPACE IS OCCUPIED
  536.                     ' SEE IF WE HAVE ANY OPEN SPACES TO MOVE TO
  537.                     iOpen% = 0
  538.                     If iZ% > 0 Then
  539.                         If arrMap(iX%, iY%, iZ% - 1).Typ = c_iMapType_Empty Then
  540.                             iOpen% = iOpen% + 1
  541.                         End If
  542.                     End If
  543.                     If iZ% < 32 Then
  544.                         If arrMap(iX%, iY%, iZ% + 1).Typ = c_iMapType_Empty Then
  545.                             iOpen% = iOpen% + 1
  546.                         End If
  547.                     End If
  548.                     If iX% > 0 Then
  549.                         If arrMap(iX% - 1, iY%, iZ%).Typ = c_iMapType_Empty Then
  550.                             iOpen% = iOpen% + 1
  551.                         End If
  552.                     End If
  553.                     If iX% < 32 Then
  554.                         If arrMap(iX% + 1, iY%, iZ%).Typ = c_iMapType_Empty Then
  555.                             iOpen% = iOpen% + 1
  556.                         End If
  557.                     End If
  558.                     If iY% > 0 Then
  559.                         If arrMap(iX%, iY% - 1, iZ%).Typ = c_iMapType_Empty Then
  560.                             iOpen% = iOpen% + 1
  561.                         End If
  562.                     End If
  563.                     If iY% < 32 Then
  564.                         If arrMap(iX%, iY% + 1, iZ%).Typ = c_iMapType_Empty Then
  565.                             iOpen% = iOpen% + 1
  566.                         End If
  567.                     End If
  568.                                        
  569.                     ' QUIT IF NO OPEN SPACES AVAILABLE
  570.                     If iOpen% = 0 Then
  571.                         ' NOWHERE TO GO, EXIT
  572.                         bFinished = TRUE
  573.                     End If
  574.                 End If
  575.                                
  576.             Loop Until bFinished = TRUE
  577.         End If
  578.  
  579.         ' PLOT GRAPHICS TO SCREEN
  580.         DrawIsometricScreen arrMap()
  581.                
  582.         Input "Type q to quit? ", in$
  583.                
  584.         If LCase$(in$) = LCase$("q") Then
  585.             bQuit = TRUE
  586.         End If
  587.                
  588.     Loop Until bQuit = TRUE
  589.        
  590.     Screen 0
  591.        
  592.         IsometricDemo1 = sResult
  593. End Sub ' IsometricDemo1
  594.  
  595. ' /////////////////////////////////////////////////////////////////////////////
  596.  
  597. Function IsometricDemo2$
  598.     Dim RoutineName As String: RoutineName = "IsometricDemo2"
  599.         Dim sResult AS String : sResult = ""
  600.     Dim arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType
  601.     Dim iX%
  602.     Dim iY%
  603.     Dim iZ%
  604.     Dim iNextX%
  605.     Dim iNextY%
  606.     Dim iNextZ%
  607.     Dim iPosX1%
  608.     Dim iPosX2%
  609.     Dim iPosY1%
  610.     Dim iPosY2%
  611.     Dim iLoopX%
  612.     Dim iLoopY%
  613.     Dim iLoopZ%
  614.     Dim iNextColor&
  615.         Dim iColorScheme%
  616.     Dim bContinue As Integer
  617.     Dim iDirection%
  618.     Dim bFinished As Integer
  619.     Dim iCount%
  620.     Dim iOpen%
  621.     Dim iMove%
  622.         Dim iSegmentLength%
  623.         Dim iMaxLength%
  624.     Dim bFirst As Integer
  625.     Dim bQuit As Integer
  626.     Dim in$
  627.        
  628.     ' INITIALIZE
  629.     'Screen _NewImage(1024, 720, 32) : _ScreenMove _Middle
  630.         Screen _NewImage(1280, 1024, 32)
  631.        
  632.     ' =============================================================================
  633.     ' MAIN LOOP
  634.     bQuit = FALSE
  635.     Do
  636.         Cls
  637.  
  638.         ' -----------------------------------------------------------------------------
  639.         ' INITIALIZE MAP TO EMPTY
  640.         ClearIsometricMap arrMap()
  641.                
  642.         ' -----------------------------------------------------------------------------
  643.         ' DRAW FLOOR
  644.         'For iLoopZ% = m_iMapMinZ To m_iMapMaxZ Step 8
  645.                 For iLoopZ% = m_iMapMinZ To m_iMapMinZ
  646.                         For iLoopX% = m_iMapMinX To m_iMapMaxX
  647.                                 For iLoopY% = m_iMapMinY To m_iMapMaxY
  648.                                         arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Floor_Tiled
  649.                                         arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = cGray&
  650.                                         arrMap(iLoopX%, iLoopY%, iLoopZ%).Color2 = cLightGray&
  651.                                 Next iLoopY%
  652.                         Next iLoopX%
  653.                 Next iLoopZ%
  654.                
  655.         ' -----------------------------------------------------------------------------
  656.         ' DRAW FRAME AROUND ENTIRE SPACE
  657.                
  658.                 FOR iLoopZ% = m_iMapMinZ+1 TO m_iMapMaxZ
  659.                         arrMap(m_iMapMinX, m_iMapMinY, iLoopZ%).Typ = c_iMapType_Wall
  660.                         arrMap(m_iMapMinX, m_iMapMinY, iLoopZ%).Color1 = cRed&
  661.                        
  662.                         arrMap(m_iMapMaxX, m_iMapMinY, iLoopZ%).Typ = c_iMapType_Wall
  663.                         arrMap(m_iMapMaxX, m_iMapMinY, iLoopZ%).Color1 = cBlue&
  664.                        
  665.                         arrMap(m_iMapMinX, m_iMapMaxY, iLoopZ%).Typ = c_iMapType_Wall
  666.                         arrMap(m_iMapMinX, m_iMapMaxY, iLoopZ%).Color1 = cGreen&
  667.                        
  668.                         arrMap(m_iMapMaxX, m_iMapMaxY, iLoopZ%).Typ = c_iMapType_Wall
  669.                         arrMap(m_iMapMaxX, m_iMapMaxY, iLoopZ%).Color1 = cYellow&
  670.                 NEXT iLoopZ%
  671.                
  672.                 FOR iLoopX% = m_iMapMinX TO m_iMapMaxX
  673.                         arrMap(iLoopX%, m_iMapMinY, m_iMapMinZ+1).Typ = c_iMapType_Wall
  674.                         arrMap(iLoopX%, m_iMapMinY, m_iMapMinZ+1).Color1 = cOrange&
  675.                        
  676.                         arrMap(iLoopX%, m_iMapMaxY, m_iMapMaxZ).Typ = c_iMapType_Wall
  677.                         arrMap(iLoopX%, m_iMapMaxY, m_iMapMaxZ).Color1 = cPurple&
  678.                        
  679.                         arrMap(iLoopX%, m_iMapMaxY, m_iMapMinZ+1).Typ = c_iMapType_Wall
  680.                         arrMap(iLoopX%, m_iMapMaxY, m_iMapMinZ+1).Color1 = cLime&
  681.                        
  682.                         arrMap(iLoopX%, m_iMapMinY, m_iMapMaxZ).Typ = c_iMapType_Wall
  683.                         arrMap(iLoopX%, m_iMapMinY, m_iMapMaxZ).Color1 = cCyan&
  684.                 NEXT iLoopX%
  685.                
  686.                 FOR iLoopY% = m_iMapMinY TO m_iMapMaxY
  687.                         arrMap(m_iMapMinX, iLoopY%, m_iMapMinZ+1).Typ = c_iMapType_Wall
  688.                         arrMap(m_iMapMinX, iLoopY%, m_iMapMinZ+1).Color1 = cDodgerBlue&
  689.                        
  690.                         arrMap(m_iMapMinX, iLoopY%, m_iMapMaxZ).Typ = c_iMapType_Wall
  691.                         arrMap(m_iMapMinX, iLoopY%, m_iMapMaxZ).Color1 = cDeepPurple&
  692.                        
  693.                         arrMap(m_iMapMaxX, iLoopY%, m_iMapMinZ+1).Typ = c_iMapType_Wall
  694.                         arrMap(m_iMapMaxX, iLoopY%, m_iMapMinZ+1).Color1 = cDarkRed&
  695.                        
  696.                         arrMap(m_iMapMaxX, iLoopY%, m_iMapMaxZ).Typ = c_iMapType_Wall
  697.                         arrMap(m_iMapMaxX, iLoopY%, m_iMapMaxZ).Color1 = cGold&
  698.                 NEXT iLoopY%
  699.                
  700.         ' -----------------------------------------------------------------------------
  701.         ' DRAW PIPES
  702.         If TRUE = TRUE Then
  703.                         ' START POSITION
  704.             iX% = m_iMapMidX ' 30 ' RandomNumber(0, 32)
  705.             iY% = m_iMapMidY ' 28 ' RandomNumber(0, 32)
  706.             iZ% = m_iMapMidZ ' 1 ' 32
  707.                        
  708.                         ' LENGTH OF PIPES
  709.                         iSegmentLength% = 8
  710.                         iMaxLength% = 512
  711.                        
  712.                         ' START COLOR + DEFINE HOW COLOR CHANGES
  713.                         iNextColor& = cRed&
  714.                         iColorScheme% = 3 ' 0 = don't change, 2 = Rainbow18 #1, 10 = Rainbow18 #2, etc.
  715.                        
  716.                         ' INITIALIZE
  717.             bFirst = TRUE
  718.             iCount% = 0
  719.             iMove% = 0
  720.             bFinished = FALSE
  721.             Do
  722.                 iNextX% = iX%
  723.                 iNextY% = iY%
  724.                 iNextZ% = iZ%
  725.                                
  726.                                 ' CHANGE DIRECTION EVERY iSegmentLength% SPACES
  727.                 iMove% = iMove% + 1
  728.                 If iMove% > iSegmentLength% Then
  729.                     iMove% = 0
  730.                                        
  731.                                         ' PICK A DIRECTION
  732.                     If bFirst = TRUE Then
  733.                                                 ' MOVE UP FOR FIRST MOVE
  734.                         iDirection% = c_iDir_Up
  735.                         bFirst = FALSE
  736.                     Else
  737.                                                 ' PICK A RANDOM DIRECTION
  738.                         iDirection% = RandomNumber(c_iDir_Min, c_iDir_Max)
  739.                     End If
  740.                 End If
  741.                                
  742.                 Select Case iDirection%
  743.                     Case c_iDir_Down:
  744.                         If iNextZ% > 0 Then
  745.                             iNextZ% = iNextZ% - 1
  746.                         End If
  747.                     Case c_iDir_Up:
  748.                         If iNextZ% < 32 Then
  749.                             iNextZ% = iNextZ% + 1
  750.                         End If
  751.                     Case c_iDir_Left:
  752.                         If iNextX% > 0 Then
  753.                             iNextX% = iNextX% - 1
  754.                         End If
  755.                     Case c_iDir_Right:
  756.                         If iNextX% < 32 Then
  757.                             iNextX% = iNextX% + 1
  758.                         End If
  759.                     Case c_iDir_Back:
  760.                         If iNextY% > 0 Then
  761.                             iNextY% = iNextY% - 1
  762.                         End If
  763.                     Case Else: ' c_iDir_Forward
  764.                         If iNextY% < 32 Then
  765.                             iNextY% = iNextY% + 1
  766.                         End If
  767.                 End Select
  768.                                
  769.                                 ' CHECK IF NEXT SPACE IS EMPTY
  770.                 If arrMap(iNextX%, iNextY%, iNextZ%).Typ = c_iMapType_Empty Then
  771.                                         ' SPACE IS EMPTY
  772.                                         ' DRAW HERE
  773.                                        
  774.                     iCount% = iCount% + 1
  775.                     iX% = iNextX%
  776.                     iY% = iNextY%
  777.                     iZ% = iNextZ%
  778.                                        
  779.                                         ' GET NEXT COLOR AND DRAW BLOCK
  780.                                         DoCycleColor iColorScheme%, iNextColor&
  781.                                         arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Wall
  782.                                         arrMap(iX%, iY%, iZ%).Color1 = iNextColor&
  783.                                        
  784.                     ' HAVE WE PLACED MAX # OF BLOCKS?
  785.                     If iCount% > iMaxLength% Then
  786.                         bFinished = TRUE
  787.                     End If
  788.                 Else                                   
  789.                                         ' SPACE IS OCCUPIED
  790.                     ' SEE IF WE HAVE ANY OPEN SPACES TO MOVE TO
  791.                     iOpen% = 0
  792.                     If iZ% > 0 Then
  793.                         If arrMap(iX%, iY%, iZ% - 1).Typ = c_iMapType_Empty Then
  794.                             iOpen% = iOpen% + 1
  795.                         End If
  796.                     End If
  797.                     If iZ% < 32 Then
  798.                         If arrMap(iX%, iY%, iZ% + 1).Typ = c_iMapType_Empty Then
  799.                             iOpen% = iOpen% + 1
  800.                         End If
  801.                     End If
  802.                     If iX% > 0 Then
  803.                         If arrMap(iX% - 1, iY%, iZ%).Typ = c_iMapType_Empty Then
  804.                             iOpen% = iOpen% + 1
  805.                         End If
  806.                     End If
  807.                     If iX% < 32 Then
  808.                         If arrMap(iX% + 1, iY%, iZ%).Typ = c_iMapType_Empty Then
  809.                             iOpen% = iOpen% + 1
  810.                         End If
  811.                     End If
  812.                     If iY% > 0 Then
  813.                         If arrMap(iX%, iY% - 1, iZ%).Typ = c_iMapType_Empty Then
  814.                             iOpen% = iOpen% + 1
  815.                         End If
  816.                     End If
  817.                     If iY% < 32 Then
  818.                         If arrMap(iX%, iY% + 1, iZ%).Typ = c_iMapType_Empty Then
  819.                             iOpen% = iOpen% + 1
  820.                         End If
  821.                     End If
  822.                                        
  823.                     ' QUIT IF NO OPEN SPACES AVAILABLE
  824.                     If iOpen% = 0 Then
  825.                         ' NOWHERE TO GO, EXIT
  826.                         bFinished = TRUE
  827.                     End If
  828.                 End If
  829.                                
  830.             Loop Until bFinished = TRUE
  831.         End If
  832.  
  833.         ' PLOT GRAPHICS TO SCREEN
  834.         DrawIsometricScreen arrMap()
  835.                
  836.         Input "Type q to quit? ", in$
  837.                
  838.         If LCase$(in$) = LCase$("q") Then
  839.             bQuit = TRUE
  840.         End If
  841.                
  842.     Loop Until bQuit = TRUE
  843.        
  844.     Screen 0
  845.        
  846.         IsometricDemo2 = sResult
  847. End Sub ' IsometricDemo2
  848.  
  849. ' /////////////////////////////////////////////////////////////////////////////
  850.  
  851. Function IsometricDemo3$
  852.     Dim RoutineName As String: RoutineName = "IsometricDemo3"
  853.         Dim sResult AS String : sResult = ""
  854.     Dim arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType
  855.     Dim iX%
  856.     Dim iY%
  857.     Dim iZ%
  858.         Dim iNewX%
  859.         Dim iNewY%
  860.         Dim iNewZ%
  861.     Dim iMyColor&
  862.         Dim iColorScheme%
  863.     Dim iDirection% ' direction player's nose is pointing
  864.         Dim bFound As Integer
  865.         DIM bDone As Integer
  866.     Dim in$
  867.         Dim iTotal% ' compute total available spaces
  868.         Dim iCount% ' count # of spaces searched
  869.         Dim bMoving As Integer
  870.         Dim iLastKey As Integer
  871.         Dim bMoved As Integer
  872.        
  873.     Dim iPosX1%
  874.     Dim iPosX2%
  875.     Dim iPosY1%
  876.     Dim iPosY2%
  877.         Dim iNextColor&
  878.         Dim bContinue As Integer
  879.     Dim iLoopX%
  880.     Dim iLoopY%
  881.     Dim iLoopZ%
  882.         Dim iLevelCount%
  883.         Dim iLevelSize%
  884.        
  885.         Dim iDrawX%
  886.         Dim iDrawY%
  887.        
  888.         ' =============================================================================
  889.     ' INITIALIZE
  890.     'Screen _NewImage(1024, 720, 32) : _ScreenMove _Middle
  891.         Screen _NewImage(1280, 1024, 32)
  892.        
  893.         ' -----------------------------------------------------------------------------
  894.         ' INITIALIZE MAP TO EMPTY
  895.         ClearIsometricMap arrMap()
  896.        
  897.         ' -----------------------------------------------------------------------------
  898.         ' DRAW FLOOR
  899.         For iLoopZ% = m_iMapMinZ To m_iMapMinZ
  900.                 For iLoopX% = m_iMapMinX To m_iMapMaxX
  901.                         For iLoopY% = m_iMapMinY To m_iMapMaxY
  902.                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Floor_Tiled
  903.                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1 = cGray&
  904.                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Color2 = cLightGray&
  905.                         Next iLoopY%
  906.                 Next iLoopX%
  907.         Next iLoopZ%
  908.  
  909.         ' -----------------------------------------------------------------------------
  910.         ' DRAW A TALL HOLLOW PYRAMID
  911.         If TRUE = TRUE Then
  912.                 iX% = 5
  913.                 iY% = 10
  914.                 iZ% = 1
  915.                 iLevelSize% = 4
  916.                
  917.                 iPosX1% = iX%
  918.                 iPosX2% = iX% + 7
  919.                 iPosY1% = iY%
  920.                 iPosY2% = iY% + 7
  921.                 iNextColor& = cRed&
  922.                 iColorScheme% = 1 ' 1 = Rainbow6 #1, 9 = Rainbow6 #2, etc.
  923.                 iLevelCount% = 0
  924.                
  925.                 bContinue = TRUE
  926.                 Do
  927.                         ' PLOT NEXT LEVEL
  928.                         'For iLoopX% = iPosX1% To iPosX2%
  929.                         '       For iLoopY% = iPosY1% To iPosY2%
  930.                         '               arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  931.                         '               arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  932.                         '       Next iLoopY%
  933.                         'Next iLoopX%
  934.                        
  935.                         ' Draw front/back walls
  936.                         For iLoopX% = iPosX1% To iPosX2%
  937.                                 iLoopY% = iPosY1%
  938.                                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  939.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  940.                                 arrMap(iLoopX%, iLoopY%, iZ%).AlphaOverride = 255
  941.                                
  942.                                 iLoopY% = iPosY2%
  943.                                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  944.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  945.                                 arrMap(iLoopX%, iLoopY%, iZ%).AlphaOverride = 255
  946.                         Next iLoopX%
  947.                        
  948.                         ' Draw left/right walls
  949.                         For iLoopY% = iPosY1% To iPosY2%
  950.                                 iLoopX% = iPosX1%
  951.                                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  952.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  953.                                 arrMap(iLoopX%, iLoopY%, iZ%).AlphaOverride = 255
  954.                                
  955.                                 iLoopX% = iPosX2%
  956.                                 arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall
  957.                                 arrMap(iLoopX%, iLoopY%, iZ%).Color1 = iNextColor&
  958.                                 arrMap(iLoopX%, iLoopY%, iZ%).AlphaOverride = 255
  959.                         Next iLoopY%
  960.                        
  961.                         ' Add a door to middle of right wall
  962.                         iX% = iPosX1% + ( (iPosX2% - iPosX1%) \ 2)
  963.                         arrMap(iX%, iPosY2%, iZ%).Typ = c_iMapType_Empty
  964.                        
  965.                         ' Add a door to middle of front wall
  966.                         iY% = iPosY1% + ( (iPosY2% - iPosY1%) \ 2)
  967.                         arrMap(iPosX2%, iY%, iZ%).Typ = c_iMapType_Empty
  968.                        
  969.                         ' MOVE UP A LEVEL
  970.                         iLevelCount% = iLevelCount% + 1
  971.                         IF iLevelCount% > iLevelSize% THEN
  972.                                 iLevelCount% = 0
  973.                                 iPosX1% = iPosX1% + 1
  974.                                 iPosX2% = iPosX2% - 1
  975.                                 iPosY1% = iPosY1% + 1
  976.                                 iPosY2% = iPosY2% - 1
  977.                         END IF
  978.                        
  979.                         ' QUIT AFTER WE REACH THE TOP
  980.                         If (iPosX1% <= iPosX2%) And (iPosY1% <= iPosY2%) Then
  981.                                 iZ% = iZ% + 1
  982.                                 DoCycleColor iColorScheme%, iNextColor&
  983.                                 If iZ% > m_iMapMaxZ Then
  984.                                         bContinue = FALSE
  985.                                 End If
  986.                         Else
  987.                                 bContinue = FALSE
  988.                         End If
  989.                        
  990.                 Loop Until bContinue = FALSE
  991.         End If 
  992.        
  993.         ' -----------------------------------------------------------------------------
  994.         ' DRAW FRAME AROUND ENTIRE SPACE (TOP)
  995.        
  996.         FOR iLoopX% = m_iMapMinX+3 TO m_iMapMaxX-3
  997.                 arrMap(iLoopX%, m_iMapMaxY-3, m_iMapMaxZ).Typ = c_iMapType_Wall
  998.                 arrMap(iLoopX%, m_iMapMaxY-3, m_iMapMaxZ).Color1 = cPurple&
  999.                
  1000.                 arrMap(iLoopX%, m_iMapMinY+3, m_iMapMaxZ).Typ = c_iMapType_Wall
  1001.                 arrMap(iLoopX%, m_iMapMinY+3, m_iMapMaxZ).Color1 = cCyan&
  1002.         NEXT iLoopX%
  1003.        
  1004.         FOR iLoopY% = m_iMapMinY+3 TO m_iMapMaxY-3
  1005.                 arrMap(m_iMapMinX+3, iLoopY%, m_iMapMaxZ).Typ = c_iMapType_Wall
  1006.                 arrMap(m_iMapMinX+3, iLoopY%, m_iMapMaxZ).Color1 = cOrange&
  1007.                
  1008.                 arrMap(m_iMapMaxX-3, iLoopY%, m_iMapMaxZ).Typ = c_iMapType_Wall
  1009.                 arrMap(m_iMapMaxX-3, iLoopY%, m_iMapMaxZ).Color1 = cLime&
  1010.         NEXT iLoopY%
  1011.        
  1012.         ' -----------------------------------------------------------------------------
  1013.         ' DRAW FRAME AROUND ENTIRE SPACE (MIDDLE)
  1014.        
  1015.         FOR iLoopX% = m_iMapMinX+2 TO m_iMapMaxX-2
  1016.                 arrMap(iLoopX%, m_iMapMaxY-2, m_iMapMidZ).Typ = c_iMapType_Wall
  1017.                 arrMap(iLoopX%, m_iMapMaxY-2, m_iMapMidZ).Color1 = cDodgerBlue&
  1018.                
  1019.                 arrMap(iLoopX%, m_iMapMinY+2, m_iMapMidZ).Typ = c_iMapType_Wall
  1020.                 arrMap(iLoopX%, m_iMapMinY+2, m_iMapMidZ).Color1 = cDeepPurple&
  1021.         NEXT iLoopX%
  1022.        
  1023.         FOR iLoopY% = m_iMapMinY+2 TO m_iMapMaxY-2
  1024.                 arrMap(m_iMapMinX+2, iLoopY%, m_iMapMidZ).Typ = c_iMapType_Wall
  1025.                 arrMap(m_iMapMinX+2, iLoopY%, m_iMapMidZ).Color1 = cDarkRed&
  1026.                
  1027.                 arrMap(m_iMapMaxX-2, iLoopY%, m_iMapMidZ).Typ = c_iMapType_Wall
  1028.                 arrMap(m_iMapMaxX-2, iLoopY%, m_iMapMidZ).Color1 = cGold&
  1029.         NEXT iLoopY%
  1030.        
  1031.         ' -----------------------------------------------------------------------------
  1032.         ' DRAW FRAME AROUND ENTIRE SPACE (BOTTOM)
  1033.        
  1034.         FOR iLoopX% = m_iMapMinX+1 TO m_iMapMaxX-1
  1035.                 arrMap(iLoopX%, m_iMapMaxY-1, m_iMapMinZ+1).Typ = c_iMapType_Wall
  1036.                 arrMap(iLoopX%, m_iMapMaxY-1, m_iMapMinZ+1).Color1 = cSeaBlue&
  1037.                
  1038.                 arrMap(iLoopX%, m_iMapMinY+1, m_iMapMinZ+1).Typ = c_iMapType_Wall
  1039.                 arrMap(iLoopX%, m_iMapMinY+1, m_iMapMinZ+1).Color1 = cChartreuse&
  1040.         NEXT iLoopX%
  1041.        
  1042.         FOR iLoopY% = m_iMapMinY+1 TO m_iMapMaxY-1
  1043.                 arrMap(m_iMapMinX+1, iLoopY%, m_iMapMinZ+1).Typ = c_iMapType_Wall
  1044.                 arrMap(m_iMapMinX+1, iLoopY%, m_iMapMinZ+1).Color1 = cOrangeRed&
  1045.                
  1046.                 arrMap(m_iMapMaxX-1, iLoopY%, m_iMapMinZ+1).Typ = c_iMapType_Wall
  1047.                 arrMap(m_iMapMaxX-1, iLoopY%, m_iMapMinZ+1).Color1 = cDeepSkyBlue&
  1048.         NEXT iLoopY%
  1049.        
  1050.         ' -----------------------------------------------------------------------------
  1051.         ' FIND START POSITION
  1052.         iX% = RandomNumber(m_iMapMinX, m_iMapMaxX)
  1053.         iY% = RandomNumber(m_iMapMinY, m_iMapMaxY)
  1054.         iZ% = 1 ' RandomNumber(m_iMapMinZ, m_iMapMaxZ)
  1055.        
  1056.         ' MAKE SURE IT'S EMPTY
  1057.         IF arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Empty THEN
  1058.                 bFound = TRUE
  1059.         ELSE
  1060.                 ' IF NOT EMPTY THEN TRY TO FIND AN EMPTY SPOT
  1061.                 iTotal% = ((m_iMapMaxX - m_iMapMinX)+1) * ((m_iMapMaxY - m_iMapMinY)+1) * ((m_iMapMaxZ - m_iMapMinZ)+1)
  1062.                 iCount% = 0
  1063.                 bFound = FALSE
  1064.                 Do
  1065.                         iX% = iX% + 1
  1066.                         if iX% > m_iMapMaxX then
  1067.                                 ' reset x and move to next y
  1068.                                 iX% = m_iMapMinX
  1069.                                 iY% = iY% + 1
  1070.                                 if iY% > m_iMapMaxY then
  1071.                                         ' reset y and move to next z
  1072.                                         iY% = m_iMapMinY
  1073.                                         iZ% = iZ% + 1
  1074.                                         if iZ% > m_iMapMaxZ then
  1075.                                                 ' RESET Z AND SEE IF WE HAVE CHECKED EVERYTHING
  1076.                                                 iZ% = m_iMapMinZ
  1077.                                                 iCount% = iCount% + 1
  1078.                                                 if iCount% >= iTotal% then
  1079.                                                         ' NONE FOUND, EXIT
  1080.                                                         Exit Do
  1081.                                                 end if
  1082.                                         else
  1083.                                                 iCount% = iCount% + 1
  1084.                                         end if
  1085.                                 else
  1086.                                         iCount% = iCount% + 1
  1087.                                 end if
  1088.                         else
  1089.                                 iCount% = iCount% + 1
  1090.                         end if
  1091.                         IF arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Empty THEN
  1092.                                 ' FOUND AN EMPTY SPACE, EXIT
  1093.                                 bFound = TRUE
  1094.                                 Exit Do
  1095.                         END IF
  1096.                 Loop
  1097.         END IF
  1098.        
  1099.         IF bFound = TRUE THEN
  1100.                 ' PLACE PLAYER
  1101.                 iMyColor& = cRed&
  1102.                 iColorScheme% = 2
  1103.                
  1104.                 ' PICK A DIRECTION (SIMPLE FOR NOW, LEFT OR RIGHT)
  1105.                 if iX% <= m_iMapMidX then
  1106.                         iDirection% = c_iDir_Right
  1107.                 else
  1108.                         iDirection% = c_iDir_Left
  1109.                 end if
  1110.                
  1111.                 ' RESET MOVEMENT VARIABLES
  1112.                 bMoving = FALSE
  1113.                 bMoved = FALSE
  1114.                
  1115.                 ' RESET INPUT
  1116.                 WHILE _DEVICEINPUT(1): WEND ' clear and update the keyboard buffer
  1117.                 iLastKey = c_iKeyDown_Enter
  1118.                
  1119.                 ' DRAW PLAYER
  1120.                 arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Player1 ' c_iMapType_Wall
  1121.                 arrMap(iX%, iY%, iZ%).Color1 = iMyColor&
  1122.                 arrMap(iX%, iY%, iZ%).AlphaOverride = 255
  1123.                
  1124.                 ' =============================================================================
  1125.                 ' MAIN LOOP
  1126.                 bFinished = FALSE
  1127.                 Do
  1128.                         ' PLOT GRAPHICS TO SCREEN
  1129.                         CLS ' is cls necessary?
  1130.                         ComputeVisible arrMap(), iX%, iY%, iZ%
  1131.                         DrawIsometricScreen arrMap()
  1132.                        
  1133.                         ' SHOW INSTRUCTIONS / COORDINATES ON SCREEN
  1134.                         LOCATE 1, 1: PRINT "IsometricDemo3"
  1135.                         LOCATE 3, 1: PRINT "CRSR RIGHT/LEFT   MOVES X=" + CSTR$(iX%)
  1136.                         LOCATE 4, 1: PRINT "CRSR UP   /DOWN   MOVES Y=" + CSTR$(iY%)
  1137.                         LOCATE 5, 1: PRINT "PAGE UP   /DOWN   MOVES Z=" + CSTR$(iZ%)
  1138.                         LOCATE 6, 1: PRINT "+ / -   CHANGES GRID SIZE=" + CSTR$(m_iGridSize)
  1139.                         LOCATE 7, 1: PRINT "SPACE TOGGLES CONTINUOUS MOVEMENT = " + IIFSTR$(bMoving, "TRUE", "FALSE")
  1140.                         LOCATE 9, 1: PRINT "PRESS <ESC> TO QUIT"
  1141.                        
  1142.                         ' SHOW 2D MINI MAP ON SCREEN
  1143.                         FOR iLoopX% = m_iMapMinX TO m_iMapMaxX
  1144.                                 FOR iLoopY% = m_iMapMinY TO m_iMapMaxY
  1145.                                         iDrawX% = (iLoopX% * 4) + 20
  1146.                                         iDrawY% = (iLoopY% * 4) + 200
  1147.                                         IF arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Wall THEN
  1148.                                                 DrawBox iDrawX%, iDrawY%, 4, arrMap(iLoopX%, iLoopY%, iZ%).Color1
  1149.                                                
  1150.                                         ELSEIF arrMap(iLoopX%, iLoopY%, iZ%).Typ = c_iMapType_Player1 THEN
  1151.                                                 DrawBox iDrawX%, iDrawY%, 4, arrMap(iLoopX%, iLoopY%, iZ%).Color1
  1152.                                                
  1153.                                         ELSE
  1154.                                                 DrawBox iDrawX%, iDrawY%, 4, cBlack&
  1155.                                         END IF
  1156.                                 NEXT iLoopY%
  1157.                         NEXT iLoopX%
  1158.                        
  1159.                         ' GET KEYBOARD INPUT
  1160.                         If _KeyDown(c_iKeyDown_Up) Then
  1161.                                 If iLastKey <> c_iKeyDown_Up Then
  1162.                                         iLastKey = c_iKeyDown_Up
  1163.                                         iDirection% = c_iDir_Back
  1164.                                         bMoved = TRUE
  1165.                                 End If
  1166.                         ElseIf _KeyDown(c_iKeyDown_Down) Then
  1167.                                 If iLastKey <> c_iKeyDown_Down Then
  1168.                                         iLastKey = c_iKeyDown_Down
  1169.                                         iDirection% = c_iDir_Forward
  1170.                                         bMoved = TRUE
  1171.                                 End If
  1172.                         ElseIf _KeyDown(c_iKeyDown_Left) Then
  1173.                                 If iLastKey <> c_iKeyDown_Left Then
  1174.                                         iLastKey = c_iKeyDown_Left
  1175.                                         iDirection% = c_iDir_Left
  1176.                                         bMoved = TRUE
  1177.                                 End If
  1178.                         ElseIf _KeyDown(c_iKeyDown_Right) Then
  1179.                                 If iLastKey <> c_iKeyDown_Right Then
  1180.                                         iLastKey = c_iKeyDown_Right
  1181.                                         iDirection% = c_iDir_Right
  1182.                                         bMoved = TRUE
  1183.                                 End If
  1184.                         ElseIf _KeyDown(c_iKeyDown_PgUp) Then
  1185.                                 If iLastKey <> c_iKeyDown_PgUp Then
  1186.                                         iLastKey = c_iKeyDown_PgUp
  1187.                                         iDirection% = c_iDir_Up
  1188.                                         bMoved = TRUE
  1189.                                 End If
  1190.                         ElseIf _KeyDown(c_iKeyDown_PgDn) Then
  1191.                                 If iLastKey <> c_iKeyDown_PgDn Then
  1192.                                         iLastKey = c_iKeyDown_PgDn
  1193.                                         iDirection% = c_iDir_Down
  1194.                                         bMoved = TRUE
  1195.                                 End If
  1196.                         ElseIf _KeyDown(c_iKeyDown_Spacebar) Then
  1197.                                 If iLastKey <> c_iKeyDown_Spacebar Then
  1198.                                         iLastKey = c_iKeyDown_Spacebar
  1199.                                         'bMoving = IIF(bMoving, False, True)
  1200.                                         IF bMoving = TRUE THEN
  1201.                                                 bMoving = FALSE
  1202.                                         ELSE
  1203.                                                 bMoving = TRUE
  1204.                                         END IF
  1205.                                 End If
  1206.                         ElseIf _KeyDown(c_iKeyDown_Minus) Then
  1207.                                 If iLastKey <> c_iKeyDown_Minus Then
  1208.                                         iLastKey = c_iKeyDown_Minus
  1209.                                         m_iGridSize = m_iGridSize - 1
  1210.                                         IF m_iGridSize < m_iGridSizeMin THEN
  1211.                                                 m_iGridSize = m_iGridSizeMin
  1212.                                         ELSE
  1213.                                                 bMoved = TRUE
  1214.                                         END IF
  1215.                                 End If
  1216.                         ElseIf _KeyDown(c_iKeyDown_EqualPlus) Then
  1217.                                 If iLastKey <> c_iKeyDown_EqualPlus Then
  1218.                                         iLastKey = c_iKeyDown_EqualPlus
  1219.                                         m_iGridSize = m_iGridSize + 1
  1220.                                         IF m_iGridSize > m_iGridSizeMax THEN
  1221.                                                 m_iGridSize = m_iGridSizeMax
  1222.                                         ELSE
  1223.                                                 bMoved = TRUE
  1224.                                         END IF
  1225.                                 End If
  1226.                         ElseIf _KeyDown(c_iKeyDown_Esc) Then
  1227.                                 Exit Do
  1228.                         Else
  1229.                                 iLastKey = -1
  1230.                         End If
  1231.                        
  1232.                         ' --------------------------------------------------------------------------------
  1233.                         ' ERASE OLD POSITION
  1234.                         ' --------------------------------------------------------------------------------
  1235.                         arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Empty
  1236.                         arrMap(iX%, iY%, iZ%).Color1 = cEmpty&
  1237.                         arrMap(iX%, iY%, iZ%).AlphaOverride = 255
  1238.                        
  1239.                         ' --------------------------------------------------------------------------------
  1240.                         ' MOVE PLAYER BASED ON DIRECTION
  1241.                         ' --------------------------------------------------------------------------------
  1242.                         'IF bMoved=TRUE THEN
  1243.                         IF bMoving=TRUE OR bMoved=TRUE THEN
  1244.                                 bMoved = FALSE
  1245.                                
  1246.                                 SELECT CASE iDirection%
  1247.                                         CASE c_iDir_Down:
  1248.                                                 iNewX% = iX%
  1249.                                                 iNewY% = iY%
  1250.                                                 iNewZ% = iZ% - 1
  1251.                                                 If iNewZ% < m_iMapMinZ Then
  1252.                                                         iNewZ% = m_iMapMaxZ
  1253.                                                 End If
  1254.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1255.                                                         iDirection% = c_iDir_Up
  1256.                                                         iNewZ% = iZ%
  1257.                                                 End If
  1258.                                                
  1259.                                         CASE c_iDir_Up:
  1260.                                                 iNewX% = iX%
  1261.                                                 iNewY% = iY%
  1262.                                                 iNewZ% = iZ% + 1
  1263.                                                 If iNewZ% > m_iMapMaxZ Then
  1264.                                                         iNewZ% = m_iMapMinZ
  1265.                                                 End If
  1266.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1267.                                                         iDirection% = c_iDir_Down
  1268.                                                         iNewZ% = iZ%
  1269.                                                 End If
  1270.                                                
  1271.                                         CASE c_iDir_Left:
  1272.                                                 iNewX% = iX% - 1
  1273.                                                 iNewY% = iY%
  1274.                                                 iNewZ% = iZ%
  1275.                                                 If iNewX% < m_iMapMinX Then
  1276.                                                         iNewX% = m_iMapMaxX
  1277.                                                 End If
  1278.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1279.                                                         iDirection% = c_iDir_Right
  1280.                                                         iNewX% = iX%
  1281.                                                 End If
  1282.                                                
  1283.                                         CASE c_iDir_Right:
  1284.                                                 iNewX% = iX% + 1
  1285.                                                 iNewY% = iY%
  1286.                                                 iNewZ% = iZ%
  1287.                                                 If iNewX% > m_iMapMaxX Then
  1288.                                                         iNewX% = m_iMapMinX
  1289.                                                 End If
  1290.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1291.                                                         iDirection% = c_iDir_Left
  1292.                                                         iNewX% = iX%
  1293.                                                 End If
  1294.                                                
  1295.                                         CASE c_iDir_Back:
  1296.                                                 iNewX% = iX%
  1297.                                                 iNewY% = iY% - 1
  1298.                                                 iNewZ% = iZ%
  1299.                                                 If iNewY% < m_iMapMinY Then
  1300.                                                         iNewY% = m_iMapMaxY
  1301.                                                 End If
  1302.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1303.                                                         iDirection% = c_iDir_Forward
  1304.                                                         iNewY% = iY%
  1305.                                                 End If
  1306.                                                
  1307.                                         CASE c_iDir_Forward:
  1308.                                                 iNewX% = iX%
  1309.                                                 iNewY% = iY% + 1
  1310.                                                 iNewZ% = iZ%
  1311.                                                 If iNewY% > m_iMapMaxY Then
  1312.                                                         iNewY% = m_iMapMinY
  1313.                                                 End If
  1314.                                                 If arrMap(iNewX%, iNewY%, iNewZ%).Typ <> c_iMapType_Empty Then
  1315.                                                         iDirection% = c_iDir_Back
  1316.                                                         iNewY% = iY%
  1317.                                                 End If
  1318.                                                
  1319.                                         CASE ELSE:
  1320.                                                 'iNewX% = iX%
  1321.                                                 'iNewY% = iY%
  1322.                                                 'iNewZ% = iZ%
  1323.                                 END SELECT
  1324.                                
  1325.                                 ' SAVE NEW POSITION
  1326.                                 iX% = iNewX%
  1327.                                 iY% = iNewY%
  1328.                                 iZ% = iNewZ%
  1329.                         END IF
  1330.                        
  1331.                         ' REDRAW AT CURRENT POSITION
  1332.                         DoCycleColor iColorScheme%, iMyColor&
  1333.                         arrMap(iX%, iY%, iZ%).Typ = c_iMapType_Player1 ' c_iMapType_Wall
  1334.                         arrMap(iX%, iY%, iZ%).Color1 = iMyColor&
  1335.                         arrMap(iX%, iY%, iZ%).AlphaOverride = 255
  1336.                        
  1337.                 _Limit 30
  1338.                 _Display
  1339.                
  1340.                 Loop
  1341.         ELSE
  1342.                 sResult = "Could not find an empty space to start player."
  1343.         END IF
  1344.        
  1345.         ' FINISH UP AND EXIT
  1346.     WHILE _DEVICEINPUT(1): WEND ' clear and update the keyboard buffer
  1347.         SCREEN 0
  1348.         IsometricDemo3$ = sResult
  1349. End Sub ' IsometricDemo3
  1350.  
  1351. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1352. ' BEGIN GRAPHICS FUNCTIONS
  1353. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1354.  
  1355. ' =============================================================================
  1356. ' LET'S GET THE COORDINATES STRAIGHT!
  1357. ' Coordinates are arrMap(x,y,z)
  1358. '           ________________
  1359. '          /|e            /|e
  1360. '         / |            / |
  1361. '        /  |           /  |z-axis
  1362. '       /   |          /   |
  1363. '      /    /---------/----/
  1364. '     /    / a       /   b/  
  1365. '    /    /         /    /        
  1366. '   |--------------|    /  
  1367. '   |f  /         g|   / y-axis
  1368. '   |  /           |  /
  1369. '   | /            | /
  1370. '   |/c           d|/
  1371. '   ----------------
  1372. '      x-axis
  1373. '
  1374. ' POINT    ( X, Y, Z)
  1375. ' a        ( 0, 0, 0)
  1376. ' b        (32, 0, 0)
  1377. ' c        ( 0,32, 0)
  1378. ' d        (32,32, 0)
  1379. ' e        ( 0, 0,32)
  1380. ' f        ( 0,32,32)
  1381. ' g        (32,32,32)
  1382. ' =============================================================================
  1383.  
  1384. ' /////////////////////////////////////////////////////////////////////////////
  1385. ' INITIALIZE MAP TO EMPTY
  1386.  
  1387. 'ClearIsometricMap arrMap()
  1388. Sub ClearIsometricMap (arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType)
  1389.     Dim RoutineName As String: RoutineName = "ClearIsometricMap"
  1390.     Dim iLoopX%
  1391.     Dim iLoopY%
  1392.     Dim iLoopZ%
  1393.        
  1394.         For iLoopZ% = m_iMapMinZ To m_iMapMaxZ
  1395.                 For iLoopX% = m_iMapMinX To m_iMapMaxX
  1396.                         For iLoopY% = m_iMapMinY To m_iMapMaxY
  1397.                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Empty
  1398.                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride = 255
  1399.                         Next iLoopY%
  1400.                 Next iLoopX%
  1401.         Next iLoopZ%
  1402. End Sub ' ClearIsometricMap
  1403.  
  1404.  
  1405. ' /////////////////////////////////////////////////////////////////////////////
  1406. ' Determine which squares are visible in isometric map
  1407.  
  1408. ' arrMap(x,y,z) = 3D array map of world
  1409. ' iX% = player's X positon
  1410. ' iY% = player's Y position
  1411. ' iZ% = player's Z position
  1412.  
  1413. Sub ComputeVisible (arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType, iX%, iY%, iZ%)
  1414.     Dim iLoopX%
  1415.     Dim iLoopY%
  1416.     Dim iLoopZ%
  1417.        
  1418.         Dim iPX1%
  1419.         Dim iPY1%
  1420.         Dim iPZ1%
  1421.         Dim iPlayer2Dx As Integer
  1422.         Dim iPlayer2Dy As Integer
  1423.         Dim iBrick2Dx As Integer
  1424.         Dim iBrick2Dy As Integer
  1425.        
  1426.         ' CALCULATE PLAYER'S 2-D POSITION
  1427.         iPX1% = iX% * m_iGridSize + cGridOffsetX
  1428.         iPY1% = iY% * m_iGridSize + cGridOffsetY
  1429.         iPZ1% = iZ% * m_iGridSize + cGridOffsetZ
  1430.     iPlayer2Dx = CX2I(iPX1%, iPY1%) + cScreenOffsetX
  1431.     iPlayer2Dy = (CY2I(iPX1%, iPY1%) + cScreenOffsetY) - iPZ1%
  1432.         'fquad TempX1, TempY1 - z, TempX2, TempY2 - z, TempX3, TempY3 - z, TempX4, TempY4 - z, _RGB32(r, g, b, alpha&) 
  1433.        
  1434.         For iLoopX% = m_iMapMinX To m_iMapMaxX
  1435.                 For iLoopY% = m_iMapMinY To m_iMapMaxY
  1436.                         For iLoopZ% = m_iMapMinZ To m_iMapMaxZ
  1437.                                 ' If space has a brick
  1438.                                 ' and its 2D (X,Y) is > Player's 2D (X,Y)
  1439.                                 ' then make the brick transparent
  1440.                                 If arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall Then
  1441.                                         ' CALCULATE BRICK'S 2-D POSITION
  1442.                                         iPX1% = iLoopX% * m_iGridSize + cGridOffsetX
  1443.                                         iPY1% = iLoopY% * m_iGridSize + cGridOffsetY
  1444.                                         iPZ1% = iLoopZ% * m_iGridSize + cGridOffsetZ
  1445.                                         iBrick2Dx = CX2I(iPX1%, iPY1%) + cScreenOffsetX
  1446.                                         iBrick2Dy = (CY2I(iPX1%, iPY1%) + cScreenOffsetY) - iPZ1%
  1447.                                         'fquad TempX1, TempY1 - z, TempX2, TempY2 - z, TempX3, TempY3 - z, TempX4, TempY4 - z, _RGB32(r, g, b, alpha&) 
  1448.                                        
  1449.                                         'If iLoopZ% >= iZ% Then
  1450.                                                 'If iLoopX% >= iX% Then
  1451.                                                         If iLoopY% > iY% Then
  1452.                                                                 If ( iPlayer2Dy >= (iBrick2Dy - m_iGridSize) ) AND ( iPlayer2Dy <= (iBrick2Dy + m_iGridSize) ) Then
  1453.                                                                         If ( iPlayer2Dx >= (iBrick2Dx - m_iGridSize) ) AND ( iPlayer2Dx <= (iBrick2Dx + m_iGridSize) ) Then
  1454.                                                                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride = 86
  1455.                                                                         Else
  1456.                                                                                 arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride = 255
  1457.                                                                         End If
  1458.                                                                 Else
  1459.                                                                         arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride = 255
  1460.                                                                 End If
  1461.                                                         End If
  1462.                                                 'End If
  1463.                                         'End If
  1464.                                 Else
  1465.                                         arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride = 255
  1466.                                 End If
  1467.                         Next iLoopZ%
  1468.                 Next iLoopY%
  1469.         Next iLoopX%
  1470. End Sub ' ComputeVisible
  1471.  
  1472. ' /////////////////////////////////////////////////////////////////////////////
  1473. ' Draw the map in 3D Isometic Perspective
  1474.  
  1475. ' Parameters:
  1476. ' arrMap(x,y,z) = 3D array map of world
  1477. ' iX% = player's X positon
  1478. ' iY% = player's Y position
  1479. ' iZ% = player's Z position
  1480.  
  1481. 'DrawIsometricScreen arrMap()
  1482. Sub DrawIsometricScreen (arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType)
  1483.     Dim RoutineName As String: RoutineName = "DrawIsometricScreen"
  1484.     Dim bTile As Integer
  1485.     Dim iLoopX%
  1486.     Dim iLoopY%
  1487.     Dim iLoopZ%
  1488.     Dim iColor As _Unsigned Long
  1489.     Dim iPosX1%
  1490.     Dim iPosX2%
  1491.     Dim iPosY1%
  1492.     Dim iPosY2%
  1493.     Dim iPosZ1%
  1494.         Dim alpha&
  1495.        
  1496.         alpha& = 255
  1497.         bTile = FALSE
  1498.         For iLoopZ% = m_iMapMinZ To m_iMapMaxZ
  1499.                 For iLoopX% = m_iMapMinX To m_iMapMaxX
  1500.                         For iLoopY% = m_iMapMinY To m_iMapMaxY
  1501.                                
  1502.                                 ' CALCULATE POSITION
  1503.                                 iPosZ1% = iLoopZ% * m_iGridSize + cGridOffsetZ
  1504.                                 iPosX1% = iLoopX% * m_iGridSize + cGridOffsetX
  1505.                                 iPosY1% = iLoopY% * m_iGridSize + cGridOffsetY
  1506.                                 iPosX2% = iPosX1% + m_iGridSize
  1507.                                 iPosY2% = iPosY1% + m_iGridSize
  1508.                                
  1509.                                 ' DETERMINE COLOR
  1510.                                 If arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Floor_Tiled Then
  1511.                                         If bTile = TRUE Then
  1512.                                                 iColor = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1
  1513.                                                 bTile = FALSE
  1514.                                         Else
  1515.                                                 iColor = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color2
  1516.                                                 bTile = TRUE
  1517.                                         End If
  1518.                                 ElseIf arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Wall Then
  1519.                                         iColor = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1
  1520.                                         alpha& = arrMap(iLoopX%, iLoopY%, iLoopZ%).AlphaOverride
  1521.                                        
  1522.                                 ElseIf arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Player1 Then
  1523.                                         iColor = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1
  1524.                                         alpha& = 255
  1525.                                        
  1526.                                 ElseIf arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Player2 Then
  1527.                                         iColor = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1
  1528.                                         alpha& = 255
  1529.                                        
  1530.                                 ElseIf arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Water Then
  1531.                                         'TODO: transparent for water
  1532.                                         iColor = cEmpty&
  1533.                                         alpha& = 64
  1534.                                        
  1535.                                 ElseIf arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ = c_iMapType_Window Then
  1536.                                         'TODO: transparent for windows
  1537.                                         iColor = cEmpty&
  1538.                                         alpha& = 64
  1539.                                        
  1540.                                 Else
  1541.                                         iColor = cEmpty&
  1542.                                 End If
  1543.                                
  1544.                                 ' PLOT NEXT BLOCK
  1545.                                 If iColor <> cEmpty& Then
  1546.                                         'IsoLine3D(x,      y,       x2,      y2,      z,       iHeight,     xoffset,        yoffset,        iColor As _Unsigned Long, alpha&)
  1547.                                         IsoLine3D iPosX1%, iPosY1%, iPosX2%, iPosY2%, iPosZ1%, m_iGridSize, cScreenOffsetX, cScreenOffsetY, iColor, alpha&
  1548.                                 End If
  1549.                                
  1550.                         Next iLoopY%
  1551.                 Next iLoopX%
  1552.         Next iLoopZ%
  1553.        
  1554. End Sub ' DrawIsometricScreen
  1555.  
  1556. ' /////////////////////////////////////////////////////////////////////////////
  1557. ' RETURNS MAP AS TEXT
  1558.  
  1559. 'Input "See a text dump (y/n)? ", in$
  1560. 'If LCase$(in$) = LCase$("y") Then
  1561. '    Print MapToText$( arrMap() )
  1562. 'End If
  1563. Function MapToText$ (arrMap(m_iMapMinX To m_iMapMaxX, m_iMapMinY To m_iMapMaxY, m_iMapMinZ To m_iMapMaxZ) As MapBlockType)
  1564.     Dim RoutineName As String: RoutineName = "MapToText$"
  1565.     Dim sResult As String
  1566.     Dim iLoopX%
  1567.     Dim iLoopY%
  1568.     Dim iLoopZ%
  1569.     Dim iMinX%
  1570.     Dim iMaxX%
  1571.     Dim iMinY%
  1572.     Dim iMaxY%
  1573.     Dim iMinZ%
  1574.     Dim iMaxZ%
  1575.     Dim sLine As String
  1576.     Dim iType%
  1577.         Dim iColor1&
  1578.         Dim iColor2&
  1579.         Dim iColor3&
  1580.     Dim in$
  1581.  
  1582.     sResult = ""
  1583.  
  1584.     ' FIND USED BOUNDARIES OF MAP
  1585.     iMinX% = -1
  1586.     iMaxX% = -1
  1587.     iMinY% = -1
  1588.     iMaxY% = -1
  1589.     iMinZ% = -1
  1590.     iMaxZ% = -1
  1591.     For iLoopZ% = 0 To 32
  1592.         For iLoopX% = 0 To 32
  1593.             For iLoopY% = 0 To 32
  1594.                 iType% = arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ
  1595.                 If iType% <> c_iMapType_Empty And iType% <> c_iMapType_Floor_Tiled Then
  1596.                     If iMinX% = -1 Then
  1597.                         iMinX% = iLoopX%
  1598.                     End If
  1599.                     If iMinY% = -1 Then
  1600.                         iMinY% = iLoopY%
  1601.                     End If
  1602.                     If iMinZ% = -1 Then
  1603.                         iMinZ% = iLoopZ%
  1604.                     End If
  1605.                     If iLoopX% > iMaxX% Then
  1606.                         iMaxX% = iLoopX%
  1607.                     End If
  1608.                     If iLoopY% > iMaxY% Then
  1609.                         iMaxY% = iLoopY%
  1610.                     End If
  1611.                     If iLoopZ% > iMaxZ% Then
  1612.                         iMaxZ% = iLoopZ%
  1613.                     End If
  1614.                 End If
  1615.             Next iLoopY%
  1616.         Next iLoopX%
  1617.     Next iLoopZ%
  1618.  
  1619.     ' GENERATE OUTPUT
  1620.     For iLoopZ% = iMinZ% To iMaxZ%
  1621.         sResult = sResult + "-------------------------------------------------------------------------------" + Chr$(13)
  1622.         sResult = sResult + "Map Z=" + cstr$(iLoopZ%) + ":" + Chr$(13)
  1623.         sResult = sResult + "-------------------------------------------------------------------------------" + Chr$(13)
  1624.         For iLoopY% = iMinY% To iMaxY%
  1625.             sLine = ""
  1626.             For iLoopX% = iMinX% To iMaxX%
  1627.                 iType% = arrMap(iLoopX%, iLoopY%, iLoopZ%).Typ
  1628.                                 iColor1& = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color1
  1629.                                 iColor2& = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color2
  1630.                                 iColor3& = arrMap(iLoopX%, iLoopY%, iLoopZ%).Color3
  1631.                                
  1632.                 If iType% = c_iMapType_Empty Then
  1633.                     sLine = sLine + " "
  1634.                 Else
  1635.                     If iColor1& = cEmpty& Then
  1636.                         sLine = sLine + " "
  1637.                     Else
  1638.                         sLine = sLine + "#"
  1639.                     End If
  1640.                 End If
  1641.             Next iLoopX%
  1642.             sResult = sResult + sLine + Chr$(13)
  1643.         Next iLoopY%
  1644.  
  1645.         sResult = sResult + Chr$(13)
  1646.     Next iLoopZ%
  1647.  
  1648.     MapToText$ = sResult
  1649. End Function ' MapToText$
  1650.  
  1651. ' /////////////////////////////////////////////////////////////////////////////
  1652.  
  1653. Function CX2I (x As Long, y As Long) 'Convert Cartesian X To Isometic coordinates
  1654.     CX2I = x - y
  1655. End Function ' CX2I
  1656.  
  1657. ' /////////////////////////////////////////////////////////////////////////////
  1658.  
  1659. Function CY2I (x As Long, y As Long) 'Convert Cartesian Y To Isometic coordinates
  1660.     CY2I = (x + y) / 2
  1661. End Function ' CY2I
  1662.  
  1663. ' /////////////////////////////////////////////////////////////////////////////
  1664. ' since we're drawing a diamond and not a square box, we can't use Line BF.
  1665. ' We have to manually down the 4 points of the line.
  1666.  
  1667. Sub IsoLine (x, y, x2, y2, xoffset, yoffset, iColor As _Unsigned Long)
  1668.     Line (CX2I(x, y) + xoffset, CY2I(x, y) + yoffset)-(CX2I(x2, y) + xoffset, CY2I(x2, y) + yoffset), iColor
  1669.     Line -(CX2I(x2, y2) + xoffset, CY2I(x2, y2) + yoffset), iColor
  1670.     Line -(CX2I(x, y2) + xoffset, CY2I(x, y2) + yoffset), iColor
  1671.     Line -(CX2I(x, y) + xoffset, CY2I(x, y) + yoffset), iColor
  1672.     Paint (CX2I(x, y) + xoffset, CY2I(x, y) + 4), iColor 'and fill the diamond solid
  1673.     Line (CX2I(x, y) + xoffset, CY2I(x, y) + yoffset)-(CX2I(x2, y) + xoffset, CY2I(x2, y) + yoffset), &HFFFFFFFF
  1674.     Line -(CX2I(x2, y2) + xoffset, CY2I(x2, y2) + yoffset), &HFFFFFFFF
  1675.     Line -(CX2I(x, y2) + xoffset, CY2I(x, y2) + yoffset), &HFFFFFFFF
  1676.     Line -(CX2I(x, y) + xoffset, CY2I(x, y) + yoffset), &HFFFFFFFF
  1677. End Sub ' IsoLine
  1678.  
  1679. ' /////////////////////////////////////////////////////////////////////////////
  1680. ' Like IsoLine, we're going to have to draw our lines manually.
  1681. ' only in this case, we also need a Z coordinate to tell us how
  1682. ' THICK/TALL/HIGH to make our tile
  1683.  
  1684. ' MODIFIED by madscijr to draw a single block of height iHeight at Z axis
  1685. ' MODIFIED by madscijr to accept an alpha& value to control transparency (where 0=fully transparent, 255=opaque)
  1686.  
  1687. ''Sub IsoLine3D (x, y, x2, y2, z, xoffset, yoffset, iColor As _Unsigned Long)
  1688. 'Sub IsoLine3D (x, y, x2, y2, z, iHeight, xoffset, yoffset, iColor As _Unsigned Long)
  1689. Sub IsoLine3D (x, y, x2, y2, z, iHeight, xoffset, yoffset, iColor As _Unsigned Long, alpha&)
  1690.     dim r as integer
  1691.         dim g as integer
  1692.         dim b as integer
  1693.         'dim iNewColor As _Unsigned Long
  1694.        
  1695.         r = _Red32(iColor)
  1696.         g = _Green32(iColor)
  1697.         b = _Blue32(iColor)
  1698.        
  1699.     ' Let's just do all the math first this time.
  1700.     ' We need to turn those 4 normal points into 4 isometric points (x, y, x1, y1)
  1701.     TempX1 = CX2I(x, y) + xoffset
  1702.     TempY1 = CY2I(x, y) + yoffset
  1703.     TempX2 = CX2I(x2, y) + xoffset
  1704.     TempY2 = CY2I(x2, y) + yoffset
  1705.     TempX3 = CX2I(x2, y2) + xoffset
  1706.     TempY3 = CY2I(x2, y2) + yoffset
  1707.     TempX4 = CX2I(x, y2) + xoffset
  1708.     TempY4 = CY2I(x, y2) + yoffset
  1709.        
  1710.     ' The top
  1711.     'fquad TempX1, TempY1 - z, TempX2, TempY2 - z, TempX3, TempY3 - z, TempX4, TempY4 - z, iColor
  1712.         fquad TempX1, TempY1 - z, TempX2, TempY2 - z, TempX3, TempY3 - z, TempX4, TempY4 - z, _RGB32(r, g, b, alpha&)
  1713.        
  1714.     If z <> 0 Then
  1715.         ' TODO: maybe change which sides gets shaded depending on the direction of the light source?
  1716.                
  1717.                 ' draw the left side, shaded 75%
  1718.         'fquad TempX4, TempY4 - z, TempX4, TempY4 - z + iHeight, TempX3, TempY3 - z + iHeight, TempX3, TempY3 - z, _RGB32(.75 * r, .75 * g, .75 * b)
  1719.         fquad TempX4, TempY4 - z, TempX4, TempY4 - z + iHeight, TempX3, TempY3 - z + iHeight, TempX3, TempY3 - z, _RGB32(.75 * r, .75 * g, .75 * b, alpha&)
  1720.                
  1721.         ' draw the right side,s haded 50%
  1722.                 'fquad TempX3, TempY3 - z, TempX3, TempY3 - z + iHeight, TempX2, TempY2 - z + iHeight, TempX2, TempY2 - z, _RGB32(.5 * r, .5 * g, .5 * b)
  1723.                 fquad TempX3, TempY3 - z, TempX3, TempY3 - z + iHeight, TempX2, TempY2 - z + iHeight, TempX2, TempY2 - z, _RGB32(.5 * r, .5 * g, .5 * b, alpha&)
  1724.     Else
  1725.         ' no need to draw any height, if there isn't any.
  1726.     End If
  1727. End Sub ' IsoLine3D
  1728.  
  1729. ' /////////////////////////////////////////////////////////////////////////////
  1730. ' found at abandoned, outdated and now likely malicious qb64 dot net website
  1731. ' don’t go there: http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  1732.  
  1733. Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
  1734.     Dim D As Long
  1735.     Dim a&
  1736.  
  1737.     D = _Dest
  1738.     a& = _NewImage(1, 1, 32)
  1739.     _Dest a&
  1740.     PSet (0, 0), K
  1741.     _Dest D
  1742.     _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
  1743.     _FreeImage a& ' <<< this is important!
  1744. End Sub ' ftri
  1745.  
  1746. ' /////////////////////////////////////////////////////////////////////////////
  1747. ' 2019-11-20 Steve saves some time with STATIC
  1748. ' and saves and restores last dest
  1749.  
  1750. Sub ftri1 (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
  1751.     Dim D As Long
  1752.     Static a&
  1753.  
  1754.     D = _Dest
  1755.     If a& = 0 Then
  1756.         a& = _NewImage(1, 1, 32)
  1757.     End If
  1758.     _Dest a&
  1759.     _DontBlend a&
  1760.     PSet (0, 0), K
  1761.     _Blend a&
  1762.     _Dest D
  1763.     _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
  1764. End Sub ' ftri1
  1765.  
  1766. ' /////////////////////////////////////////////////////////////////////////////
  1767. ' original fill quad that may be at fault using Steve's fTri version
  1768. ' need 4 non linear points (not all on 1 line) list them clockwise
  1769. ' so x2, y2 is opposite of x4, y4
  1770.  
  1771. Sub fquad1 (x1, y1, x2, y2, x3, y3, x4, y4, K As _Unsigned Long)
  1772.     ftri1 x1, y1, x2, y2, x4, y4, K
  1773.     ftri1 x3, y3, x2, y2, x4, y4, K
  1774. End Sub ' fquad1
  1775.  
  1776. ' /////////////////////////////////////////////////////////////////////////////
  1777. ' update 2019-12-16 needs orig fTri
  1778. ' need 4 non linear points (not all on 1 line)
  1779. ' list them clockwise so x2, y2 is opposite of x4, y4
  1780.  
  1781. Sub fquad (x1, y1, x2, y2, x3, y3, x4, y4, K As _Unsigned Long)
  1782.     ftri x1, y1, x2, y2, x3, y3, K
  1783.     ftri x3, y3, x4, y4, x1, y1, K
  1784. End Sub ' fquad
  1785.  
  1786. ' /////////////////////////////////////////////////////////////////////////////
  1787. ' DRAW A 2-D BOX
  1788.  
  1789. 'SUB DrawBox (iX%, iY%, iSize%, iColor%)
  1790. SUB DrawBox (iX%, iY%, iSize%, iColor&)
  1791.     LINE (iX%, iY%)-(iX% + iSize%, iY% + iSize%), iColor&, BF ' Draw a solid box
  1792.         'LINE (iX%, iY%)-(iX% + iSize%, iY% + iSize%), iColor%, BF ' Draw a solid box
  1793.     'LINE (60, 60)-(130, 100), iColor%, B ' Draw a box outline
  1794. END SUB ' DrawBox
  1795.  
  1796. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1797. ' END GRAPHICS FUNCTIONS
  1798. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1799.  
  1800. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1801. ' BEGIN GENERAL PURPOSE FUNCTIONS
  1802. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  1803.  
  1804. ' /////////////////////////////////////////////////////////////////////////////
  1805.  
  1806. Function cstr$ (myValue)
  1807.     'cstr$ = LTRIM$(RTRIM$(STR$(myValue)))
  1808.     cstr$ = _Trim$(Str$(myValue))
  1809. End Function ' cstr$
  1810.  
  1811. ' /////////////////////////////////////////////////////////////////////////////
  1812.  
  1813. Function cstrl$ (myValue As Long)
  1814.     cstrl$ = _Trim$(Str$(myValue))
  1815. End Function ' cstrl$
  1816.  
  1817. ' /////////////////////////////////////////////////////////////////////////////
  1818.  
  1819. Function cstrs$ (myValue As Single)
  1820.     ''cstr$ = LTRIM$(RTRIM$(STR$(myValue)))
  1821.     cstrs$ = _Trim$(Str$(myValue))
  1822. End Function ' cstrs$
  1823.  
  1824. ' /////////////////////////////////////////////////////////////////////////////
  1825.  
  1826. Function IIF (Condition, IfTrue, IfFalse)
  1827.     If Condition Then IIF = IfTrue Else IIF = IfFalse
  1828.  
  1829. ' /////////////////////////////////////////////////////////////////////////////
  1830.  
  1831. Function IIFSTR$ (Condition, IfTrue$, IfFalse$)
  1832.     If Condition Then IIFSTR$ = IfTrue$ Else IIFSTR$ = IfFalse$
  1833.  
  1834. ' /////////////////////////////////////////////////////////////////////////////
  1835. ' From: Bitwise Manipulations By Steven Roman
  1836. ' http://www.romanpress.com/Articles/Bitwise_R/Bitwise.htm
  1837.  
  1838. ' Returns the 8-bit binary representation
  1839. ' of an integer iInput where 0 <= iInput <= 255
  1840.  
  1841. Function GetBinary$ (iInput1 As Integer)
  1842.     Dim sResult As String
  1843.     Dim iLoop As Integer
  1844.     Dim iInput As Integer: iInput = iInput1
  1845.  
  1846.     sResult = ""
  1847.  
  1848.     If iInput >= 0 And iInput <= 255 Then
  1849.         For iLoop = 1 To 8
  1850.             sResult = LTrim$(RTrim$(Str$(iInput Mod 2))) + sResult
  1851.             iInput = iInput \ 2
  1852.             'If iLoop = 4 Then sResult = " " + sResult
  1853.         Next iLoop
  1854.     End If
  1855.  
  1856.     GetBinary$ = sResult
  1857. End Function ' GetBinary$
  1858.  
  1859. ' /////////////////////////////////////////////////////////////////////////////
  1860. ' wonderfully inefficient way to read if a bit is set
  1861. ' ival = GetBit256%(int we are comparing, int containing the bits we want to read)
  1862.  
  1863. ' See also: GetBit256%, SetBit256%
  1864.  
  1865. Function GetBit256% (iNum1 As Integer, iBit1 As Integer)
  1866.     Dim iResult As Integer
  1867.     Dim sNum As String
  1868.     Dim sBit As String
  1869.     Dim iLoop As Integer
  1870.     Dim bContinue As Integer
  1871.     'DIM iTemp AS INTEGER
  1872.     Dim iNum As Integer: iNum = iNum1
  1873.     Dim iBit As Integer: iBit = iBit1
  1874.  
  1875.     iResult = FALSE
  1876.     bContinue = TRUE
  1877.  
  1878.     If iNum < 256 And iBit <= 128 Then
  1879.         sNum = GetBinary$(iNum)
  1880.         sBit = GetBinary$(iBit)
  1881.         For iLoop = 1 To 8
  1882.             If Mid$(sBit, iLoop, 1) = "1" Then
  1883.                 'if any of the bits in iBit are false, return false
  1884.                 If Mid$(sNum, iLoop, 1) = "0" Then
  1885.                     iResult = FALSE
  1886.                     bContinue = FALSE
  1887.                     Exit For
  1888.                 End If
  1889.             End If
  1890.         Next iLoop
  1891.         If bContinue = TRUE Then
  1892.             iResult = TRUE
  1893.         End If
  1894.     End If
  1895.  
  1896.     GetBit256% = iResult
  1897. End Function ' GetBit256%
  1898.  
  1899. ' /////////////////////////////////////////////////////////////////////////////
  1900. ' From: Bitwise Manipulations By Steven Roman
  1901. ' http://www.romanpress.com/Articles/Bitwise_R/Bitwise.htm
  1902.  
  1903. ' Returns the integer that corresponds to a binary string of length 8
  1904.  
  1905. Function GetIntegerFromBinary% (sBinary1 As String)
  1906.     Dim iResult As Integer
  1907.     Dim iLoop As Integer
  1908.     Dim strBinary As String
  1909.     Dim sBinary As String: sBinary = sBinary1
  1910.  
  1911.     iResult = 0
  1912.     strBinary = Replace$(sBinary, " ", "") ' Remove any spaces
  1913.     For iLoop = 0 To Len(strBinary) - 1
  1914.         iResult = iResult + 2 ^ iLoop * Val(Mid$(strBinary, Len(strBinary) - iLoop, 1))
  1915.     Next iLoop
  1916.  
  1917.     GetIntegerFromBinary% = iResult
  1918. End Function ' GetIntegerFromBinary%
  1919.  
  1920. ' /////////////////////////////////////////////////////////////////////////////
  1921. ' By sMcNeill from https://www.qb64.org/forum/index.php?topic=896.0
  1922.  
  1923. Function IsNum% (text$)
  1924.     Dim a$
  1925.     Dim b$
  1926.     a$ = _Trim$(text$)
  1927.     b$ = _Trim$(Str$(Val(text$)))
  1928.     If a$ = b$ Then
  1929.         IsNum% = TRUE
  1930.     Else
  1931.         IsNum% = FALSE
  1932.     End If
  1933. End Function ' IsNum%
  1934.  
  1935. ' /////////////////////////////////////////////////////////////////////////////
  1936. ' Split and join strings
  1937. ' https://www.qb64.org/forum/index.php?topic=1073.0
  1938.  
  1939. 'Combine all elements of in$() into a single string with delimiter$ separating the elements.
  1940.  
  1941. Function join$ (in$(), delimiter$)
  1942.     result$ = in$(LBound(in$))
  1943.     For i = LBound(in$) + 1 To UBound(in$)
  1944.         result$ = result$ + delimiter$ + in$(i)
  1945.     Next i
  1946.     join$ = result$
  1947. End Function ' join$
  1948.  
  1949. ' /////////////////////////////////////////////////////////////////////////////
  1950. ' ABS was returning strange values with type LONG
  1951. ' so I created this which does not.
  1952.  
  1953. Function LongABS& (lngValue As Long)
  1954.     If Sgn(lngValue) = -1 Then
  1955.         LongABS& = 0 - lngValue
  1956.     Else
  1957.         LongABS& = lngValue
  1958.     End If
  1959. End Function ' LongABS&
  1960.  
  1961. ' /////////////////////////////////////////////////////////////////////////////
  1962. ' Returns blank if successful else returns error message.
  1963.  
  1964. Function PrintFile$ (sFileName As String, sText As String, bAppend As Integer)
  1965.     'x = 1: y = 2: z$ = "Three"
  1966.  
  1967.     Dim sError As String: sError = ""
  1968.  
  1969.     If Len(sError) = 0 Then
  1970.         If (bAppend = TRUE) Then
  1971.             If _FileExists(sFileName) Then
  1972.                 Open sFileName For Append As #1 ' opens an existing file for appending
  1973.             Else
  1974.                 sError = "Error in PrintFile$ : File not found. Cannot append."
  1975.             End If
  1976.         Else
  1977.             Open sFileName For Output As #1 ' opens and clears an existing file or creates new empty file
  1978.         End If
  1979.     End If
  1980.     If Len(sError) = 0 Then
  1981.         ' WRITE places text in quotes in the file
  1982.         'WRITE #1, x, y, z$
  1983.         'WRITE #1, sText
  1984.  
  1985.         ' PRINT does not put text inside quotes
  1986.         Print #1, sText
  1987.  
  1988.         Close #1
  1989.  
  1990.         'PRINT "File created with data. Press a key!"
  1991.         'K$ = INPUT$(1) 'press a key
  1992.  
  1993.         'OPEN sFileName FOR INPUT AS #2 ' opens a file to read it
  1994.         'INPUT #2, a, b, c$
  1995.         'CLOSE #2
  1996.  
  1997.         'PRINT a, b, c$
  1998.         'WRITE a, b, c$
  1999.     End If
  2000.  
  2001.     PrintFile$ = sError
  2002. End Function ' PrintFile$
  2003.  
  2004. ' /////////////////////////////////////////////////////////////////////////////
  2005. ' Generate random value between Min and Max.
  2006. Function RandomNumber% (Min%, Max%)
  2007.     Dim NumSpread%
  2008.  
  2009.     ' SET RANDOM SEED
  2010.     'Randomize ' Initialize random-number generator.
  2011.  
  2012.     ' GET RANDOM # Min%-Max%
  2013.     'RandomNumber = Int((Max * Rnd) + Min) ' generate number
  2014.  
  2015.     NumSpread% = (Max% - Min%) + 1
  2016.  
  2017.     RandomNumber% = Int(Rnd * NumSpread%) + Min% ' GET RANDOM # BETWEEN Max% AND Min%
  2018.  
  2019. End Function ' RandomNumber%
  2020.  
  2021. ' /////////////////////////////////////////////////////////////////////////////
  2022.  
  2023. Sub RandomNumberTest
  2024.     Dim iCols As Integer: iCols = 10
  2025.     Dim iRows As Integer: iRows = 20
  2026.     Dim iLoop As Integer
  2027.     Dim iX As Integer
  2028.     Dim iY As Integer
  2029.     Dim sError As String
  2030.     Dim sFileName As String
  2031.     Dim sText As String
  2032.     Dim bAppend As Integer
  2033.     Dim iMin As Integer
  2034.     Dim iMax As Integer
  2035.     Dim iNum As Integer
  2036.     Dim iErrorCount As Integer
  2037.     Dim sInput$
  2038.  
  2039.     sFileName = "c:\temp\maze_test_1.txt"
  2040.     sText = "Count" + Chr$(9) + "Min" + Chr$(9) + "Max" + Chr$(9) + "Random"
  2041.     bAppend = FALSE
  2042.     sError = PrintFile$(sFileName, sText, bAppend)
  2043.     If Len(sError) = 0 Then
  2044.         bAppend = TRUE
  2045.         iErrorCount = 0
  2046.  
  2047.         iMin = 0
  2048.         iMax = iCols - 1
  2049.         For iLoop = 1 To 100
  2050.             iNum = RandomNumber(iMin, iMax)
  2051.             sText = Str$(iLoop) + Chr$(9) + Str$(iMin) + Chr$(9) + Str$(iMax) + Chr$(9) + Str$(iNum)
  2052.             sError = PrintFile$(sFileName, sText, bAppend)
  2053.             If Len(sError) > 0 Then
  2054.                 iErrorCount = iErrorCount + 1
  2055.                 Print Str$(iLoop) + ". ERROR"
  2056.                 Print "    " + "iMin=" + Str$(iMin)
  2057.                 Print "    " + "iMax=" + Str$(iMax)
  2058.                 Print "    " + "iNum=" + Str$(iNum)
  2059.                 Print "    " + "Could not write to file " + Chr$(34) + sFileName + Chr$(34) + "."
  2060.                 Print "    " + sError
  2061.             End If
  2062.         Next iLoop
  2063.  
  2064.         iMin = 0
  2065.         iMax = iRows - 1
  2066.         For iLoop = 1 To 100
  2067.             iNum = RandomNumber(iMin, iMax)
  2068.             sText = Str$(iLoop) + Chr$(9) + Str$(iMin) + Chr$(9) + Str$(iMax) + Chr$(9) + Str$(iNum)
  2069.             sError = PrintFile$(sFileName, sText, bAppend)
  2070.             If Len(sError) > 0 Then
  2071.                 iErrorCount = iErrorCount + 1
  2072.                 Print Str$(iLoop) + ". ERROR"
  2073.                 Print "    " + "iMin=" + Str$(iMin)
  2074.                 Print "    " + "iMax=" + Str$(iMax)
  2075.                 Print "    " + "iNum=" + Str$(iNum)
  2076.                 Print "    " + "Could not write to file " + Chr$(34) + sFileName + Chr$(34) + "."
  2077.                 Print "    " + sError
  2078.             End If
  2079.         Next iLoop
  2080.  
  2081.         Print "Finished generating numbers. Errors: " + Str$(iErrorCount)
  2082.     Else
  2083.         Print "Error creating file " + Chr$(34) + sFileName + Chr$(34) + "."
  2084.         Print sError
  2085.     End If
  2086.  
  2087.     Input "Press <ENTER> to continue", sInput$
  2088. End Sub ' RandomNumberTest
  2089.  
  2090. ' /////////////////////////////////////////////////////////////////////////////
  2091. ' FROM: String Manipulation
  2092. ' http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index_topic_5964-0/
  2093. '
  2094. 'SUMMARY:
  2095. '   Purpose:  A library of custom functions that transform strings.
  2096. '   Author:   Dustinian Camburides (dustinian@gmail.com)
  2097. '   Platform: QB64 (www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there])
  2098. '   Revision: 1.6
  2099. '   Updated:  5/28/2012
  2100.  
  2101. 'SUMMARY:
  2102. '[Replace$] replaces all instances of the [Find] sub-string with the [Add] sub-string within the [Text] string.
  2103. 'INPUT:
  2104. 'Text: The input string; the text that's being manipulated.
  2105. 'Find: The specified sub-string; the string sought within the [Text] string.
  2106. 'Add: The sub-string that's being added to the [Text] string.
  2107.  
  2108. Function Replace$ (Text1 As String, Find1 As String, Add1 As String)
  2109.     ' VARIABLES:
  2110.     Dim Text2 As String
  2111.     Dim Find2 As String
  2112.     Dim Add2 As String
  2113.     Dim lngLocation As Long ' The address of the [Find] substring within the [Text] string.
  2114.     Dim strBefore As String ' The characters before the string to be replaced.
  2115.     Dim strAfter As String ' The characters after the string to be replaced.
  2116.  
  2117.     ' INITIALIZE:
  2118.     ' MAKE COPIESSO THE ORIGINAL IS NOT MODIFIED (LIKE ByVal IN VBA)
  2119.     Text2 = Text1
  2120.     Find2 = Find1
  2121.     Add2 = Add1
  2122.  
  2123.     lngLocation = InStr(1, Text2, Find2)
  2124.  
  2125.     ' PROCESSING:
  2126.     ' While [Find2] appears in [Text2]...
  2127.     While lngLocation
  2128.         ' Extract all Text2 before the [Find2] substring:
  2129.         strBefore = Left$(Text2, lngLocation - 1)
  2130.  
  2131.         ' Extract all text after the [Find2] substring:
  2132.         strAfter = Right$(Text2, ((Len(Text2) - (lngLocation + Len(Find2) - 1))))
  2133.  
  2134.         ' Return the substring:
  2135.         Text2 = strBefore + Add2 + strAfter
  2136.  
  2137.         ' Locate the next instance of [Find2]:
  2138.         lngLocation = InStr(1, Text2, Find2)
  2139.  
  2140.         ' Next instance of [Find2]...
  2141.     Wend
  2142.  
  2143.     ' OUTPUT:
  2144.     Replace$ = Text2
  2145. End Function ' Replace$
  2146.  
  2147. ' /////////////////////////////////////////////////////////////////////////////
  2148. ' fantastically inefficient way to set a bit
  2149.  
  2150. ' example use: arrMaze(iX, iY) = SetBit256%(arrMaze(iX, iY), cS, FALSE)
  2151.  
  2152. ' See also: GetBit256%, SetBit256%
  2153.  
  2154. ' newint=SetBit256%(oldint, int containing the bits we want to set, value to set them to)
  2155. Function SetBit256% (iNum1 As Integer, iBit1 As Integer, bVal1 As Integer)
  2156.     Dim sNum As String
  2157.     Dim sBit As String
  2158.     Dim sVal As String
  2159.     Dim iLoop As Integer
  2160.     Dim strResult As String
  2161.     Dim iResult As Integer
  2162.     Dim iNum As Integer: iNum = iNum1
  2163.     Dim iBit As Integer: iBit = iBit1
  2164.     Dim bVal As Integer: bVal = bVal1
  2165.  
  2166.     If iNum < 256 And iBit <= 128 Then
  2167.         sNum = GetBinary$(iNum)
  2168.         sBit = GetBinary$(iBit)
  2169.         If bVal = TRUE Then
  2170.             sVal = "1"
  2171.         Else
  2172.             sVal = "0"
  2173.         End If
  2174.         strResult = ""
  2175.         For iLoop = 1 To 8
  2176.             If Mid$(sBit, iLoop, 1) = "1" Then
  2177.                 strResult = strResult + sVal
  2178.             Else
  2179.                 strResult = strResult + Mid$(sNum, iLoop, 1)
  2180.             End If
  2181.         Next iLoop
  2182.         iResult = GetIntegerFromBinary%(strResult)
  2183.     Else
  2184.         iResult = iNum
  2185.     End If
  2186.  
  2187.     SetBit256% = iResult
  2188. End Function ' SetBit256%
  2189.  
  2190. ' /////////////////////////////////////////////////////////////////////////////
  2191. ' Split and join strings
  2192. ' https://www.qb64.org/forum/index.php?topic=1073.0
  2193. '
  2194. ' FROM luke, QB64 Developer
  2195. ' Date: February 15, 2019, 04:11:07 AM »
  2196. '
  2197. ' Given a string of words separated by spaces (or any other character),
  2198. ' splits it into an array of the words. I've no doubt many people have
  2199. ' written a version of this over the years and no doubt there's a million
  2200. ' ways to do it, but I thought I'd put mine here so we have at least one
  2201. ' version. There's also a join function that does the opposite
  2202. ' array -> single string.
  2203. '
  2204. ' Code is hopefully reasonably self explanatory with comments and a little demo.
  2205. ' Note, this is akin to Python/JavaScript split/join, PHP explode/implode.
  2206.  
  2207. 'Split in$ into pieces, chopping at every occurrence of delimiter$. Multiple consecutive occurrences
  2208. 'of delimiter$ are treated as a single instance. The chopped pieces are stored in result$().
  2209. '
  2210. 'delimiter$ must be one character long.
  2211. 'result$() must have been REDIMmed previously.
  2212.  
  2213. Sub split (in$, delimiter$, result$())
  2214.     ReDim result$(-1)
  2215.     start = 1
  2216.     Do
  2217.         While Mid$(in$, start, 1) = delimiter$
  2218.             start = start + 1
  2219.             If start > Len(in$) Then Exit Sub
  2220.         Wend
  2221.         finish = InStr(start, in$, delimiter$)
  2222.         If finish = 0 Then finish = Len(in$) + 1
  2223.         ReDim _Preserve result$(0 To UBound(result$) + 1)
  2224.         result$(UBound(result$)) = Mid$(in$, start, finish - start)
  2225.         start = finish + 1
  2226.     Loop While start <= Len(in$)
  2227. End Sub ' split
  2228.  
  2229. ' /////////////////////////////////////////////////////////////////////////////
  2230.  
  2231. Sub SplitTest
  2232.  
  2233.     Dim in$
  2234.     Dim delim$
  2235.     ReDim arrTest$(0)
  2236.     Dim iLoop%
  2237.  
  2238.     delim$ = Chr$(10)
  2239.     in$ = "this" + delim$ + "is" + delim$ + "a" + delim$ + "test"
  2240.     Print "in$ = " + Chr$(34) + in$ + Chr$(34)
  2241.     Print "delim$ = " + Chr$(34) + delimeter$ + Chr$(34)
  2242.     split in$, delim$, arrTest$()
  2243.  
  2244.     For iLoop% = LBound(arrTest$) To UBound(arrTest$)
  2245.         Print "arrTest$(" + LTrim$(RTrim$(Str$(iLoop%))) + ") = " + Chr$(34) + arrTest$(iLoop%) + Chr$(34)
  2246.     Next iLoop%
  2247.     Print
  2248.     Print "Split test finished."
  2249. End Sub ' SplitTest
  2250.  
  2251. ' /////////////////////////////////////////////////////////////////////////////
  2252.  
  2253. Sub WaitForEnter
  2254.     Dim in$
  2255.     Input "Press <ENTER> to continue", in$
  2256. End Sub ' WaitForEnter
  2257.  
  2258. ' /////////////////////////////////////////////////////////////////////////////
  2259. ' WaitForKey "Press <ESC> to continue", 27, 0
  2260. ' WaitForKey "Press <ENTER> to begin;", 13, 0
  2261. ' waitforkey "", 65, 5
  2262.  
  2263. Sub WaitForKey (prompt$, KeyCode&, DelaySeconds%)
  2264.     ' SHOW PROMPT (IF SPECIFIED)
  2265.     If Len(prompt$) > 0 Then
  2266.         If Right$(prompt$, 1) <> ";" Then
  2267.             Print prompt$
  2268.         Else
  2269.             Print Right$(prompt$, Len(prompt$) - 1);
  2270.         End If
  2271.     End If
  2272.  
  2273.     ' WAIT FOR KEY
  2274.     Do: Loop Until _KeyDown(KeyCode&) ' leave loop when specified key pressed
  2275.  
  2276.     ' PAUSE AFTER (IF SPECIFIED)
  2277.     If DelaySeconds% < 1 Then
  2278.         _KeyClear: '_DELAY 1
  2279.     Else
  2280.         _KeyClear: _Delay DelaySeconds%
  2281.     End If
  2282. End Sub ' WaitForKey
  2283.  
  2284. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2285. ' END GENERAL PURPOSE FUNCTIONS
  2286. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2287.  
  2288. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2289. ' BEGIN COLOR ROUTINES
  2290. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2291.  
  2292. ' /////////////////////////////////////////////////////////////////////////////
  2293. ' Receives:
  2294. ' cycleColor = determines how foreColor, backColor are modified
  2295. ' foreColor  = the foreground color
  2296. ' backColor  = the background color (if needed)
  2297.  
  2298. ' /////////////////////////////////////////////////////////////////////////////
  2299. ' DoCycleColor colorScheme%, myColor&
  2300.  
  2301. ' colorScheme = color scheme (value is alternated on subsequent calls)
  2302. ' myColor     = the current color (value is incremented/decremented on subsequent calls)
  2303.  
  2304. ' colorScheme values:
  2305. '  1 Rainbow6 #1
  2306. '  9 Rainbow6 #2
  2307. '  2 Rainbow18 #1
  2308. ' 10 Rainbow18 #2
  2309. '  3 Grayscale #1
  2310. ' 11 Grayscale #2
  2311. '  4 Grayscale #1
  2312. ' 12 Grayscale #2
  2313.  
  2314. Sub DoCycleColor (colorScheme As Integer, myColor As Long)
  2315.     ' ----------------------------------------------------------------------------------------------------------------------------------------------------------------
  2316.     ' CYCLE FORE COLOR
  2317.  
  2318.     ' 1, 5, 9 = simple rainbow
  2319.     If colorScheme = 1 Or colorScheme = 9 Then
  2320.         Select Case myColor
  2321.             Case cRed&:
  2322.                 myColor = cOrange&
  2323.             Case cOrange&:
  2324.                 myColor = cYellow&
  2325.             Case cYellow&:
  2326.                 myColor = cGreen&
  2327.             Case cGreen&:
  2328.                 myColor = cBlue&
  2329.             Case cBlue&:
  2330.                 myColor = cPurple&
  2331.             Case Else:
  2332.                 myColor = cRed&
  2333.         End Select
  2334.  
  2335.     ' 2, 6, 10 = complex rainbow
  2336.     ElseIf colorScheme = 2 Or colorScheme = 10 Then
  2337.         Select Case myColor
  2338.             Case cRed&:
  2339.                 myColor = cOrangeRed&
  2340.             Case cOrangeRed&:
  2341.                 myColor = cDarkOrange&
  2342.             Case cDarkOrange&:
  2343.                 myColor = cOrange&
  2344.             Case cOrange&:
  2345.                 myColor = cGold&
  2346.             Case cGold&:
  2347.                 myColor = cYellow&
  2348.             Case cYellow&:
  2349.                 myColor = cChartreuse&
  2350.             Case cChartreuse&:
  2351.                 myColor = cLime&
  2352.             Case cLime&:
  2353.                 myColor = cMediumSpringGreen&
  2354.             Case cMediumSpringGreen&:
  2355.                 myColor = cCyan&
  2356.             Case cCyan&:
  2357.                 myColor = cDeepSkyBlue&
  2358.             Case cDeepSkyBlue&:
  2359.                 myColor = cDodgerBlue&
  2360.             Case cDodgerBlue&:
  2361.                 myColor = cSeaBlue&
  2362.             Case cSeaBlue&:
  2363.                 myColor = cBlue&
  2364.             Case cBlue&:
  2365.                 myColor = cBluePurple&
  2366.             Case cBluePurple&:
  2367.                 myColor = cDeepPurple&
  2368.             Case cDeepPurple&:
  2369.                 myColor = cPurple&
  2370.             Case cPurple&:
  2371.                 myColor = cPurpleRed&
  2372.             Case Else:
  2373.                 myColor = cRed&
  2374.         End Select
  2375.  
  2376.     ' 3, 7, 11 = grayscale, ascending
  2377.     ElseIf colorScheme = 3 Or colorScheme = 11 Then
  2378.         Select Case myColor
  2379.             Case cBlack&:
  2380.                 myColor = cDarkGray&
  2381.             Case cDarkGray&:
  2382.                 myColor = cDimGray&
  2383.             Case cDimGray&:
  2384.                 myColor = cGray&
  2385.             Case cGray&:
  2386.                 myColor = cLightGray&
  2387.             Case cLightGray&:
  2388.                 myColor = cSilver&
  2389.             Case cSilver&:
  2390.                 myColor = cWhite&
  2391.             Case Else:
  2392.                 'myColor = cBlack&
  2393.                 myColor = cSilver&
  2394.  
  2395.                 ' go in the other direction!
  2396.                 If colorScheme = 3 Then
  2397.                     colorScheme = 4
  2398.                 Else
  2399.                     colorScheme = 12
  2400.                 End If
  2401.  
  2402.         End Select
  2403.  
  2404.     ' 4, 8, 12 = grayscale, descending
  2405.     ElseIf colorScheme = 4 Or colorScheme = 12 Then
  2406.         Select Case myColor
  2407.             Case cWhite&:
  2408.                 myColor = cSilver&
  2409.             Case cSilver&:
  2410.                 myColor = cLightGray&
  2411.             Case cLightGray&:
  2412.                 myColor = cGray&
  2413.             Case cGray&:
  2414.                 myColor = cDimGray&
  2415.             Case cDimGray&:
  2416.                 myColor = cDarkGray&
  2417.             Case cDarkGray&:
  2418.                 myColor = cBlack&
  2419.             Case Else:
  2420.                 myColor = cDarkGray&
  2421.  
  2422.                 ' go in the other direction!
  2423.                 If colorScheme = 4 Then
  2424.                     colorScheme = 3
  2425.                 Else
  2426.                     colorScheme = 11
  2427.                 End If
  2428.         End Select
  2429.  
  2430.     End If
  2431.        
  2432. End Sub ' DoCycleColor
  2433.  
  2434. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2435. ' END COLOR ROUTINES
  2436. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2437.  
  2438. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2439. ' BEGIN COLOR FUNCTIONS
  2440. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2441.  
  2442. ' NOTE: these are mostly negative numbers
  2443. '       and have to be forced to positive
  2444. '       when stored in the dictionary
  2445. '       (only cEmpty& should be negative)
  2446.  
  2447. Function cRed& ()
  2448.     cRed& = _RGB32(255, 0, 0)
  2449.  
  2450. Function cOrangeRed& ()
  2451.     cOrangeRed& = _RGB32(255, 69, 0)
  2452. End Function ' cOrangeRed&
  2453.  
  2454. Function cDarkOrange& ()
  2455.     cDarkOrange& = _RGB32(255, 140, 0)
  2456. End Function ' cDarkOrange&
  2457.  
  2458. Function cOrange& ()
  2459.     cOrange& = _RGB32(255, 165, 0)
  2460. End Function ' cOrange&
  2461.  
  2462. Function cGold& ()
  2463.     cGold& = _RGB32(255, 215, 0)
  2464. End Function ' cGold&
  2465.  
  2466. Function cYellow& ()
  2467.     cYellow& = _RGB32(255, 255, 0)
  2468. End Function ' cYellow&
  2469.  
  2470. Function cChartreuse& ()
  2471.     cChartreuse& = _RGB32(127, 255, 0)
  2472. End Function ' cChartreuse&
  2473.  
  2474. Function cLime& ()
  2475.     cLime& = _RGB32(0, 255, 0)
  2476. End Function ' cLime&
  2477.  
  2478. Function cMediumSpringGreen& ()
  2479.     cMediumSpringGreen& = _RGB32(0, 250, 154)
  2480. End Function ' cMediumSpringGreen&
  2481.  
  2482. Function cCyan& ()
  2483.     cCyan& = _RGB32(0, 255, 255)
  2484. End Function ' cCyan&
  2485.  
  2486. Function cDeepSkyBlue& ()
  2487.     cDeepSkyBlue& = _RGB32(0, 191, 255)
  2488. End Function ' cDeepSkyBlue&
  2489.  
  2490. Function cDodgerBlue& ()
  2491.     cDodgerBlue& = _RGB32(30, 144, 255)
  2492. End Function ' cDodgerBlue&
  2493.  
  2494. Function cSeaBlue& ()
  2495.     cSeaBlue& = _RGB32(0, 64, 255)
  2496. End Function ' cSeaBlue&
  2497.  
  2498. Function cBlue& ()
  2499.     cBlue& = _RGB32(0, 0, 255)
  2500. End Function ' cBlue&
  2501.  
  2502. Function cBluePurple& ()
  2503.     cBluePurple& = _RGB32(64, 0, 255)
  2504. End Function ' cBluePurple&
  2505.  
  2506. Function cDeepPurple& ()
  2507.     cDeepPurple& = _RGB32(96, 0, 255)
  2508. End Function ' cDeepPurple&
  2509.  
  2510. Function cPurple& ()
  2511.     cPurple& = _RGB32(128, 0, 255)
  2512. End Function ' cPurple&
  2513.  
  2514. Function cPurpleRed& ()
  2515.     cPurpleRed& = _RGB32(128, 0, 192)
  2516. End Function ' cPurpleRed&
  2517.  
  2518. Function cDarkRed& ()
  2519.     cDarkRed& = _RGB32(160, 0, 64)
  2520. End Function ' cDarkRed&
  2521.  
  2522. Function cBrickRed& ()
  2523.     cBrickRed& = _RGB32(192, 0, 32)
  2524. End Function ' cBrickRed&
  2525.  
  2526. Function cDarkGreen& ()
  2527.     cDarkGreen& = _RGB32(0, 100, 0)
  2528. End Function ' cDarkGreen&
  2529.  
  2530. Function cGreen& ()
  2531.     cGreen& = _RGB32(0, 128, 0)
  2532. End Function ' cGreen&
  2533.  
  2534. Function cOliveDrab& ()
  2535.     cOliveDrab& = _RGB32(107, 142, 35)
  2536. End Function ' cOliveDrab&
  2537.  
  2538. Function cLightPink& ()
  2539.     cLightPink& = _RGB32(255, 182, 193)
  2540. End Function ' cLightPink&
  2541.  
  2542. Function cHotPink& ()
  2543.     cHotPink& = _RGB32(255, 105, 180)
  2544. End Function ' cHotPink&
  2545.  
  2546. Function cDeepPink& ()
  2547.     cDeepPink& = _RGB32(255, 20, 147)
  2548. End Function ' cDeepPink&
  2549.  
  2550. Function cMagenta& ()
  2551.     cMagenta& = _RGB32(255, 0, 255)
  2552. End Function ' cMagenta&
  2553.  
  2554. Function cBlack& ()
  2555.     cBlack& = _RGB32(0, 0, 0)
  2556. End Function ' cBlack&
  2557.  
  2558. Function cDimGray& ()
  2559.     cDimGray& = _RGB32(105, 105, 105)
  2560. End Function ' cDimGray&
  2561.  
  2562. Function cGray& ()
  2563.     cGray& = _RGB32(128, 128, 128)
  2564. End Function ' cGray&
  2565.  
  2566. Function cDarkGray& ()
  2567.     cDarkGray& = _RGB32(169, 169, 169)
  2568. End Function ' cDarkGray&
  2569.  
  2570. Function cSilver& ()
  2571.     cSilver& = _RGB32(192, 192, 192)
  2572. End Function ' cSilver&
  2573.  
  2574. Function cLightGray& ()
  2575.     cLightGray& = _RGB32(211, 211, 211)
  2576. End Function ' cLightGray&
  2577.  
  2578. Function cGainsboro& ()
  2579.     cGainsboro& = _RGB32(220, 220, 220)
  2580. End Function ' cGainsboro&
  2581.  
  2582. Function cWhiteSmoke& ()
  2583.     cWhiteSmoke& = _RGB32(245, 245, 245)
  2584. End Function ' cWhiteSmoke&
  2585.  
  2586. Function cWhite& ()
  2587.     cWhite& = _RGB32(255, 255, 255)
  2588. End Function ' cWhite&
  2589.  
  2590. Function cDarkBrown& ()
  2591.     cDarkBrown& = _RGB32(128, 64, 0)
  2592. End Function ' cDarkBrown&
  2593.  
  2594. Function cLightBrown& ()
  2595.     cLightBrown& = _RGB32(196, 96, 0)
  2596. End Function ' cLightBrown&
  2597.  
  2598. Function cKhaki& ()
  2599.     cKhaki& = _RGB32(240, 230, 140)
  2600. End Function ' cKhaki&
  2601.  
  2602. Function cEmpty& ()
  2603.     cEmpty& = -1
  2604. End Function ' cEmpty&
  2605.  
  2606. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2607. ' END COLOR FUNCTIONS
  2608. ' ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2609.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Isometric Demo re-revisited v2.70 added variable grid size
« Reply #1 on: December 04, 2021, 12:44:17 pm »
@madscijr

You should post in Programs in one thread as a work in progress. That way if amounts to something, and it should with continued progress, librarians have a single thread to reference. MasterGy is doing good job of that with "car simulator".

I wonder if you can make a Christmas tree of cubes or even a whole xmas scene?

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Isometric Demo re-revisited v2.70 added variable grid size
« Reply #2 on: December 04, 2021, 04:43:07 pm »
@madscijr
You should post in Programs in one thread as a work in progress. That way if amounts to something, and it should with continued progress, librarians have a single thread to reference. MasterGy is doing good job of that with "car simulator".
I wonder if you can make a Christmas tree of cubes or even a whole xmas scene?

All good ideas! I'll see what I can come up with! :-D