Beispiel #1
0
        public static void run()
        {
            GeoGrid grid = new GeoGrid(10);

            GameWindow    window  = new GameWindow(WIDTH, HEIGHT);
            GeoDisplayIco hexGrid = new GeoDisplayIco(window, grid);

            window.Run();
        }
Beispiel #2
0
        public GeoDisplayIco(GameWindow window, GeoGrid grid)
        {
            this.window = window;
            this.grid   = grid;

            window.Load        += Window_Load;
            window.UpdateFrame += Window_UpdateFrame;
            window.RenderFrame += Window_RenderFrame;
            window.Closing     += Window_Closing;
        }
        public void LoadGrid(GeoGrid g)
        {
            int edgeLen = (int)Math.Pow(2, numSubs);
            //Number of hexagons on an even face
            int even = Triangular(edgeLen) - 1;
            //Number of hexagons on an odd face
            int odd    = Triangular(edgeLen - 1);
            int hexDex = 0;

            //This loop assigns the display hexagons to an index in the data representation
            //While there's five parallelograms, I end up doing the same thing twice in each one, so I did some simple integer division trickery.
            //Hopefully it doesn't f**k me in the butt down the road.

            //I'm down the road and pretty sure I'm being f****d in the butt

            System.Console.WriteLine("HexLen: " + hexList.Length);
            System.Console.WriteLine("Even: " + even);
            System.Console.WriteLine("Odd: " + odd);
            for (int par = 0; par < 10; par++)
            {
                int start = (par % 2) * edgeLen;
                for (int col = 1; col < edgeLen; col++)
                {
                    for (int row = 0; row <= edgeLen - col; row++)
                    {
                        hexList[hexDex++].tile = g.getTile(par / 2, row, col + start);
                        //hexDex++;
                    }
                }
                for (int row = edgeLen - 1; row > 0; row--)
                {
                    int iter = 0;
                    for (int col = edgeLen; col > row; col--)
                    {
                        hexList[hexDex++].tile = g.getTile(par / 2, row + iter, col + start);
                        iter++;
                    }
                }
            }
        }