public void ReadMap(Texture2D map) { Color value; for (int x = 0; x < map.Width; x++) { for (int y = 0; y < map.Height; y++) { value = ReadPixel(x, y, map); if (value == new Color(255, 0, 255)) { Texture2D textureCharacter = Content.Load<Texture2D>("characteratlas"); player = new Player(textureCharacter, new Vector2(x * 20, y * 20)); } if (value == new Color(0, 0, 0)) { Texture2D textureWall = Content.Load<Texture2D>("wall"); listWalls.Add(new Wall(textureWall, new Vector2(x * 20, y * 20))); } } } }
//LOAD CONTENT protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. Texture2D textureEnemy = Content.Load<Texture2D>("simpleenemy"); Texture2D textureObjective = Content.Load<Texture2D>("obj"); Texture2D textureWall = Content.Load<Texture2D>("wall"); Texture2D textureCharacter = Content.Load<Texture2D>("characteratlas"); spriteBatch = new SpriteBatch(GraphicsDevice); player = new Player(textureCharacter, new Vector2(1, 1)); map1 = Content.Load<Texture2D>("map1"); ReadMap(map1); //player = new Player(textureCharacter, new Vector2(1, 700)); /* Random random = new Random(); int randomX; int randomY; for(int i = 0 ; i < 10 ; i++) { randomX = random.Next(150, 800); randomY = random.Next(150, 800); listEnemies.Add(new SimpleEnemy(textureEnemy, new Vector2(randomX, randomY))); }*/ font = Content.Load<SpriteFont>("SpriteFont1"); /* for(int i = 0 ; i < 100 ; i++) { randomX = random.Next(1, 800); randomY = random.Next(1, 800); listObjectives.Add(new Objectives(textureObjective, new Vector2(randomX, randomY))); } for (int i = 0; i < 100; i++) { randomX = random.Next(1, 800); randomY = random.Next(1, 800); listWalls.Add(new Wall(textureWall, new Vector2(randomX, randomY))); }*/ }