Exemple #1
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
            string level = File.ReadAllText("levels.csv");

            game = GameState.Parse(level);

            mazeSprite = new MazeSprite(this, game);
            mazeSprite.Initialize();
            Components.Add(mazeSprite);

            ghostsSprite = new GhostsSprite(this, game);
            ghostsSprite.Initialize();
            Components.Add(ghostsSprite);

            pmanSprite = new PacmanSprite(this, game);
            pmanSprite.Initialize();
            Components.Add(pmanSprite);

            scoreSprite = new ScoreSprite(this, game);
            scoreSprite.Initialize();
            Components.Add(scoreSprite);

            graphics.PreferredBackBufferHeight = 850;
            graphics.PreferredBackBufferWidth  = 750;
            graphics.ApplyChanges();
            this.Window.Position = new Point(graphics.GraphicsDevice.Viewport.Width / 2, 0);

            base.Initialize();
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform the initialization it needs for every level 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 void InitializeNextLevel()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            wall   = new MazeSprite(this);
            pacman = new PacmanSprite(this);
            ghosts = new GhostsSprite(this);

            Components.Add(wall);
            Components.Add(pacman);
            Components.Add(ghosts);
            base.Initialize();
        }
Exemple #3
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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            wall   = new MazeSprite(this);
            pacman = new PacmanSprite(this);
            ghosts = new GhostsSprite(this);
            score  = new ScoreSprite(this);

            //add sprites to components
            Components.Add(wall);
            Components.Add(pacman);
            Components.Add(ghosts);
            Components.Add(score);

            base.Initialize();
        }