Esempio n. 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()
        {
            string level1 = File.ReadAllText("../../../../../PacMan/levelsPen.csv");

            this.gameState    = GameState.Parse(level1);
            this.mazeSprite   = new MazeSprite(this);
            this.ghostSprite  = new GhostSprite(this);
            this.pacmanSprite = new PacManSprite(this);
            this.scoreSprite  = new ScoreSprite(this);
            Components.Add(mazeSprite);
            Components.Add(ghostSprite);
            Components.Add(pacmanSprite);
            Components.Add(scoreSprite);
            base.Initialize();

            //events
            this.PacManGame.Maze.PacmanWon += Maze_PacmanWon;
            this.PacManGame.Score.GameOver += Score_GameOver;
        }
Esempio 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()
        {
            //Adding all the components needed for the game to work properly
            mazeSprite   = new MazeSprite(this, gs.Maze);
            pacmanSprite = new PacmanSprite(this, gs);
            ghostSprite  = new GhostSprite(this, gs);
            scoreSprite  = new ScoreSprite(this, gs);
            Components.Add(mazeSprite);
            Components.Add(ghostSprite);
            Components.Add(pacmanSprite);
            Components.Add(scoreSprite);

            //window size
            graphics.PreferredBackBufferHeight = 736;
            graphics.PreferredBackBufferWidth  = 1000;
            graphics.ApplyChanges();

            base.Initialize();
        }