/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } p.Update(); eL.Update(); foreach (Bullet bullet in p.BList) { bullet.Update(); foreach (EnemyClass enemy in eL.EList) { if (bullet.Rectangle.Intersects(enemy.Rectangle)) { enemy.Damage(); bullet.Remove(); } } } foreach (EnemyClass enemy in eL.EList) { enemy.Update(); if (enemy.Rectangle.Intersects(p.Rectangle)) { points.WriteHighScore(); Exit(); } if (enemy.Position.Y > 800) { points.WriteHighScore(); Exit(); } } // TODO: Add your update logic here base.Update(gameTime); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } p.Update(); eL.Update(); foreach (Bullet element in p.BList) { element.Update(); } foreach (BaseClass element in eL.EList) { element.Update(); } // TODO: Add your update logic here base.Update(gameTime); }