public static void UpdateLasers(GameTime gameTime) { for (int i = 0; i < Lasers.Count;) { Laser2 l = Lasers[i]; l.Update(gameTime); if (l.Y < l.minY - l.Width || l.Y > l.maxY + l.Width || l.X < l.minX - l.Width || l.X > l.maxX + l.Width) { Lasers.Remove(l); } else { i++; } } }
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(); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); ColorTexture.White = ColorTexture.Create(GraphicsDevice, 16, 16, Color.White); ColorTexture.Black = ColorTexture.Create(GraphicsDevice, 16, 16, Color.Black); ColorTexture.Red = ColorTexture.Create(GraphicsDevice, 16, 16, Color.Red); ColorTexture.Green = ColorTexture.Create(GraphicsDevice, 16, 16, Color.Green); ColorTexture.Gray = ColorTexture.Create(GraphicsDevice, 16, 16, Color.Gray); HealthBar.Texture = Content.Load <Texture2D>("HealthBar2"); BulletType.NormalTexture = Content.Load <Texture2D>("peanut"); BulletType.FireTexture = Content.Load <Texture2D>("fire"); BulletType.CokeCanTexture = Content.Load <Texture2D>("cokecan"); BulletType.CrushCanTexture = Content.Load <Texture2D>("crushcan"); BulletType.DrPepperCanTexture = Content.Load <Texture2D>("drpeppercan"); BulletType.PepsiCanTexture = Content.Load <Texture2D>("pepsican"); BulletType.SierraMistCanTexture = Content.Load <Texture2D>("sierramistcan"); PowerUpType.DoubleShotTexture = Content.Load <Texture2D>("doubleshotpowerup"); PowerUpType.SpeedBoostTexture = Content.Load <Texture2D>("speedboostpowerup"); PowerUpType.CanShieldTexture = Content.Load <Texture2D>("shieldpowerup"); PowerUpType.SledgeHammerTexture = Content.Load <Texture2D>("sledgehammerpowerup"); Laser.Texture = ColorTexture.Create(graphicsDevice, 16, 16, Color.Red); Laser2.Texture = ColorTexture.Create(graphicsDevice, 16, 16, Color.Red); Laser.InitializeLine(GraphicsDevice); Laser2.InitializeLine(GraphicsDevice); Fireball.FireballTexture = Content.Load <Texture2D>("fireball"); AlexEnchanter.WarpTextures[0] = Content.Load <Texture2D>("alexenchanterwarp1jpg"); AlexEnchanter.WarpTextures[1] = Content.Load <Texture2D>("alexenchanterwarp2jpg"); AlexEnchanter.WarpTextures[2] = Content.Load <Texture2D>("alexenchanterwarp3jpg"); AlexEnchanter.WarpTextures[3] = Content.Load <Texture2D>("alexenchanterwarp4jpg"); AlexEnchanter.WarpTextures[4] = Content.Load <Texture2D>("alexenchanterwarp5jpg"); AlexEnchanter.WarpTextures[5] = Content.Load <Texture2D>("alexenchanterwarp6jpg"); AlexEnchanter.WarpTextures[6] = Content.Load <Texture2D>("alexenchanterwarp7jpg"); AlexEnchanter.WarpTextures[7] = Content.Load <Texture2D>("alexenchanterwarp8jpg"); AlexEnchanter.WarpTextures[8] = Content.Load <Texture2D>("alexenchanterwarp9jpg"); AlexEnchanter.WarpTextures[9] = Content.Load <Texture2D>("alexenchanterwarp10jpg"); AlexEnchanter.CastTextures[0] = Content.Load <Texture2D>("alexenchantercast1"); AlexEnchanter.CastTextures[1] = Content.Load <Texture2D>("alexenchantercast2"); AlexEnchanter.CastTextures[2] = Content.Load <Texture2D>("alexenchantercast3"); AlexEnchanter.CastTextures[3] = Content.Load <Texture2D>("alexenchantercast4"); AlexEnchanter.CastTextures[4] = Content.Load <Texture2D>("alexenchantercast5"); AlexEnchanter.CastTextures[5] = Content.Load <Texture2D>("alexenchantercast6"); AlexEnchanter.CastTextures[6] = Content.Load <Texture2D>("alexenchantercast7"); AlexEnchanter.CastTextures[7] = Content.Load <Texture2D>("alexenchantercast8"); AlexEnchanter.CastTextures[8] = Content.Load <Texture2D>("alexenchantercast9"); AlexEnchanter.CastTextures[9] = Content.Load <Texture2D>("alexenchantercast10"); AlexEnchanter.PeanutShieldTextures[0] = Content.Load <Texture2D>("peanutshield1"); AlexEnchanter.PeanutShieldTextures[1] = Content.Load <Texture2D>("peanutshield2"); AlexEnchanter.PeanutShieldTextures[2] = Content.Load <Texture2D>("peanutshield3"); AlexEnchanter.PeanutShieldTextures[3] = Content.Load <Texture2D>("peanutshield4"); AlexEnchanter.MagicStaffTexture = Content.Load <Texture2D>("Magic_staff"); AlexEnchanter.SuperFireballEnterSound = Content.Load <SoundEffect>("superfireballenter"); MouseSeeker.MouseTexture = Content.Load <Texture2D>("LOM"); MouseSeeker.CordTexture = ColorTexture.Create(graphicsDevice, 16, 16, Color.DarkGray); MouseSeeker.PlugTexture = Content.Load <Texture2D>("usb_plug"); Potion.RedPotionTexture = Content.Load <Texture2D>("redpotion"); }