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()
        {
            // TODO: Add your initialization logic here
            _renderHelper = new RenderHelper();
            _renderHelper.Init(GraphicsDevice);
            _renderHelper.ActiveCamera.SetWorldConstrains(Vector2.Zero);

            _boxes      = BoxLoader.LoadFromFile("Content/test_world.boxes");
            _background = new BackgroundImage();
            _background.Init(_renderHelper, _screenSize);

            _world = WorldLoader.Load("Content/level3.map", Content);
            _world.Init(_renderHelper, _screenSize);

            _renderHelper.ActiveCamera.WorldBotRight = new Vector2()
            {
                X = _world.Cols * _world.TileSize.X + 1,
                Y = _world.Rows * _world.TileSize.Y + 1
            };

            _boxes = WorldLoader.GenerateHitboxes(_world);

            var player1 = new Player(PlayerIndex.One);
            var player2 = new Player(PlayerIndex.Two);

            //var player3 = new Player(PlayerIndex.Three);
            _players.Add(player1);
            _players.Add(player2);
            //_players.Add(player3);

            _fonter = new Fonter();
            _fonter.Init(_renderHelper, _screenSize);
            _fonter.Messages.Add(new Message(() => player1.PhysicsComponent.Position, () => "P1:\n" + player1.PhysicsComponent.Position));
            _fonter.Messages.Add(new Message(() => player2.PhysicsComponent.Position, () => "P2:\n" + player2.PhysicsComponent.Position));
            base.Initialize();
        }