Ejemplo n.º 1
0
        public void Draw(GraphicsDevice graphicsDevice, Camera camera)
        {
            graphicsDevice.SetVertexBuffer(m_vertexBuffer);

            m_effect.World = m_world;
            m_effect.View = camera.View;
            m_effect.Projection = camera.Projection;
            m_effect.VertexColorEnabled = true;

            // Begin effect and draw for each pass
            foreach (EffectPass pass in m_effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
                    PrimitiveType.TriangleList, m_vertices, 0, m_vertices.Length,
                    m_indices, 0, m_indices.Length / 3, VertexPositionColor.VertexDeclaration);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            map = new Grid(20, 14);

            map.Randomize();

            // Calculate shortest path
            map.Path = map.FindPath(new Point(0, 0), new Point(19, 13));

            // TODO: Do something when map.Path is null
            // Toggle path flag for cells on the path
            for (int i = 0; i < map.Path.Count; i++)
                    map.Path[i].Status |= Cell.Type.Path;

            camera = new Camera(this);
            Components.Add(camera);

            Components.Add(new Statistics(this));

            base.Initialize();
        }