public Game1() { bulletAlien = new BulletAlien(texture, origin, dir, speed, activeTime); graphics = new GraphicsDeviceManager(this); gsm = new GamestateManager(); // graphics.IsFullScreen = true; graphics.PreferredBackBufferHeight = 500; graphics.PreferredBackBufferWidth = 900; Content.RootDirectory = "Content"; ExitGame = this; ch = new ControlHandler(); r = new Random(); p = new Player(); hud = new HUD(graphics); oMenu = new OptionsMenu(graphics, Content); intro = new AsteroidsIntro(); screenHeight = graphics.PreferredBackBufferHeight; screenWidth = graphics.PreferredBackBufferWidth; numOfAsteroids = 3; currentGameState = 1; }
public void ShootBullet(GameTime gameTime) { this.origin = new Vector2(position.X + drawTexture.Width / 2, position.Y + drawTexture.Height / 2); shottimer += gameTime.ElapsedGameTime.Milliseconds; if (shottimer > timeBetweenShots) { shottimer = 0; BulletAlien b = new BulletAlien( bulletTexture, this.origin, this.direction, 1, // The speed 2000); // The active time in Milliseconds bullets.Add(b); } for (int i = 0; i < bullets.Count; i++) { bullets[i].Update(gameTime); if (bullets[i].totalActiveTime > bullets[i].activeTime) bullets.RemoveAt(i); } direction.X = rnd.Next(-5, 5); direction.Y = rnd.Next(-5, 5); }