Ejemplo 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()
        {
            // +2 to compensate for tiles off screen
            squaresAcross = GraphicsDevice.Viewport.Width / 64 + 2;
            squaresDown = GraphicsDevice.Viewport.Height / 64 + 2;

            SpriteFont font = Content.Load<SpriteFont>("SpriteFont1");

            Texture2D torchTexture = Content.Load<Texture2D> ("torch");
            Texture2D gameOverTexture = Content.Load<Texture2D>("GameOver");
            Texture2D hudTexture = Content.Load<Texture2D>("hud");
            hud = new hud(this);
            hud.initialize(hudTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, GraphicsDevice.Viewport.Width - 50, GraphicsDevice.Viewport.Height - 50,font);
            gameOver = new GameOverScreen(this);
            gameOver.initialize(gameOverTexture, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            gameState = GameState.Game;

            //Load guards
            loadGuards();

            Vector2 start = new Vector2(GraphicsDevice.Viewport.Width/2, GraphicsDevice.Viewport.Height/2);
            Texture2D texture = Content.Load<Texture2D>("sprite");
            player = new Player(this);
            player.initialize(start, 0, texture, 10, 10, "Player", myMap);
            testObject = new torch(this);
            testObject.initialize(myMap, 1, 1, 0, 0, torchTexture, "torch");
            base.Initialize ();
        }