public override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || (exitButton.Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed)) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { cleanup(); returnControl("title"); return; } if (returnButton.Rectangle.Contains(Mouse.GetState().X, Mouse.GetState().Y) && Mouse.GetState().LeftButton == ButtonState.Pressed) { cleanup(); returnControl("title"); return; } // mute check checkForMute(); Bullet.moveBullets(gameTime); rotateCans(gameTime); rotatePeanuts(gameTime); createFallingCans(gameTime); }
public override void Update(GameTime gameTime) { // check for exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { cleanup(); returnControl("title"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { MediaPlayer.Volume /= 4; } else { MediaPlayer.Volume *= 4; } } if (paused) { return; } //show fps every 1 second fpsElapsedTime += gameTime.ElapsedGameTime; if (fpsElapsedTime > TimeSpan.FromSeconds(1)) { Game1.Game.Window.Title = "FPS: " + frameCounter; fpsElapsedTime -= TimeSpan.FromSeconds(1); frameCounter = 0; } // update position of crosshair position crossHair.CenterPoint = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); // update blasts and explosions updateBlasts(gameTime); updateExplosions(); // move gun moveGun(gameTime); // update gun angle updateGunAngle(gameTime); // move and rotate bullets Bullet.moveBullets(gameTime); rotatePeanuts(gameTime); // shoot on click checkForShoot(gameTime); }
public override void Update(GameTime gameTime) { // check for exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { cleanup(); returnControl("title"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { //MediaPlayer.Pause(); MediaPlayer.Volume /= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Stop(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Stop(); } } else { //MediaPlayer.Resume(); MediaPlayer.Volume *= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Start(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Start(); } } } if (paused) { return; } //show fps every 1 second fpsElapsedTime += gameTime.ElapsedGameTime; if (fpsElapsedTime > TimeSpan.FromSeconds(1)) { Game1.Game.Window.Title = "FPS: " + frameCounter; fpsElapsedTime -= TimeSpan.FromSeconds(1); frameCounter = 0; } isaacHurtAnimation.Update(); //isaacHurtMove(gameTime); spawnPotions(gameTime); moveIsaac(gameTime); Bullet.moveBullets(gameTime); rotatePeanuts(gameTime); Fireball.moveFireballs(gameTime); rotateFireballs(gameTime); Laser2.UpdateLasers(gameTime); SeekerSnake.UpdateSeekerSnakes(gameTime); checkForPowerUpSpawnExpire(gameTime); isaac.CalculateCorners(); alex.CalculateCorners(); foreach (Laser2 laser in Laser2.Lasers) { laser.CalculateCorners(); } foreach (Bullet p in Bullet.Peanuts) { p.CalculateCorners(); } checkForPowerUpAcquisition(); acquirePotions(); isaacShoot(gameTime); checkForPeanutHits(); checkForSledgeHammerUse(gameTime); checkForSledgeHammerHits(); if (checkForIsaacHurt()) { isaacDeath(); cleanup(); returnControl("title"); return; } if (alex.HP == 0) { cleanup(); returnControl("postgame"); return; } alex.Update(gameTime, isaac); updateHearts(); shrinkPeanuts(gameTime); burnPeanuts(gameTime); moveBurningPeanuts(gameTime); updateSuperFireballLoopingSound(); }
public override void Update(GameTime gameTime) { // check for exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { returnControl("title"); return; } if (checkForBillDeath()) { Stats.PeanutShots -= Bullet.Peanuts.Count; returnControl("endbattle1"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { //MediaPlayer.Pause(); MediaPlayer.Volume /= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Stop(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Stop(); } } else { //MediaPlayer.Resume(); MediaPlayer.Volume *= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Start(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Start(); } } } if (paused) { return; } //show fps every 1 second fpsElapsedTime += gameTime.ElapsedGameTime; if (fpsElapsedTime > TimeSpan.FromSeconds(1)) { fpsElapsedTime -= TimeSpan.FromSeconds(1); Game1.Game.Window.Title = "FPS: " + frameCounter; //Game1.Game.Window.Title = "FPS: " + frameCounter + " | Projectiles: " + (Bullet.Peanuts.Count + Bullet.Cans.Count) + " | Powerups: " + PowerUp.AlivePowerUps.Count + " | Sound instances: " + SoundEffectManager.SoundEffectInstances.Count + "."; //Game1.Game.Window.Title = "Peanuts: " + Bullet.Peanuts.Length + " Cans: " + Bullet.Cans.Length + " Powerups: " + PowerUp.AlivePowerUps.Count; frameCounter = 0; } //Game1.Game.Window.Title = SoundEffectManager.soundEffectInstances.Count + " sound effect instances"; billStatus = bill.HP <= (bill.MaxHP * .5) ? (bill.HP <= (bill.MaxHP * .1) ? "PISSED" : "Upset") : "Normal"; if (billStatus == "Normal") { moveBillRandom(gameTime); } else if (billStatus == "Upset" && (int)(DateTime.Now - startTime).TotalSeconds % 8 != 7) { moveBillRandom(gameTime); } else { checkForBillSpray(gameTime); moveBillAngry(gameTime); if (!billIsAngry) { billIsAngry = true; timeBillGotAngry = DateTime.Now; if (billStatus == "PISSED") { currentBillMessage = LOWHPMESSAGE; } else { currentBillMessage = billMessages[rand.Next(billMessages.Length)]; } } } if ((DateTime.Now - timeBillGotAngry).TotalSeconds >= 1) { billIsAngry = false; } if (currentBillMessage == LOWHPMESSAGE && billStatus != "PISSED") { billIsAngry = false; } moveIsaac(gameTime); Bullet.moveBullets(gameTime); rotatePeanuts(gameTime); rotateCans(gameTime); checkForPowerUpSpawnExpire(gameTime); // calculate rotated positions of everything // sledgehammer is calculated in own method isaac.CalculateCorners(); foreach (Bullet b in Bullet.Cans) { b.CalculateCorners(); } if (GameSettings.ProjectileRotationCollision) { bill.CalculateCorners(); foreach (Bullet b in Bullet.Peanuts) { b.CalculateCorners(); } } checkForPowerUpAcquisition(); checkForIsaacDeath(); checkForBulletHits(); checkForBillShoot(gameTime); checkForIsaacShoot(gameTime); checkForSledgeHammerUse(gameTime); checkForSledgeHammerHits(); // clean up sound effect instances /*if (++cleanupCounter >= 60) * { * SoundEffectManager.Cleanup(); * cleanupCounter = 0; * }*/ //Game1.Game.Window.Title = "Bill's HP: " + bill.HP + "/" + bill.MaxHP + " Status: " + status; billHPString = "Bill's HP: " + bill.HP + "/" + bill.MaxHP; billStatusString = "Status: " + billStatus; }
public override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { returnControl("title"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { startTimer.Stop(); MediaPlayer.Pause(); } else { startTimer.Start(); MediaPlayer.Resume(); } } if (paused) { return; } //if (startTimer.ElapsedMilliseconds >= 10000) //MediaPlayer.Volume -= .001f; //if (MediaPlayer.Volume == 0) //if (MediaPlayer.State == MediaState.Stopped) // go to PostGame if (isaacSizeMaxedTime == DateTime.MinValue && isaac.Height == Graphics.GraphicsDevice.Viewport.Height) { isaacSizeMaxedTime = DateTime.Now; } if (isaacSizeMaxedTime != DateTime.MinValue && (DateTime.Now - isaacSizeMaxedTime).TotalSeconds >= 1) { returnControl("postgame"); return; } actualScrollSpeed = (int)Math.Round(Util.ScaleWithGameTime(scrollSpeed, gameTime)); scrollBackground(gameTime); //if (startTimer.ElapsedMilliseconds >= STARTDELAY) //{ //scrollBackground(gameTime); //bill.moveTowards(billTarget, gameTime); //} //if (startTimer.ElapsedMilliseconds < 3000) //bill.moveTowards(billTarget, gameTime); //else //else if (startTimer.ElapsedMilliseconds < 7000) { moveBillRandom(gameTime); bill.Speed += 2; rotationSpeed += .05f; bill.Rotation += Util.ScaleWithGameTime(rotationSpeed, gameTime); } if (startTimer.ElapsedMilliseconds > 3000) { billSprayFireRandom(); rotateCans(gameTime); Bullet.moveBullets(gameTime); isaacTarget = new Vector2(Graphics.GraphicsDevice.Viewport.Width / 2, Graphics.GraphicsDevice.Viewport.Height / 2); isaac.moveTowardsPrecise(isaacTarget, gameTime, true); if (isaac.Height < Graphics.GraphicsDevice.Viewport.Height) { isaac.Width += 1; isaac.Height += 1; } } if (isaac.CenterPoint != isaacTarget) { isaac.moveTowardsPrecise(isaacTarget, gameTime, true); } }