Beispiel #1
0
        /// <summary>
        /// Adds walls to the screen as the player turns
        /// </summary>
        /// <param name="direction"></param>
        private void AddWall(Directions direction)
        {
            Wall oldWall = currentWall;

            // Adds the current wall to the list of all previous walls and creates a new wall
            walls.Add(currentWall);
            currentWall = new Wall();

            switch (direction)
            {
                case Directions.Up:
                    currentWall.Initialize((int)player.Position.X - 10, (int)player.Position.Y - 7, wallTexture);
                    oldWall.Turn((int)player.Position.X);
                    break;
                case Directions.Down:
                    currentWall.Initialize((int)player.Position.X - 10, (int)player.Position.Y - 10, wallTexture);
                    oldWall.Turn((int)player.Position.X);
                    break;
                case Directions.Left:
                    currentWall.Initialize((int)player.Position.X + 10, (int)player.Position.Y - 7, wallTexture);
                    oldWall.Turn((int)player.Position.Y);
                    break;
                case Directions.Right:
                    currentWall.Initialize((int)player.Position.X - 10, (int)player.Position.Y - 7, wallTexture);
                    oldWall.Turn((int)player.Position.Y);
                    break;
            }
        }
Beispiel #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

            settings = new Constants();

            // Initialize player
            playerTextures = new List<Texture2D>();
            player = new Player();

            // Initialize walls
            walls = new List<Wall>();
            currentWall = new Wall();

            // Initialize collision detection
            collisions = new Collision();

            base.Initialize();
        }