Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' AZURE WORLDS YES
- ' Globals
- Global Syslog:TStream
- Global debugLevel:Int=1
- Global Beta:Int
- Global Version:Int=1
- Global AzClickToInsert:Int=1
- Global AzCurrentColourR:Int=255 ' Current colour - R
- Global AzCurrentColourG:Int=255 ' Current colour - G
- Global AzCurrentColourB:Int=255 ' Current colour - B
- Global AzCurrentGridSize:Int=30 ' Current grid size
- Global AzCurrentInstanceId:Int=0 ' Current Instance ID
- Global AzCurrentUniqueId:Int=0 ' Current Unique ID - integrate?
- Global AzCurrentSizeX:Int=30 ' Current size - X
- Global AzCurrentSizeY:Int=30 ' Current size - Y
- Global AzCurrentStyling:Int=0 ' Current styling
- Global AzGlobalTimer:TTimer ' Timer for running the game
- Global AzInstanceList:TList
- Global AzInstanceIdList:TList ' hack
- Global AzWindow:TGadget
- Global AzWindowMenu:TGadget
- Global AzWindowCanvas:TGadget
- Global AzWindowFileMenu:TGadget
- Global AzWindowGameMenu:TGadget
- Global AzWindowToolsMenu:TGadget
- Global AzWindowHelpMenu:TGadget
- Global AzWindowExplorer:TGadget
- Global AzWindowExplorerRoot:TGadget
- Global AzWindowToolStrip:TGadget
- Global AzWindowCtiBtn:TGadget
- Global AzWindowDelBtn:TGadget
- Global AzWindowSizeBtn:TGadget
- Global AzWindowColourBtn:TGadget
- Global AzWindowEffectBtn:TGadget
- Global AzWindowPropBtn:TGadget
- Type AzureWorlds
- 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
- AppTitle = appTtl
- ' preparation for loading from config
- canvasSzX = x - x/5
- canvasSzY = y - y/4
- SeedRnd MilliSecs() ' seed the random number generator
- Syslog = Self.OpenLog("Engine\AvantGardeEyes.log")
- AzInstanceList = New TList ' New instance list
- AzInstanceIdList = New TList ' New Instance Id list - external display only
- WriteLog("Azure Worlds Initalizing...",Syslog)
- AzGlobalTimer = CreateTimer(60) ' initalize the timer
- WriteLog("Created timer...",Syslog)
- Graphics x,y,d,h
- Local introImage:TImage = LoadImage(introImg) ' load the intro image
- If introImage = Null ' Null = failed to load
- WriteLog("Failure to load: Couldn't load intro image.",Syslog)
- HandleError(1,"Error loading intro image",1,0)
- EndIf
- DrawImage introImage,0,0
- Flip
- Delay displayTime
- EndGraphics ' end the graphics as we use MxaGUI
- introImage = Null ' destroy the image
- InitAzGui(AppTtl,x,y,canvasSzX,canvasSzY) ' initalize GUI
- AzToolVisibility(1,0,0,0,0,0) ' set tool visibility to 1,0,0,0,0,0 as we dont need the rest
- AzInitInstanceIdList(AzInstanceIdList) ' initalize the instanceid list
- Return True ' return true
- End Method
- Method OpenLog:TStream(logUrl:String)
- Local logStr:TStream = OpenStream(logUrl) ' open the log
- Return logStr
- End Method
- Method WriteLog(logText:String,logStream:TStream)
- If debugLevel = 1
- WriteLine(logStream,"[" + CurrentDate() + " " + CurrentTime() + "] " + logText)
- Return True
- EndIf
- End Method
- Method HandleError(errorId:Int,errorText:String,errorSeverity:Int,confirmation:Int) ' error handling. returns errorResult if errorSeverity=0 and confirmation=1.
- WriteLog(errorText,Syslog) ' write the error to the log
- Select errorSeverity ' 0 = error, 1 = crash
- Case 0
- Select confirmation ' ok or ok/cancel
- Case 0
- Notify("Error: ~n~n " + errorText + "~n~n Error Code: " + errorId)
- Case 1
- Local errorResult = Confirm("Error: ~n~n " + errorText + "Continue? ~n~n Error Code: " + errorId)
- Return errorResult ' return the errorresult
- End Select
- Case 1
- RuntimeError("Critical Error: ~n~n " + errorText + "~n~n Error Code: " + errorId + " Please contact support. ")
- Default
- End Select
- End Method
- Method InitAzGui:Int(AppTtl:String,x,y,canvasSzX,canvasSzY) ' initalize the Az MaxGUI
- AzWindow=CreateWindow(AppTtl,DesktopWidth()/4,DesktopHeight()/4,x,y,Null) ' main window
- AzWindowCanvas = CreateCanvas(0,0,canvasSzX,canvasSzY,AzWindow) ' canvas - this holds the graphics
- SetGraphics CanvasGraphics(AzWindowCanvas) ' redirect the graphics context to the canvas so we can draw stuff
- AzWindowMenu = WindowMenu(AzWindow) ' window menu
- ' cut down on unnecessary variables here for most menus
- AzWindowFileMenu = CreateMenu("File",0,AzWindowMenu) ' File menu
- AzWindowGameMenu = CreateMenu("Game",100,AzWindowMenu) ' Game menu
- AzWindowToolsMenu = CreateMenu("Tools",200,AzWindowMenu) ' Tools menu
- AzWindowHelpMenu = CreateMenu("Help",300,AzWindowMenu) ' Help menu
- ' FILE MENU SUBMENUS
- CreateMenu("New Game",1,AzWindowFileMenu) ' new game submenu
- CreateMenu("Open Game",2,AzWindowFileMenu) ' open game submenu
- CreateMenu("Save Game",3,AzWindowFileMenu) ' save game submenu
- CreateMenu("Save Game As",4,AzWindowFileMenu) ' save game as submenu
- CreateMenu("Upload",5,AzWindowFileMenu) ' upload menu
- CreateMenu("",6,AzWindowFileMenu) ' blank dummy menu for divider
- CreateMenu("Exit",7,AzWindowFileMenu) ' exit menu
- ' GAME MENU SUBMENUS
- CreateMenu("Play",101,AzWindowGameMenu) ' player
- CreateMenu("Settings...",102,AzWindowGameMenu) ' Settings menu
- ' TOOLS MENU SUBMENUS
- If debugLevel > 1
- CreateMenu("Debug",201,AzWindowToolsMenu) ' Debug menu
- EndIf
- CreateMenu("Insert Object",202,AzWindowToolsMenu) ' Insert object menu
- CreateMenu("Colour",203,AzWindowToolsMenu) ' Colour menu
- CreateMenu("Size",204,AzWindowToolsMenu) ' Size menu
- CreateMenu("Effect",205,AzWindowToolsMenu) ' Effect menu
- CreateMenu("Style",206,AzWindowToolsMenu) ' Style menu
- CreateMenu("",207,AzWindowToolsMenu) ' Dummy menu for divider
- CreateMenu("Check for Updates",208,AzWindowToolsMenu) ' Check for Updates
- ' HELP MENU SUBMENUS
- CreateMenu("Online Help",301,AzWindowHelpMenu) ' Online help menu
- CreateMenu("Visit Azure Worlds",302,AzWindowHelpMenu) ' Visit Azure Worlds menu
- CreateMenu("",303,AzWindowHelpMenu) ' dummy
- CreateMenu("About",304,AzWindowHelpMenu) ' About Menu
- UpdateWindowMenu AzWindow ' update the window menu
- ' Explorer
- AzWindowExplorer = CreateTreeView(canvasSzX + 4,28,GadgetWidth(AzWindow) - canvasSzX - 12,GadgetHeight(AzWindow) - 100,AzWindow) ' Explorer - where the bricks are!
- AzWindowExplorerRoot = TreeViewRoot(AzWindowExplorer) ' Root handle for adding shit
- CreateLabel("Explorer: ",canvasSzX + 4,0,96,24,AzWindow) ' create the label
- AzWindowToolStrip = CreateLabel("Brick Tools: ",4,canvasSzY + 4,96,24,AzWindow) ' Tool strip label
- ' TOOLSTRIP for BLOCKS
- AzWindowCtiBtn = CreateButton("Click-to-Insert: On",GadgetWidth(AzWindow)/8,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Click-to-Insert toggle
- AzWindowDelBtn = CreateButton("Delete",GadgetWidth(AzWindow)/4.499,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Delete button
- AzWindowSizeBtn = CreateButton("Size",GadgetWidth(AzWindow)/3.141,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Size button
- AzWindowColourBtn = CreateButton("Colour",GadgetWidth(AzWindow)/2.4,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Colour button
- AzWindowEffectBtn = CreateButton("Effects and Style",GadgetWidth(AzWindow)/1.954,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Effects and Style button
- AzWindowPropBtn = CreateButton("Properties",GadgetWidth(AzWindow)/1.648,GadgetHeight(AzWindow) - GadgetHeight(AzWindow)/4.65,96,32,AzWindow) ' Properties button
- End Method
- Method AzToolVisibility(one,two,three,four,five,six)
- If one=1 ' click to insert
- ShowGadget AzWindowCtiBtn
- Else
- HideGadget AzWindowCtiBtn
- EndIf
- If two=1
- ShowGadget AzWindowDelBtn
- Else
- HideGadget AzWindowDelBtn
- EndIf
- If three=1
- ShowGadget AzWindowSizeBtn
- Else
- HideGadget AzWindowSizeBtn
- EndIf
- If four=1
- ShowGadget AzWindowColourBtn
- Else
- HideGadget AzWindowColourBtn
- EndIf
- If five=1
- ShowGadget AzWindowEffectBtn
- Else
- HideGadget AzWindowEffectBtn
- EndIf
- If six=1
- ShowGadget AzWindowPropBtn
- Else
- HideGadget AzWindowPropBtn
- EndIf
- End Method
- Method AzInitInstanceIdList:TList(AzList:TList)
- WriteLog("Registering Instance IDs...",Syslog)
- Local Az0:String = "Block"
- WriteLog("Registered ID 0 " + Az0,Syslog)
- Local Az1:String = "CircleBlock"
- WriteLog("Registered ID 1 " + Az1,Syslog)
- AzList.AddLast(Az0)
- AzList.AddLast(Az1)
- Return AzList
- End Method
- Method AzRegisterTreeView(instanceId,uniqueId)
- AddTreeViewNode instanceId + " (ID: " + uniqueId + ")",AzWindowExplorerRoot ' add the tree view node to the root of the explorer
- End Method
- End Type
- Type InstanceManager Extends AzureWorlds
- Field posX ' X position of the brick
- Field posY ' Y position of the brick
- Field sizeX ' X size of the brick
- Field sizeY ' Y size of the brick
- Field colourR ' Colour RGB red of the brick
- Field colourG ' Colour RGB green of the brick
- Field colourB ' Colour RGB blue of the brick
- Field instanceId ' instance ID of the brick
- Field instanceIdDescription:String ' instance ID description of the brick
- Field uniqueId ' unique ID of the brick
- Field gridSize ' grid size of the brick
- Field styling ' styling of the brick
- Field fx ' BrickFX(tm)
- Field scoreBonus ' score given
- Field timeBonus ' time given
- Field bonusBonus ' bonus given
- Field winGiven ' Win given
- Field physEnabled ' Super-Shit" Physics Engine Enabled
- Method InsertInstance:InstanceManager(instanceId,posX,posY,sizeX,sizeY,colourR,colourG,colourB,gridSize,styling)
- Local insMan:InstanceManager = New InstanceManager
- insMan.instanceId = AzCurrentInstanceId
- insMan.posX = RoundPos(posX,gridSize) ' round x to the grid size
- insMan.posY = RoundPos(posY,gridSize) ' round y to the grid size
- insMan.sizeX = sizeX
- insMan.sizeY = sizeY
- insMan.colourR = colourR
- insMan.colourG = colourG
- insMan.colourB = colourB
- insMan.gridSize = gridSize
- insMan.styling = styling
- AzCurrentUniqueId = AzCurrentUniqueId + 1
- insMan.uniqueId = AzCurrentUniqueId
- insMan.instanceIdDescription = insMan.DetermineInstanceParameters(instanceId) ' description of the InstanceID
- AzInstanceList.AddLast(insMan) ' add this to the list of instances
- AzRegisterTreeView(insMan.instanceId,insMan.uniqueId)
- Return insMan ' return insMan
- End Method
- Method DetermineInstanceParameters:String(instanceId:String) ' this determines the parameters of a brick by their Instance IDs
- Select instanceId
- Case 0
- instanceIdDescription = "Brick"
- Case 1
- instanceIdDescription = "CircleBrick"
- Default
- instanceIdDescription = "Fatal"
- End Select
- Return instanceIdDescription
- End Method
- Method RoundPos(x#,m#)
- If m < 0.0
- m = -m
- EndIf
- ' Fake Sgn as for some reason BMX-NG 0.99+ doesn't support it
- Local s#
- If x < 0.0 s=-1
- If x = 0 s=0
- If x > 0.0 s=1
- If x < 0.0
- x = -x
- EndIf
- Local diff# = x Mod m ' modulus the x
- If diff < .5 * m
- Return (x-diff)*s
- Else
- Return (m+x-diff)*s
- EndIf
- End Method
- End Type
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement