예제 #1
0
        public override void InitializeContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new SpriteBatch(GraphicsDevice);

            var tileMapTexture   = Content.Load <Texture2D>("Sprites/candy_sheet");
            var collisionTexture = Content.Load <Texture2D>("Sprites/collisions");

            _coinTexture = Content.Load <Texture2D>("Sprites/coinGold");

            _font = Content.Load <SpriteFont>("Font/Arial");

            LoadHudTextures();

            Map.TileMapData tileMapData = new Map.TileMapData()
            {
                MapHeight  = 15,
                MapWidth   = 15,
                Texture    = tileMapTexture,
                TileHeight = 70,
                TileWidth  = 70,
                TileMap    = map
            };

            for (int y = 0; y < 15; y++)
            {
                for (int x = 0; x < 15; x++)
                {
                    if (x == 0 || x == 14 || y == 0)
                    {
                        collisionMap[y, x] = 1;
                    }
                    if (map[y, x] != -1)
                    {
                        collisionMap[y, x] = 1;
                    }
                }
            }

            Map.TileMapData collisionMapData = new Map.TileMapData()
            {
                MapHeight  = 15,
                MapWidth   = 15,
                Texture    = collisionTexture,
                TileHeight = 70,
                TileWidth  = 70,
                TileMap    = collisionMap
            };



            _camera = new Camera.Camera();
            _camera.ViewportWidth  = GraphicsDevice.Viewport.Width;
            _camera.ViewportHeight = GraphicsDevice.Viewport.Height;

            _myMap = new Map.Map(_camera);
            _myMap.AddLayer(new Map.TileMap(tileMapData));
            _myMap.SetCollisionMap(new Map.CollisionMap(collisionMapData));



            _player = new Player.Player(new Vector2(500, 10));
            _player.Initialize(Content);
            Reset();
        }