Ejemplo n.º 1
0
        /// <summary>
        /// Draw ant on garden
        /// </summary>
        public void Draw()
        {
            GL.PushMatrix();

            GL.Translate(Position.X + Game.GRIDSIZE / 2, Position.Y + Game.GRIDSIZE / 2, 0);
            GL.Rotate((float)Direction, 0, 0, 1);
            GL.Translate(-(Position.X + Game.GRIDSIZE / 2), -(Position.Y + Game.GRIDSIZE / 2), 0);

            Spritebatch.DrawSprite(Game.TILESET, new RectangleF(this.Position.X, this.Position.Y, Game.GRIDSIZE, Game.GRIDSIZE), this.Color, this.sourceRec);

            GL.PopMatrix();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Manage the elements display on the window
        /// </summary>
        /// <param name="e"></param>
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            base.OnRenderFrame(e);

            GL.Clear(ClearBufferMask.ColorBufferBit);
            GL.ClearColor(Color.CornflowerBlue);

            Matrix4 world = Matrix4.CreateOrthographicOffCenter(0, this.Width, this.Height, 0, 0, 1);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref world);

            //Display the garden
            for (int x = 0; x < GARDEN.Width; x++)
            {
                for (int y = 0; y < GARDEN.Height; y++)
                {
                    RectangleF sourceRec = new RectangleF(0, 0, 0, 0);

                    switch (GARDEN[x, y].Type)
                    {
                    case BlockType.Grass:
                        sourceRec = new RectangleF(1 * TILESIZE, 1 * TILESIZE, TILESIZE, TILESIZE);
                        break;

                    case BlockType.Stone:
                        sourceRec = new RectangleF(6 * TILESIZE, 4 * TILESIZE, TILESIZE, TILESIZE);
                        break;

                    case BlockType.Dirt:
                        sourceRec = new RectangleF(6 * TILESIZE, 1 * TILESIZE, TILESIZE, TILESIZE);
                        break;

                    case BlockType.Pheromone:
                        sourceRec = new RectangleF(3 * TILESIZE, 5 * TILESIZE, TILESIZE, TILESIZE);
                        break;
                    }

                    Spritebatch.DrawSprite(TILESET, new RectangleF(x * GRIDSIZE, y * GRIDSIZE, GRIDSIZE, GRIDSIZE), Color.Transparent, sourceRec);  //Display a grid square
                }
            }

            ANT.Draw();

            this.SwapBuffers();
        }