Imports AgkSharp

Module MainModule

    Sub Main()

        ' ---
        ' README NOTES
        ' ............
        '
        ' I...
        ' The code in this project is VB.NET or Microsoft's current form of Visual Basic
        '
        ' II..
        ' Variable declarations use a prefix with primitive form of Hungarian notation.  
        '    Examples...
        '      li = local integer
        '      ci = class level integer 
        '      mi = module level integer
        '
        '    Prefixes use the first character to denote the scope of the variable
        '      l = local
        '      c = class
        '      m = module
        '      g = global
        '      p = parameter
        '
        '    The second character or characters represent the variable type
        '      i   = integer
        '      l   = long
        '      dbl = double
        '      dec = decimal
        '      s   = string
        '      o   = object
        '
        '    You do not need to follow this paradigm but it is how I have code porofessionally for several decades.
        '
        ' III.
        ' This project currently contains two classes, "Window.vb" and "Core.vb", which are located in the "Classes" sub-directory.
        '
        ' The "Window.vb" class currently has 2 methods; "Initialze_Window" and "Create_WindowForm".  You may ignore the "Initialze_Window" method
        ' as it is not currently used.
        '
        ' The class method can be moved into an AGK Editor project's primary source file or it may be implemented in an "include" file.
        '
        ' The "Core.vb" class is a reduced version of the class that is provided the AGKSharp toolset project templates.  The version of
        ' this class has only has two methods that are used to control the game-loop in the code below; "LoopAGK" amd "Cleanup".
        '
        ' The boolean function in the "LoopAGK" method is used to inform the application if the user has selected any input options that
        ' would inhibit the game-loop.  Since no such input exists in this version ofthe code, the method is simply used to ensure that the
        ' "Core.LoopAGK()" always returns "True".  However, any corresponding technique may be used to maintain the activity of the game-loop.
        ' Core.LoopAGK() was just used simply out of convenience.
        '
        ' IV.
        ' The image used in this project is an initial hexagonal map created with the "Tiled" freely available software, which supports
        ' the creation of hexagonal maps.  The trick with using "Tiled" to accomplish this is know the length of the hexagonal side for the
        ' images you plan to use to create such a map.
        '
        ' The hexagonal images that are used in the map-board image have a size of 72x72 pixels
        '
        ' V...
        ' This project has been created using the AGKSharp Toolset and Visual Studio 2019.  If you are interested in using Visual Studio 2019,
        ' the author of the AGKSharp toolset has not provided project templates for VS 2019 projects in the current downloaded files.  To create
        ' a VS 2019 project template similar to this project using VB.NET, open up the "Agk-VB-Template" project in VS 2019.  Then follow the instructions
        ' in the page at the following link...  https://docs.microsoft.com/en-us/visualstudio/ide/how-to-update-existing-templates?view=vs-2019
        ' ---


        ' ---
        ' Variable Declarations
        ' ---
        Dim liX          As Integer = 0
        Dim liY          As Integer = 0
        Dim liDirection  As Integer = 0

        'Dim loCore       As New Core()
        Dim loWindow     As New Window()
        Dim loForm       As New Windows.Forms.Form()


        ' ---
        ' Create the initial window\form for the game
        ' ---
        loForm = loWindow.Create_WindowForm(1000, 1000, "My Test WIndow")

        ' Test the newly created handle for the form object to ensure that it has been created
        '   * This code will probably not be required for AGK Editor users
        If loForm.Handle <> vbNull Then
            Agk.InitGL(loForm.Handle)
        End If

        ' ---
        ' Set the parameters for the display, which are internally related to the newly created
        ' window\form from the code above
        ' ---
        Agk.SetVirtualResolution(1200, 1200)
        Agk.CreateSprite(1, AgkSharp.Agk.LoadImage("Images/HexagonEngineMap.png"))
        Agk.SetSpriteSize(1, 2256, 7236)
        Agk.SetSpritePosition(1, 0, 0)
        Agk.SetScissor(0, 0, 0, 0)


        ' ---
        ' Master Game Loop Code
        ' ...
        ' Automatically scroll the image in the display area.  This scrolling will primarily move the 
        ' image from the top left corner towards the bottom right corner.
        ' 
        ' ---
        While Core.LoopAGK() = True
            Try
                ' scroll the screen
                Agk.SetViewOffset (liX, liY)

                ' move down and to the right
                If (liDirection = 0)
                    liX = liX + 1
                    liY = liY + 2

                    If (liY > 740)
                        liDirection = 1
                    End If
                End If

                ' move up and to the left
                If (liDirection = 1)
                    liX = liX - 1
                    liY = liY - 2

                    If (liY < 0)
                        liDirection = 0
                    End If
                End If

                ' update the screen
                Agk.Sync()
            Catch loException As Exception
                ' do nothing
            End Try
        End While

        Core.CleanUp()
    End Sub

End Module
