//Input private float Input(GameTime gameTime, float timer) { KeyboardState keyb = Keyboard.GetState(); MouseState mouseState = Mouse.GetState(); GamePadState gpad1 = GamePad.GetState(PlayerIndex.One); Vector3 mouseP = Initial; Vector3 mouseR = Initial; Vector2 mouseC; Rectangle BallRectangle = new Rectangle(50, screenHeight - 220, 200, 200); Rectangle Hyp = new Rectangle(250, screenHeight - 220, 60, 65); mouseP.X = mouseState.X; mouseP.Y = mouseState.Y; mouseC.X = BallRectangle.Center.X; mouseC.Y = BallRectangle.Center.Y; if ((mouseP.X >= Hyp.Left) && (mouseP.X <= Hyp.Right) && (mouseP.Y >= Hyp.Top) && (mouseP.Y <= Hyp.Bottom) && (mouseState.LeftButton == ButtonState.Pressed)) { hypButton = Content.Load<Texture2D>("Images\\p1hypclk"); if (hyperbool == true) { Random x = new Random(); Random y = new Random(); play.position.X = x.Next(-2000, 2000); play.position.Y = y.Next(-2000, 2000); hyperSpace = 0; HyperSpace.Play(); } hyperbool = false; } if ((mouseP.X >= BallRectangle.Left) && (mouseP.X <= BallRectangle.Right) && (mouseP.Y >= BallRectangle.Top) && (mouseP.Y <= BallRectangle.Bottom) && (mouseState.LeftButton == ButtonState.Pressed)) { #region Thrust if ((mouseP.Y < mouseC.Y + 20) && (mouseP.X > mouseC.X - 20) && (mouseP.X < mouseC.X + 20)) { thrustclicked = true; //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput(); } #endregion #region Spin Left if (mouseP.X > mouseC.X + 20) { play.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); leftclicked = true; } #endregion #region Spin Right if (mouseP.X < mouseC.X - 20) { play.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); leftclicked = true; } #endregion #region Shoot if ((mouseP.Y > mouseC.Y - 20) && (mouseP.X > mouseC.X - 20) && (mouseP.X < mouseC.X + 20) && (timer > interval)) { shootclicked = true; for (int i = 0; i <= noBullets - 1; i++) { if (!BulletList[i].AmmoFlying) { BulletList[i] = new Projectile(ammo, play.position, play.rotation, Initial, true, Initial); BulletList[i].ammoVelocityAdd.X = -(float)Math.Sin(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd.Y = +(float)Math.Cos(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd *= 100; BulletList[i].AmmoVelocity += BulletList[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer = 0; } } #endregion } #region pause if (keyb.IsKeyDown(Keys.P) || (gpad1.Buttons.Start == ButtonState.Pressed)) { paused = true; } #endregion #region HyperSpace if (keyb.IsKeyDown(Keys.H) || (gpad1.Buttons.Y == ButtonState.Pressed)) { if (hyperSpace == 1) { hypButton = Content.Load<Texture2D>("Images\\p1hypclk"); hyperbool = false; Random x = new Random(); Random y = new Random(); play.position.X = x.Next(-2000, 2000); play.position.Y = y.Next(-2000, 2000); hyperSpace = 0; HyperSpace.Play(); } } #endregion #region Left Right if (keyb.IsKeyDown(Keys.Left) || (gpad1.ThumbSticks.Left.X < 0.0f)) { play.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } if (keyb.IsKeyDown(Keys.Right) || (gpad1.ThumbSticks.Left.X > 0.0f)) { play.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } #endregion #region Thrust if (keyb.IsKeyDown(Keys.Space) || (gpad1.Triggers.Left == 1.0f)) { //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput(); } #endregion #region Shoot if (((keyb.IsKeyDown(Keys.Enter)) || (gpad1.Triggers.Right == 1.0f)) && (timer > interval)) { for (int i = 0; i <= noBullets - 1; i++) { if (!BulletList[i].AmmoFlying) { BulletList[i] = new Projectile(ammo, play.position, play.rotation, Initial, true, Initial); BulletList[i].ammoVelocityAdd.X = -(float)Math.Sin(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd.Y = +(float)Math.Cos(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd *= 100; BulletList[i].AmmoVelocity += BulletList[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer = 0; } } #endregion #region Position Check And Velocity play.position += play.velocity; play.velocity *= 0.95f; for (int i = 0; i <= NumAsteroid1 - 1; i++) { asteroid1List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid1List[i].position); } for (int i = 0; i <= NumAsteroid2 - 1; i++) { if (asteroid2List[i].isAlive) { asteroid2List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid2List[i].position); } } for (int i = 0; i <= NumAsteroid3 - 1; i++) { if (asteroid3List[i].isAlive) { asteroid3List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid3List[i].position); } } play.position = check.Position(screenWidth, screenHeight, play.position); #endregion #region UFO Shoot if (ufoShoot > interval) { saucer.isAlive = check.UFOPosition(screenWidth, screenHeight, saucer.position, saucer.isAlive); if (saucer.isAlive) { for (int i = 0; i <= noBullets - 1; i++) { if (!ufoBulletList[i].AmmoFlying) { ufoBulletList[i] = new Projectile(ammo, saucer.position, saucer.rotation, Initial, true, Initial); ufoBulletList[i].ammoVelocityAdd.X = -(float)Math.Sin(ufoBulletList[i].AmmoAngle); ufoBulletList[i].ammoVelocityAdd.Y = +(float)Math.Cos(ufoBulletList[i].AmmoAngle); ufoBulletList[i].ammoVelocityAdd *= 100; ufoBulletList[i].AmmoVelocity += ufoBulletList[i].ammoVelocityAdd; ufoFire.Play(); break; } ufoShoot = 0; } } } #endregion ufoShoot += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; return timer; }
public override void LoadContent() { if (Content == null) Content = new ContentManager(ScreenManager.Game.Services, "Content"); #region loaded content myModel = Content.Load<Model>("Model\\fighter"); Player2 = Content.Load<Model>("Model\\Player2"); Player3 = Content.Load<Model>("Model\\Player3"); Player4 = Content.Load<Model>("Model\\player4"); Asteroid1 = Content.Load<Model>("Model\\Asteroid1"); Asteroid2 = Content.Load<Model>("Model\\Asteroid2"); Asteroid3 = Content.Load<Model>("Model\\Asteroid3"); globe = Content.Load<Model>("Model\\globe"); Explosion = Content.Load<SoundEffect>("Audio\\explosion3"); dataScreen = Content.Load<Texture2D>("Images\\DataScreen"); BackGround = Content.Load<Texture2D>("Images\\background"); panel = Content.Load<Texture2D>("Images\\panel"); panel2 = Content.Load<Texture2D>("Images\\panel2"); hypButton = Content.Load<Texture2D>("Images\\p1hyp"); hypButton2 = Content.Load<Texture2D>("Images\\p2hypclk"); ammo = Content.Load<Model>("Model\\ammo"); Engine = Content.Load<SoundEffect>("Audio\\engine_3"); WeaponFire = Content.Load<SoundEffect>("Audio\\pdp1_fire"); defaultFont = Content.Load<SpriteFont>("Fonts\\defaultFont"); HyperSpace = Content.Load<SoundEffect>("Audio\\hax2_fire_alt"); play = new Player(myModel, Player1Start, 0.0f, 10); play2 = new Player2(Player2, Player2Start, 0.0f, 10); play3 = new Player3(Player3, Player3Start, 0.0f, 10); play4 = new Player4(Player4, Player4Start, 0.0f, 10); Projectile bullet = new Projectile(ammo, Initial, 0.0f, Initial, false, Initial); BulletList = new Projectile[noBullets]; Bullet2List = new Projectile[noBullets]; Bullet3List = new Projectile[noBullets]; Bullet4List = new Projectile[noBullets]; #endregion #region Graphic Device and screen elements screenWidth = ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; screenHeight = ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; aspectRatio = ScreenManager.GraphicsDevice.Viewport.AspectRatio; #endregion #region initialise Asteroids AP1.X = 0; AP1.Y = 0; AP2.X = -2500; AP2.Y = -2000; AP3.X = -1500; AP3.Y = -1500; AP4.X = -300; AP4.Y = 1500; asteroid1List[0] = new Asteroid(Asteroid1, AP1, 0.005f, true, 5); asteroid1List[1] = new Asteroid(Asteroid1, AP2, 1.5f, true, 5); asteroid3List[0] = new Asteroid(Asteroid3, AP3, 0.005f, true, 1); asteroid3List[1] = new Asteroid(Asteroid3, AP4, 0.5f, true, 1); asteroid3List[2] = new Asteroid(Asteroid3, new Vector3(2500, 1900, 0), 1.25f, true, 1); asteroid3List[3] = new Asteroid(Asteroid3, new Vector3(300, 2500, 0), 2.0f, true, 1); asteroid3List[4] = new Asteroid(Asteroid3, new Vector3(-2500, 1500, 0), 2.5f, true, 1); asteroid3List[5] = new Asteroid(Asteroid3, new Vector3(-500, 200, 0), 3.0f, true, 1); asteroid3List[6] = new Asteroid(Asteroid3, new Vector3(-1500, 2000, 0), 3.5f, true, 1); asteroid3List[7] = new Asteroid(Asteroid3, new Vector3(1500, -2500, 0), 4.0f, true, 1); for (int i = 0; i < NumAsteroid2; i++) asteroid2List[i] = new Asteroid(Asteroid2, new Vector3(4000, 4000, 0), 0.005f, false, 3); for (int i = 8; i < NumAsteroid3; i++) asteroid3List[i] = new Asteroid(Asteroid3, new Vector3(4000, 4000, 0), 0.005f, false, 1); #endregion #region initialise bullet list for (int i = 0; i < noBullets; i++) { BulletList[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); } #endregion #region initialise bullet 2 list for (int i = 0; i < noBullets; i++) { Bullet2List[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); } #endregion #region initialise bullet 3 list for (int i = 0; i < noBullets; i++) { Bullet3List[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); } #endregion #region initialise bullet 4 list for (int i = 0; i < noBullets; i++) { Bullet4List[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); } #endregion }
public override void LoadContent() { if (Content == null) Content = new ContentManager(ScreenManager.Game.Services, "Content"); #region loaded content myModel = Content.Load<Model>("Model\\fighter"); Asteroid1 = Content.Load<Model>("Model\\Asteroid1"); Asteroid2 = Content.Load<Model>("Model\\Asteroid2"); Asteroid3 = Content.Load<Model>("Model\\Asteroid3"); ammo = Content.Load<Model>("Model\\ammo"); ufo = Content.Load<Model>("Model\\UFO"); venus = Content.Load<Model>("Model\\venus"); Explosion = Content.Load<SoundEffect>("Audio\\explosion3"); dataScreen = Content.Load<Texture2D>("Images\\DataScreen"); BackGround = Content.Load<Texture2D>("Images\\background2"); panel = Content.Load<Texture2D>("Images\\panel"); hypButton = Content.Load<Texture2D>("Images\\p1hyp"); hypButtonClk = Content.Load<Texture2D>("Images\\p1hypclk"); ufoFire = Content.Load<SoundEffect>("Audio\\tx0_fire1"); Engine = Content.Load<SoundEffect>("Audio\\engine_3"); WeaponFire = Content.Load<SoundEffect>("Audio\\pdp1_fire"); defaultFont = Content.Load<SpriteFont>("Fonts\\defaultFont"); HyperSpace = Content.Load<SoundEffect>("Audio\\hax2_fire_alt"); play = new Player(myModel, Initial, 0.0f, 3); saucer = new UFO(ufo, new Vector3(9000, 9000, 0), 0.0f, 5, false); Projectile bullet = new Projectile(ammo, Initial, 0.0f, Initial, false, Initial); ufoque = new float[] { 4000, 36000, 36000 }; BulletList = new Projectile[noBullets]; ufoBulletList = new Projectile[noBullets]; #endregion #region Graphic Device and screen elements screenWidth = ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; screenHeight = ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; aspectRatio = ScreenManager.GraphicsDevice.Viewport.AspectRatio; #endregion #region initialise Asteroids AP1.X = -2000; AP1.Y = screenHeight; AP2.X = -screenWidth; AP2.Y = -2000; AP3.X = 500; AP3.Y = -screenHeight; AP4.X = screenWidth; AP4.Y = 750; asteroid1List[0] = new Asteroid(Asteroid1, AP1, 0.5f, true, 5); asteroid1List[1] = new Asteroid(Asteroid1, AP2, 1.25f, true, 5); asteroid1List[2] = new Asteroid(Asteroid1, AP3, 2.005f, true, 5); asteroid2List[0] = new Asteroid(Asteroid2, AP4, 0.005f, true, 3); for (int i = 1; i < NumAsteroid2; i++) asteroid2List[i] = new Asteroid(Asteroid2, new Vector3(4000, 4000, 0), 0.005f, false, 3); for (int i = 0; i < NumAsteroid3; i++) asteroid3List[i] = new Asteroid(Asteroid3, new Vector3(4000, 4000, 0), 0.005f, false, 1); #endregion #region initialise bullet list for (int i = 0; i < noBullets; i++) { BulletList[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); ufoBulletList[i] = new Projectile(ammo, new Vector3(5000, 5000, 0), 0.0f, Initial, false, Initial); } #endregion }
//Input private float Input(GameTime gameTime, float timer) { KeyboardState keyb = Keyboard.GetState(); GamePadState gpad1 = GamePad.GetState(PlayerIndex.One); GamePadState gpad2 = GamePad.GetState(PlayerIndex.Two); GamePadState gpad3 = GamePad.GetState(PlayerIndex.Three); GamePadState gpad4 = GamePad.GetState(PlayerIndex.Four); #region pause if (keyb.IsKeyDown(Keys.P) || (gpad1.Buttons.Start == ButtonState.Pressed) || (gpad2.Buttons.Start == ButtonState.Pressed) || (gpad3.Buttons.Start == ButtonState.Pressed) || (gpad4.Buttons.Start == ButtonState.Pressed)) { paused = true; } #endregion #region HyperSpace if ((keyb.IsKeyDown(Keys.H) || (gpad1.Buttons.Y == ButtonState.Pressed))&& p1dead==false) { if (hyperSpace == 1) { hypButton = Content.Load<Texture2D>("Images\\p1hypclk"); hyperbool = false; Random x = new Random(); Random y = new Random(); play.position.X = x.Next(-2000, 2000); play.position.Y = y.Next(-2000, 2000); hyperSpace = 0; HyperSpace.Play(); } } if ((keyb.IsKeyDown(Keys.G) || (gpad2.Buttons.Y == ButtonState.Pressed))&& p2dead==false) { if (hyperSpace2 == 1) { hypButton2 = Content.Load<Texture2D>("Images\\p2hyp"); hyperbool2 = false; Random x = new Random(); Random y = new Random(); play2.position.X = x.Next(-2000, 2000); play2.position.Y = y.Next(-2000, 2000); hyperSpace2 = 0; HyperSpace.Play(); } } if (((keyb.IsKeyDown(Keys.L)) || (gpad3.Buttons.Y == ButtonState.Pressed))&&p3dead==false) { if (hyperSpace3 == 1) { Random x = new Random(); Random y = new Random(); play3.position.X = x.Next(-2000, 2000); play3.position.Y = y.Next(-2000, 2000); hyperSpace3 = 0; HyperSpace.Play(); } } if (((keyb.IsKeyDown(Keys.NumPad1)) || (gpad4.Buttons.Y == ButtonState.Pressed))&&p4dead==false) { if (hyperSpace3 == 1) { Random x = new Random(); Random y = new Random(); play4.position.X = x.Next(-2000, 2000); play4.position.Y = y.Next(-2000, 2000); hyperSpace4 = 0; HyperSpace.Play(); } } #endregion #region Left Right + 'A' 'D' #region Player1 if (keyb.IsKeyDown(Keys.Left) || (gpad1.ThumbSticks.Left.X < -0.0f)) { play.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } if (keyb.IsKeyDown(Keys.Right) || (gpad1.ThumbSticks.Left.X > 0.0f)) { play.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } #endregion #region Player 2 if (keyb.IsKeyDown(Keys.A) || (gpad2.ThumbSticks.Left.X < 0.0f)) { play2.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } if (keyb.IsKeyDown(Keys.D) || (gpad2.ThumbSticks.Left.X > 0.0f)) { play2.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } #endregion #region Player 3 if ((keyb.IsKeyDown(Keys.B)) || (gpad3.ThumbSticks.Left.X < 0.0f)) { play3.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } if ((keyb.IsKeyDown(Keys.M)) || (gpad3.ThumbSticks.Left.X > 0.0f)) { play3.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } #endregion #region Player 4 if ((keyb.IsKeyDown(Keys.NumPad2)) || (gpad4.ThumbSticks.Left.X < 0.0f)) { play4.rotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } if ((keyb.IsKeyDown(Keys.NumPad3)) || (gpad4.ThumbSticks.Left.X > 0.0f)) { play4.rotation -= (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.2f); } #endregion #endregion #region Thrust and 'W' if (keyb.IsKeyDown(Keys.Space) || (gpad1.Triggers.Left == 1.0f)) { //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput(); } if (keyb.IsKeyDown(Keys.W) || (gpad2.Triggers.Left == 1.0f)) { //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput2(); } if (keyb.IsKeyDown(Keys.J) || (gpad3.Triggers.Left == 1.0f)) { //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput3(); } if (keyb.IsKeyDown(Keys.NumPad4) || (gpad4.Triggers.Left == 1.0f)) { //Play engine sound only when the engine is on. if (!EnginePlaying) { if (EngineInstance == null) { EngineInstance = Engine.Play(); EngineInstance.Volume = 1.0f; } else EngineInstance.Resume(); EnginePlaying = true; } else if (EnginePlaying) { EngineInstance.Play(); EnginePlaying = false; } UpdateInput4(); } #endregion #region Shoot(enter) + shoot (F) if (((keyb.IsKeyDown(Keys.Enter)) || (gpad1.Triggers.Right == 1.0f)) && (timer > interval) && p1dead==false) { for (int i = 0; i <= noBullets - 1; i++) { if (!BulletList[i].AmmoFlying) { BulletList[i] = new Projectile(ammo, play.position, play.rotation, Initial, true, Initial); BulletList[i].ammoVelocityAdd.X = -(float)Math.Sin(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd.Y = +(float)Math.Cos(BulletList[i].AmmoAngle); BulletList[i].ammoVelocityAdd *= 100; BulletList[i].AmmoVelocity += BulletList[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer = 0; } } if (((keyb.IsKeyDown(Keys.F)) || (gpad2.Triggers.Right == 1.0f)) && (timer2 > interval)&& p2dead==false) { for (int i = 0; i <= noBullets - 1; i++) { if (!Bullet2List[i].AmmoFlying) { Bullet2List[i] = new Projectile(ammo, play2.position, play2.rotation, Initial, true, Initial); Bullet2List[i].ammoVelocityAdd.X = -(float)Math.Sin(Bullet2List[i].AmmoAngle); Bullet2List[i].ammoVelocityAdd.Y = +(float)Math.Cos(Bullet2List[i].AmmoAngle); Bullet2List[i].ammoVelocityAdd *= 100; Bullet2List[i].AmmoVelocity += Bullet2List[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer2 = 0; } } if (((keyb.IsKeyDown(Keys.V))) || (gpad3.Triggers.Right == 1.0f) && (timer3 > interval) && p3dead==false) { for (int i = 0; i <= noBullets - 1; i++) { if (!Bullet3List[i].AmmoFlying) { Bullet3List[i] = new Projectile(ammo, play3.position, play3.rotation, Initial, true, Initial); Bullet3List[i].ammoVelocityAdd.X = -(float)Math.Sin(Bullet3List[i].AmmoAngle); Bullet3List[i].ammoVelocityAdd.Y = +(float)Math.Cos(Bullet3List[i].AmmoAngle); Bullet3List[i].ammoVelocityAdd *= 100; Bullet3List[i].AmmoVelocity += Bullet3List[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer3 = 0; } } if (((keyb.IsKeyDown(Keys.NumPad5))) || (gpad4.Triggers.Right == 1.0f) && (timer4 > interval)&& p4dead==false) { for (int i = 0; i <= noBullets - 1; i++) { if (!Bullet4List[i].AmmoFlying) { Bullet4List[i] = new Projectile(ammo, play4.position, play4.rotation, Initial, true, Initial); Bullet4List[i].ammoVelocityAdd.X = -(float)Math.Sin(Bullet4List[i].AmmoAngle); Bullet4List[i].ammoVelocityAdd.Y = +(float)Math.Cos(Bullet4List[i].AmmoAngle); Bullet4List[i].ammoVelocityAdd *= 100; Bullet4List[i].AmmoVelocity += Bullet4List[i].ammoVelocityAdd; WeaponFire.Play(); break; } timer4 = 0; } } #endregion #region Position Check And Velocity play.position += play.velocity; play.velocity *= 0.95f; play2.position += play2.velocity; play2.velocity *= 0.95f; play3.position += play3.velocity; play3.velocity *= 0.95f; play4.position += play3.velocity; play4.velocity *= 0.95f; for (int i = 0; i <= NumAsteroid1 - 1; i++) { asteroid1List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid1List[i].position); } for (int i = 0; i <= NumAsteroid2 - 1; i++) { if (asteroid2List[i].isAlive) { asteroid2List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid2List[i].position); } } for (int i = 0; i <= NumAsteroid3 - 1; i++) { if (asteroid3List[i].isAlive) { asteroid3List[i].position = check.RoidPosition(screenWidth, screenHeight, asteroid3List[i].position); } } play.position = check.Position(screenWidth, screenHeight, play.position); play2.position = check.Position(screenWidth, screenHeight, play2.position); play3.position = check.Position(screenWidth, screenHeight, play3.position); play4.position = check.Position(screenWidth, screenHeight, play4.position); #endregion timer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer2 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer3 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer4 += (float)gameTime.ElapsedGameTime.TotalMilliseconds; return timer; }