private void CreateEnemies() { enemiesCount++; Random random = new Random(); Texture2D tmpSprite = this.Content.Load <Texture2D>("Sprites/mine"); for (int i = 0; i < enemiesCount; i++) { int rndX = random.Next(0, Window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, Window.ClientBounds.Height / 2); Mine temp = new Mine(tmpSprite, rndX, -rndY); enemies.Add(temp); } //Tripoder tmpSprite = this.Content.Load <Texture2D>("Sprites/tripod"); for (int i = 0; i < enemiesCount; i++) { int rndX = random.Next(0, Window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, Window.ClientBounds.Height / 2); Tripod temp = new Tripod(tmpSprite, rndX, -rndY); enemies.Add(temp); } }
private static void Reset(GameWindow window, ContentManager content) { player.Reset(380, 400, 4f, 6f); enemies.Clear(); Random random = new Random(); Texture2D tmpSprite = content.Load <Texture2D>("LaxMineEnemy"); for (int i = 0; i < 5; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Mine temp = new Mine(tmpSprite, rndX, rndY); enemies.Add(temp); } tmpSprite = content.Load <Texture2D>("laxtripod"); for (int i = 0; i < 5; i++) { int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Tripod temp = new Tripod(tmpSprite, rndX, rndY); enemies.Add(temp); } }
protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here //Spelaren player = new Player(Content.Load <Texture2D>("ship"), 380, 400, 2.5f, 4.5f, Content.Load <Texture2D>("bullet")); goldCoinSprite = Content.Load <Texture2D>("coin"); //Skapa fiender enemies = new List <Enemy>(); Random random = new Random(); Texture2D tmpSprite = Content.Load <Texture2D>("mine"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, Window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, Window.ClientBounds.Height / 2); Enemy temp = new Mine(tmpSprite, rndX, rndY); enemies.Add(temp); } tmpSprite = Content.Load <Texture2D>("tripod"); for (int i = 0; i < 10; i++) { int rndX = random.Next(0, Window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, Window.ClientBounds.Height / 2); Enemy temp = new Tripod(tmpSprite, rndX, rndY); enemies.Add(temp); } //För utskrift printText = new PrintText(Content.Load <SpriteFont>("myFont")); }
public static void LoadContent(ContentManager content, GameWindow window) { background = new Background(content.Load <Texture2D>("sprites/background"), window); menu = new Menu((int)State.Menu); //menu.AddItem(content.Load<Texture2D>("menu/start"),(int)State.Run); //menu.AddItem(content.Load<Texture2D>("menu/highscore"), (int)State.Highscore); //menu.AddItem(content.Load<Texture2D>("menu/exit"), (int)State.Quit); menuSprite = content.Load <Texture2D>("zamypic"); menuPos.X = window.ClientBounds.Width / 2 - menuSprite.Width / 2; menuPos.Y = window.ClientBounds.Height / 2 - menuSprite.Height / 2; player = new Player(content.Load <Texture2D>("hamburger"), 380, 400, 4.5f, 6.5f, content.Load <Texture2D>("Laxbullet")); enemies = new List <Enemies>(); Random random = new Random(); //amount of enemies for (int i = 0; i < 10; i++) { Texture2D tmpSprite = content.Load <Texture2D>("LaxMineEnemy"); int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Mine temp = new Mine(tmpSprite, rndX, rndY); enemies.Add(temp); } for (int i = 0; i < 15; i++) { Texture2D tmpSprite = content.Load <Texture2D>("Laxtripod"); int rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width); int rndY = random.Next(0, window.ClientBounds.Height / 2); Tripod temp = new Tripod(tmpSprite, rndX, rndY); enemies.Add(temp); } printText = new PrintText(content.Load <SpriteFont>("Spritefont")); goldCoinSprite = content.Load <Texture2D>("coin"); }