Advertisement
Cosmo224

Untitled

Jul 4th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.00 KB | None | 0 0
  1. ' AZURE WORLDS YES
  2.  
  3. ' Globals
  4. Global Syslog:TStream
  5. Global debugLevel:Int=1
  6. Global Beta:Int
  7. Global Version:Int=1
  8. Global AzClickToInsert:Int=1
  9. Global AzCurrentColourR:Int=255 ' Current colour - R
  10. Global AzCurrentColourG:Int=255 ' Current colour - G
  11. Global AzCurrentColourB:Int=255 ' Current colour - B
  12. Global AzCurrentGridSize:Int=30 ' Current grid size
  13. Global AzCurrentInstanceId:Int=0 ' Current Instance ID
  14. Global AzCurrentUniqueId:Int=0 ' Current Unique ID - integrate?
  15. Global AzCurrentSizeX:Int=30 ' Current size - X
  16. Global AzCurrentSizeY:Int=30 ' Current size - Y
  17. Global AzCurrentStyling:Int=0 ' Current styling
  18. Global AzGlobalTimer:TTimer ' Timer for running the game
  19. Global AzInstanceList:TList
  20. Global AzInstanceIdList:TList ' hack
  21. Global AzWindow:TGadget
  22. Global AzWindowMenu:TGadget
  23. Global AzWindowCanvas:TGadget
  24. Global AzWindowFileMenu:TGadget
  25. Global AzWindowGameMenu:TGadget
  26. Global AzWindowToolsMenu:TGadget
  27. Global AzWindowHelpMenu:TGadget
  28. Global AzWindowExplorer:TGadget
  29. Global AzWindowExplorerRoot:TGadget
  30. Global AzWindowToolStrip:TGadget
  31. Global AzWindowCtiBtn:TGadget
  32. Global AzWindowDelBtn:TGadget
  33. Global AzWindowSizeBtn:TGadget
  34. Global AzWindowColourBtn:TGadget
  35. Global AzWindowEffectBtn:TGadget
  36. Global AzWindowPropBtn:TGadget
  37. Type AzureWorlds
  38.  
  39. Method Init(x=1228,y=928,d=0,h=0,introImg:String="NonInstanceTextures\avantgarde.png",displayTime:Int=6000,appTtl:String="avant-gardé eyes presents Azure Worlds",canvasSzX=1024,canvasSzY=768) ' placeholder values
  40. AppTitle = appTtl
  41. ' preparation for loading from config
  42. canvasSzX = x - x/5
  43. canvasSzY = y - y/4
  44. SeedRnd MilliSecs() ' seed the random number generator
  45. Syslog = Self.OpenLog("Engine\AvantGardeEyes.log")
  46. AzInstanceList = New TList ' New instance list
  47. AzInstanceIdList = New TList ' New Instance Id list - external display only
  48. WriteLog("Azure Worlds Initalizing...",Syslog)
  49. AzGlobalTimer = CreateTimer(60) ' initalize the timer
  50. WriteLog("Created timer...",Syslog)
  51. Graphics x,y,d,h
  52. Local introImage:TImage = LoadImage(introImg) ' load the intro image
  53. If introImage = Null ' Null = failed to load
  54. WriteLog("Failure to load: Couldn't load intro image.",Syslog)
  55. HandleError(1,"Error loading intro image",1,0)
  56. EndIf
  57.  
  58. DrawImage introImage,0,0
  59. Flip
  60. Delay displayTime
  61. EndGraphics ' end the graphics as we use MxaGUI
  62. introImage = Null ' destroy the image
  63. InitAzGui(AppTtl,x,y,canvasSzX,canvasSzY) ' initalize GUI
  64. AzToolVisibility(1,0,0,0,0,0) ' set tool visibility to 1,0,0,0,0,0 as we dont need the rest
  65. AzInitInstanceIdList(AzInstanceIdList) ' initalize the instanceid list
  66. Return True ' return true
  67. End Method
  68.  
  69. Method OpenLog:TStream(logUrl:String)
  70. Local logStr:TStream = OpenStream(logUrl) ' open the log
  71. Return logStr
  72. End Method
  73.  
  74. Method WriteLog(logText:String,logStream:TStream)
  75. If debugLevel = 1
  76. WriteLine(logStream,"[" + CurrentDate() + " " + CurrentTime() + "] " + logText)
  77. Return True
  78. EndIf
  79. End Method
  80.  
  81. Method HandleError(errorId:Int,errorText:String,errorSeverity:Int,confirmation:Int) ' error handling. returns errorResult if errorSeverity=0 and confirmation=1.
  82. WriteLog(errorText,Syslog) ' write the error to the log
  83. Select errorSeverity ' 0 = error, 1 = crash
  84. Case 0
  85. Select confirmation ' ok or ok/cancel
  86. Case 0
  87. Notify("Error: ~n~n " + errorText + "~n~n Error Code: " + errorId)
  88. Case 1
  89. Local errorResult = Confirm("Error: ~n~n " + errorText + "Continue? ~n~n Error Code: " + errorId)
  90. Return errorResult ' return the errorresult
  91. End Select
  92. Case 1
  93. RuntimeError("Critical Error: ~n~n " + errorText + "~n~n Error Code: " + errorId + " Please contact support. ")
  94. Default
  95. End Select
  96.  
  97. End Method
  98.  
  99. Method InitAzGui:Int(AppTtl:String,x,y,canvasSzX,canvasSzY) ' initalize the Az MaxGUI
  100. AzWindow=CreateWindow(AppTtl,DesktopWidth()/4,DesktopHeight()/4,x,y,Null) ' main window
  101. AzWindowCanvas = CreateCanvas(0,0,canvasSzX,canvasSzY,AzWindow) ' canvas - this holds the graphics
  102. SetGraphics CanvasGraphics(AzWindowCanvas) ' redirect the graphics context to the canvas so we can draw stuff
  103. AzWindowMenu = WindowMenu(AzWindow) ' window menu
  104. ' cut down on unnecessary variables here for most menus
  105. AzWindowFileMenu = CreateMenu("File",0,AzWindowMenu) ' File menu
  106. AzWindowGameMenu = CreateMenu("Game",100,AzWindowMenu) ' Game menu
  107. AzWindowToolsMenu = CreateMenu("Tools",200,AzWindowMenu) ' Tools menu
  108. AzWindowHelpMenu = CreateMenu("Help",300,AzWindowMenu) ' Help menu
  109. ' FILE MENU SUBMENUS
  110. CreateMenu("New Game",1,AzWindowFileMenu) ' new game submenu
  111. CreateMenu("Open Game",2,AzWindowFileMenu) ' open game submenu
  112. CreateMenu("Save Game",3,AzWindowFileMenu) ' save game submenu
  113. CreateMenu("Save Game As",4,AzWindowFileMenu) ' save game as submenu
  114. CreateMenu("Upload",5,AzWindowFileMenu) ' upload menu
  115. CreateMenu("",6,AzWindowFileMenu) ' blank dummy menu for divider
  116. CreateMenu("Exit",7,AzWindowFileMenu) ' exit menu
  117.  
  118. ' GAME MENU SUBMENUS
  119.  
  120. CreateMenu("Play",101,AzWindowGameMenu) ' player
  121. CreateMenu("Settings...",102,AzWindowGameMenu) ' Settings menu
  122.  
  123. ' TOOLS MENU SUBMENUS
  124.  
  125. If debugLevel > 1
  126. CreateMenu("Debug",201,AzWindowToolsMenu) ' Debug menu
  127. EndIf
  128. CreateMenu("Insert Object",202,AzWindowToolsMenu) ' Insert object menu
  129. CreateMenu("Colour",203,AzWindowToolsMenu) ' Colour menu
  130. CreateMenu("Size",204,AzWindowToolsMenu) ' Size menu
  131. CreateMenu("Effect",205,AzWindowToolsMenu) ' Effect menu
  132. CreateMenu("Style",206,AzWindowToolsMenu) ' Style menu
  133. CreateMenu("",207,AzWindowToolsMenu) ' Dummy menu for divider
  134. CreateMenu("Check for Updates",208,AzWindowToolsMenu) ' Check for Updates
  135.  
  136. ' HELP MENU SUBMENUS
  137.  
  138. CreateMenu("Online Help",301,AzWindowHelpMenu) ' Online help menu
  139. CreateMenu("Visit Azure Worlds",302,AzWindowHelpMenu) ' Visit Azure Worlds menu
  140. CreateMenu("",303,AzWindowHelpMenu) ' dummy
  141. CreateMenu("About",304,AzWindowHelpMenu) ' About Menu
  142.  
  143. UpdateWindowMenu AzWindow ' update the window menu
  144.  
  145. ' Explorer
  146. AzWindowExplorer = CreateTreeView(canvasSzX + 4,28,GadgetWidth(AzWindow) - canvasSzX - 12,GadgetHeight(AzWindow) - 100,AzWindow) ' Explorer - where the bricks are!
  147. AzWindowExplorerRoot = TreeViewRoot(AzWindowExplorer) ' Root handle for adding shit
  148. CreateLabel("Explorer: ",canvasSzX + 4,0,96,24,AzWindow) ' create the label
  149. AzWindowToolStrip = CreateLabel("Brick Tools: ",4,canvasSzY + 4,96,24,AzWindow) ' Tool strip label
  150.  
  151. ' TOOLSTRIP for BLOCKS
  152. AzWindowCtiBtn = CreateButton("Click-to-Insert: On",GadgetWidth(AzWindow)/8,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Click-to-Insert toggle
  153. AzWindowDelBtn = CreateButton("Delete",GadgetWidth(AzWindow)/4.499,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Delete button
  154. AzWindowSizeBtn = CreateButton("Size",GadgetWidth(AzWindow)/3.141,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Size button
  155. AzWindowColourBtn = CreateButton("Colour",GadgetWidth(AzWindow)/2.4,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Colour button
  156. AzWindowEffectBtn = CreateButton("Effects and Style",GadgetWidth(AzWindow)/1.954,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Effects and Style button
  157. AzWindowPropBtn = CreateButton("Properties",GadgetWidth(AzWindow)/1.648,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Properties button
  158. End Method
  159.  
  160. Method AzToolVisibility(one,two,three,four,five,six)
  161. If one=1 ' click to insert
  162. ShowGadget AzWindowCtiBtn
  163. Else
  164. HideGadget AzWindowCtiBtn
  165. EndIf
  166.  
  167. If two=1
  168. ShowGadget AzWindowDelBtn
  169. Else
  170. HideGadget AzWindowDelBtn
  171. EndIf
  172.  
  173. If three=1
  174. ShowGadget AzWindowSizeBtn
  175. Else
  176. HideGadget AzWindowSizeBtn
  177. EndIf
  178.  
  179. If four=1
  180. ShowGadget AzWindowColourBtn
  181. Else
  182. HideGadget AzWindowColourBtn
  183. EndIf
  184.  
  185. If five=1
  186. ShowGadget AzWindowEffectBtn
  187. Else
  188. HideGadget AzWindowEffectBtn
  189. EndIf
  190.  
  191. If six=1
  192. ShowGadget AzWindowPropBtn
  193. Else
  194. HideGadget AzWindowPropBtn
  195. EndIf
  196. End Method
  197.  
  198. Method AzInitInstanceIdList:TList(AzList:TList)
  199. WriteLog("Registering Instance IDs...",Syslog)
  200. Local Az0:String = "Block"
  201. WriteLog("Registered ID 0 " + Az0,Syslog)
  202. Local Az1:String = "CircleBlock"
  203. WriteLog("Registered ID 1 " + Az1,Syslog)
  204. AzList.AddLast(Az0)
  205. AzList.AddLast(Az1)
  206. Return AzList
  207. End Method
  208.  
  209. Method AzRegisterTreeView(instanceId,uniqueId)
  210. AddTreeViewNode instanceId + " (ID: " + uniqueId + ")",AzWindowExplorerRoot ' add the tree view node to the root of the explorer
  211. End Method
  212. End Type
  213.  
  214. Type InstanceManager Extends AzureWorlds
  215. Field posX ' X position of the brick
  216. Field posY ' Y position of the brick
  217. Field sizeX ' X size of the brick
  218. Field sizeY ' Y size of the brick
  219. Field colourR ' Colour RGB red of the brick
  220. Field colourG ' Colour RGB green of the brick
  221. Field colourB ' Colour RGB blue of the brick
  222. Field instanceId ' instance ID of the brick
  223. Field instanceIdDescription:String ' instance ID description of the brick
  224. Field uniqueId ' unique ID of the brick
  225. Field gridSize ' grid size of the brick
  226. Field styling ' styling of the brick
  227. Field fx ' BrickFX(tm)
  228. Field scoreBonus ' score given
  229. Field timeBonus ' time given
  230. Field bonusBonus ' bonus given
  231. Field winGiven ' Win given
  232. Field physEnabled ' Super-Shit" Physics Engine Enabled
  233.  
  234. Method InsertInstance:InstanceManager(instanceId,posX,posY,sizeX,sizeY,colourR,colourG,colourB,gridSize,styling)
  235. Local insMan:InstanceManager = New InstanceManager
  236. insMan.instanceId = AzCurrentInstanceId
  237. insMan.posX = RoundPos(posX,gridSize) ' round x to the grid size
  238. insMan.posY = RoundPos(posY,gridSize) ' round y to the grid size
  239. insMan.sizeX = sizeX
  240. insMan.sizeY = sizeY
  241. insMan.colourR = colourR
  242. insMan.colourG = colourG
  243. insMan.colourB = colourB
  244. insMan.gridSize = gridSize
  245. insMan.styling = styling
  246. AzCurrentUniqueId = AzCurrentUniqueId + 1
  247. insMan.uniqueId = AzCurrentUniqueId
  248. insMan.instanceIdDescription = insMan.DetermineInstanceParameters(instanceId) ' description of the InstanceID
  249. AzInstanceList.AddLast(insMan) ' add this to the list of instances
  250. AzRegisterTreeView(insMan.instanceId,insMan.uniqueId)
  251. Return insMan ' return insMan
  252.  
  253. End Method
  254.  
  255. Method DetermineInstanceParameters:String(instanceId:String) ' this determines the parameters of a brick by their Instance IDs
  256. Select instanceId
  257. Case 0
  258. instanceIdDescription = "Brick"
  259. Case 1
  260. instanceIdDescription = "CircleBrick"
  261. Default
  262. instanceIdDescription = "Fatal"
  263. End Select
  264. Return instanceIdDescription
  265. End Method
  266.  
  267. Method RoundPos(x#,m#)
  268. If m < 0.0
  269. m = -m
  270. EndIf
  271. ' Fake Sgn as for some reason BMX-NG 0.99+ doesn't support it
  272. Local s#
  273. If x < 0.0 s=-1
  274. If x = 0 s=0
  275. If x > 0.0 s=1
  276. If x < 0.0
  277. x = -x
  278. EndIf
  279. Local diff# = x Mod m ' modulus the x
  280. If diff < .5 * m
  281. Return (x-diff)*s
  282. Else
  283. Return (m+x-diff)*s
  284. EndIf
  285. End Method
  286.  
  287. End Type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement