public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Select()) { BustinOutGame.setLevel(1); BustinOutGame.setState(4, 0); } }
public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Select()) { BustinOutGame.setState(1, 1); } if (ctrl.Back()) { BustinOutGame.setState(1, 1); } }
public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Up()) { PositionUp(); } if (ctrl.Down()) { PositionDown(); } if (ctrl.Select()) { //Easy if (location == 0) { BustinOutGame.setLevel(1); BustinOutGame.setState(12, 1); BustinOutGame.timeRemaining = TimeSpan.FromMinutes(40.0); } //Normal else if (location == 1) { BustinOutGame.setLevel(1); BustinOutGame.setState(12, 1); BustinOutGame.timeRemaining = TimeSpan.FromMinutes(20.0); } //Go back to title screen else { BustinOutGame.setState(1, 1); } } if (ctrl.Back()) { BustinOutGame.setState(1, 1); } }
public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Select()) { if (option == 0) { BustinOutGame.setState(11, 1); } else if (option == 1) { BustinOutGame.setState(5, 1); } else if (option == 2) { BustinOutGame.setState(6, 1); } else { if (fromTitle == 0) { BustinOutGame.setState(1, 1); } else { BustinOutGame.setState(7, 0); FromTitle = 0; } } option = 0; position = arrowPosition; } if (ctrl.Back()) { if (fromTitle == 0) { BustinOutGame.setState(1, 1); } else { BustinOutGame.setState(7, 0); FromTitle = 0; } } if (ctrl.Up()) { if (option == 0) { option = 3; } else { option--; } setPosition(); } if (ctrl.Down()) { if (option == 3) { option = 0; } else { option++; } setPosition(); } }
public void Update(GameTime gameTime, GraphicsDeviceManager graphics) { ctrl.setStates(); if (ctrl.Select()) { if (option == 0) { BustinOutGame.setState(3, 1); option = 0; position = arrowPosition; } else if (option == 1) { if (isFullScreen == true) { isFullScreen = false; screen = graphicsScreen; graphics.ToggleFullScreen(); } } else { if (isFullScreen == false) { isFullScreen = true; screen = graphicsScreen2; graphics.ToggleFullScreen(); } } } if (ctrl.Back()) { BustinOutGame.setState(3, 1); } if (ctrl.Up()) { if (option == 0) { option = 1; } else { option = 0; } setPosition(); } if (ctrl.Down()) { if (option == 1 || option == 2) { option = 0; } else { option = 1; } setPosition(); } if (ctrl.Right() || ctrl.Left()) { if (option == 1) { option = 2; } else if (option == 2) { option = 1; } setPosition(); } }
public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Select()) { if (option == 0) { BustinOutGame.setState(8, 0); } else if (option == 1) { BustinOutGame.setState(9, 0); } else if (option == 2) { } else if (option == 3) { } else { BustinOutGame.setState(1, 1); } option = 0; position = arrowPosition; } if (ctrl.Back()) { BustinOutGame.setState(1, 1); } if (ctrl.Up()) { if (option == 0) { option = 4; } else { option--; } setPosition(); } if (ctrl.Down()) { if (option == 4) { option = 0; } else { option++; } setPosition(); } }
public void Update(GameTime gameTime) { ctrl.setStates(); if (pongState == 0) { if (ctrl.Select()) { pongState = 1; } } if (pongState == 1) { //Controls if (ctrl.moveUp()) { playerone.ySpeed = negPaddleSpeed; } else if (ctrl.moveDown()) { playerone.ySpeed = posPaddleSpeed; } else { playerone.ySpeed = 0; } if (ctrl.Pause()) { BustinOutGame.setState(7, 0); } if (p1Score == winning) { pongState = 2; } playerone.UpdatePaddle(); playertwo.UpdatePaddle(); playerrectangle.X = (int)playerone.Position.X; playerrectangle.Y = (int)playerone.Position.Y; computerrectangle.X = (int)playertwo.Position.X; computerrectangle.Y = (int)playertwo.Position.Y; ballrectangle.X = (int)ball.Position.X; ballrectangle.Y = (int)ball.Position.Y; ball.UpdateBall(); //Computer scores a point if (ball.Position.X <= -100) { speedReset(); p2Score++; direction = 0; } //Player scores a point else if (ball.Position.X + ball1.Width >= width - 5) { speedReset(); p1Score++; direction = 1; } //ball hits bottom wall if (ball.Position.Y + ball1.Height > height) { ball.ySpeed *= -1; } //ball hits top wall else if (ball.Position.Y < 0) { ball.ySpeed *= -1; } //Stop player from going through top or bottom if (playerone.Position.Y < 0) { playerone.Position.Y = 0; } else if (playerone.Position.Y + paddle.Height > height) { playerone.Position.Y = height - paddle.Height; } //Stop computer from going through top or bottom if (playertwo.Position.Y < 0) { playertwo.Position.Y = 0; } else if (playertwo.Position.Y + paddle.Height > height) { playertwo.Position.Y = height - paddle.Height; } //ball hits a paddle if (ballrectangle.Intersects(playerrectangle)) { ball.Position.X = playerrectangle.Right; ball.xSpeed++; ball.ySpeed++; ball.xSpeed *= -1; direction = 0; blip.Play(); } else if (ballrectangle.Intersects(computerrectangle)) { ball.Position.X = computerrectangle.Left - ball1.Width; ball.xSpeed++; ball.ySpeed++; ball.xSpeed *= -1; direction = 1; blip.Play(); } //The AI for the computer (just tries to match the ball) if (ball.Position.Y + ball1.Height / 2 > playertwo.Position.Y + paddle.Height / 2) { playertwo.ySpeed = posPaddleSpeed; } else if (ball.Position.Y + ball1.Height / 2 < playertwo.Position.Y + paddle.Height / 2) { playertwo.ySpeed = negPaddleSpeed; } } if (pongState == 2) { if (ctrl.Select()) { BustinOutGame.wonPong = true; BustinOutGame.setState(4, 0); } } }
public void Update(GameTime gameTime) { ctrl.setStates(); //timeRemaining -= gameTime.ElapsedGameTime; //create this rectangle in update since the x and y will change playerrectangle = new Rectangle((int)playerPos.X, (int)playerPos.Y, mLeft.Width, mLeft.Height); //If the player wants to move up if (ctrl.Up()) { if (posY == yMax) { //do nothing } else if (CollisionWalls(1) == true) { //do nothing } else { playerPos.Y = playerPos.Y - 57; posY++; } } //If the player wants to move down if (ctrl.Down()) { if (posY == 0) { //do nothing } else if (CollisionWalls(2) == true) { //do nothing } else { playerPos.Y = playerPos.Y + 57; posY--; } } //If the player wants to move left if (ctrl.Left()) { mman = mLeft; if (posX == 0) { //do nothing } else if (CollisionWalls(3) == true) { //do nothing } else { playerPos.X = playerPos.X - 80; posX--; } } //If the player wants to move right if (ctrl.Right()) { mman = mRight; if (posX == xMax) { //do nothing } else if (CollisionWalls(4) == true) { //do nothing } else { playerPos.X = playerPos.X + 80; posX++; } } //pause the game if (ctrl.Pause()) { BustinOutGame.setState(7, 0); } //adds the trucks with an increment that decides how many will show up if (counter == 0 || (counter % 60) == 0) { Projectiles vehicle = new Projectiles(); Projectiles vehicle2 = new Projectiles(); Projectiles vehicle3 = new Projectiles(); Projectiles vehicle4 = new Projectiles(); vehicle.Position = truckPos; vehicle.Velocity = new Vector2(10, 0); trucks.Add(vehicle); vehicle2.Position = truckPos2; vehicle2.Velocity = new Vector2(-10, 0); trucks.Add(vehicle2); vehicle3.Position = truckPos3; vehicle3.Velocity = new Vector2(8, 0); trucks2.Add(vehicle3); vehicle4.Position = truckPos4; vehicle4.Velocity = new Vector2(-8, 0); trucks2.Add(vehicle4); } //adds the cars with an increment that decides how many will show up if (counter == 0 || (counter % 120) == 0) { Projectiles vehicle5 = new Projectiles(); Projectiles vehicle6 = new Projectiles(); vehicle5.Position = carPos1; vehicle5.Velocity = new Vector2(5, 0); cars.Add(vehicle5); vehicle6.Position = carPos2; vehicle6.Velocity = new Vector2(-5, 0); cars.Add(vehicle6); } //Controls the electricity bar that megaman must pass at the end if (light == light1) { light = light2; } else { light = light1; } if (counter == 0 || (counter % 50) == 0) { if (set == 0) { if (lightning < 6) { lightning++; } else { set = 1; } } if (set == 1) { if (lightning > 0) { lightning--; } else { set = 2; } } if (set == 2) { if (lightning < 6) { lightning++; } else { lightning = 0; set = 0; } } } counter++; //reset the counter so it doesnt get infinitly big if (counter >= 400) { counter = 0; } //checks for collisions with vehicles CollisionVehicles(); //Checks if player hits lightning CollisionLightning(); //Remove vehicles from list when they hit the screen edges foreach (Projectiles p in trucks.ToArray()) { p.Position += p.Velocity; //check to if the trucks leave the screen if (p.Position.X < -edge || p.Position.X > BustinOutGame.screenWidth + edge) { trucks.RemoveAt(trucks.IndexOf(p)); } } foreach (Projectiles p in trucks2.ToArray()) { p.Position += p.Velocity; //check to if the trucks leave the screen if (p.Position.X < -edge || p.Position.X > BustinOutGame.screenWidth + edge) { trucks2.RemoveAt(trucks2.IndexOf(p)); } } foreach (Projectiles p in cars.ToArray()) { p.Position += p.Velocity; //check to if the trucks leave the screen if (p.Position.X < -edge || p.Position.X > BustinOutGame.screenWidth + edge) { cars.RemoveAt(cars.IndexOf(p)); } } //positionInText = string.Format("Position of Truck X Y: ({0:0.0}), ({1:0.0}), ({2:0:0})", collides, playerPos.Y); //positionInText2 = string.Format("Position of megaman: ({0:0.0}, {1:0.0})", playerPos.X, playerPos.Y); }
public void Update(GameTime gameTime) { ctrl.setStates(); //this if statement handles if the user selects a new volume if (ctrl.Select()) { if (option == 0) { optionX = 0; position = arrowPosition; BustinOutGame.setState(3, 1); } else if (option == 1) { soundV = 0; } else if (option == 2) { musicV = 0; } else if (option == 3) { soundV = 1; } else if (option == 4) { musicV = 1; } else if (option == 5) { musicV = 2; } UpdateImage(); } if (ctrl.Back()) { BustinOutGame.setState(3, 1); } //handles moving the pointer up if (ctrl.Up()) { if (optionY == 2 && optionX == 0) { optionY = 0; } else if (optionY == 2 && optionX == 1) { optionY = 0; optionX = 0; } else if (optionY == 2 && optionX == 2) { optionY = 0; optionX = 0; } else { optionY++; } SetOption(); } //handles moving the pointer down if (ctrl.Down()) { if (optionY == 0 && optionX == 0) { optionY = 2; } else if (optionY == 1 && optionX == 1) { optionY = 0; optionX = 0; } else if (optionY == 2 && optionX == 2) { optionY = 0; optionX = 0; } else { optionY--; } SetOption(); } //handles moving the pointer right if (ctrl.Right()) { if (optionX == 0 && optionY == 0) { //do nothing } else if ((optionX == 1 && optionY == 1) || (optionX == 2 && optionY == 2)) { optionX = 0; } else { optionX++; } SetOption(); } //handles moving the pointer left if (ctrl.Left()) { if (optionX == 0 && optionY == 0) { //do nothing } else if (optionX == 0 && optionY == 1) { optionX = 1; } else if (optionX == 0 && optionY == 2) { optionX = 2; } else { optionX--; } SetOption(); } }
public void Update(GameTime gameTime) { ctrl.setStates(); //handles if unpaused, where the game returns to if (ctrl.Back() && whereFrom == 0) { BustinOutGame.setState(4, 0); } else if (ctrl.Back() && whereFrom == 1) { BustinOutGame.setState(8, 0); } else if (ctrl.Back() && whereFrom == 2) { BustinOutGame.setState(9, 0); } if (ctrl.Down()) { if (option == 4) { option = 0; } else { option++; } } if (ctrl.Up()) { if (option == 0) { option = 4; } else { option--; } } if (ctrl.Select()) { if (option == 0 && whereFrom == 0) { BustinOutGame.setState(4, 0); } else if (option == 0 && whereFrom == 1) { BustinOutGame.setState(8, 0); } else if (option == 0 && whereFrom == 2) { BustinOutGame.setState(9, 0); } else if (option == 1) { BustinOutGame.setState(3, 0); Options.FromTitle = 1; } else if (option == 2 && whereFrom == 0) { BustinOutGame.RestartGame(whereFrom); BustinOutGame.setState(4, 0); BustinOutGame.setLevel(1); } else if (option == 2 && whereFrom == 1) { BustinOutGame.RestartGame(whereFrom); BustinOutGame.setState(8, 0); } else if (option == 3) { BustinOutGame.RestartGame(whereFrom); BustinOutGame.setState(1, 0); BustinOutGame.setLevel(0); } else { Program.gameExit(); } option = 0; } SetPosition(); }
public void Update(GameTime gameTime) { ctrl.setStates(); if (ctrl.Select()) { if (option == 0) { BustinOutGame.setState(13, 1); } else if (option == 1) { option = 0; position = arrowPosition; BustinOutGame.setState(10, 1); } else if (option == 2) { option = 0; position = arrowPosition; BustinOutGame.setState(2, 1); } else if (option == 3) { option = 0; position = arrowPosition; BustinOutGame.setState(3, 1); } else if (option == 4) { //asks if the player is sure they want to quit; screen = sure; title = false; position = arrowPosition6; option = 5; } else if (option == 5) { Program.gameExit(); } else { screen = titleScreen; position = arrowPosition; option = 0; title = true; } } if (ctrl.Up()) { if (title == true) { if (option == 0) { option = 4; } else { option--; } } else { if (option == 5) { option = 6; } else { option--; } } } if (ctrl.Down()) { if (title == true) { if (option == 4) { option = 0; } else { option++; } } else { if (option == 6) { option = 5; } else { option++; } } } if (ctrl.Exit()) { Program.game.Exit(); } SetPosition(); }
private void ManageState(GameTime gameTime) { previousState = currentState; currentState = Keyboard.GetState(); //The switch statement will handle what screen the user sees switch (mCurrentState) { case GameState.Title: { titleScreen.Update(gameTime); break; } case GameState.Hall: { hallOfFame.Update(gameTime); break; } case GameState.Options: { optScn.Update(gameTime); break; } case GameState.Controls: { control.Update(gameTime); break; } case GameState.Sounds: { sound.Update(gameTime); break; } case GameState.Graphics: { grph.Update(gameTime, graphics); break; } case GameState.MiniGames: { mini.Update(gameTime); break; } case GameState.Pause: { pause.Update(gameTime); break; } case GameState.Difficulty: { difficult.Update(gameTime); break; } case GameState.Show: { show.Update(gameTime); break; } case GameState.Pong: { game.Update(gameTime); //decrement remaining time timeRemaining -= gameTime.ElapsedGameTime; if (ctrl.Pause()) { Pause.from = 1; BustinOutGame.setState(7, 0); } break; } case GameState.Frogger: { frog.Update(gameTime); //decrement remaining time timeRemaining -= gameTime.ElapsedGameTime; if (ctrl.Pause()) { Pause.from = 2; BustinOutGame.setState(7, 0); } break; } case GameState.Playing: { //decrement remaining time timeRemaining -= gameTime.ElapsedGameTime; if (AnimatedSprite.shooting == true) { Projectiles bullet = new Projectiles(); if (AnimatedSprite.direction == 1) { bullet.Position = new Vector2((megaman.Position.X + megaman.SourceRect.Width), (megaman.Position.Y + (megaman.SourceRect.Height / 2))); bullet.Velocity = new Vector2(10, 0); bullet.bound = new Rectangle((int)bullet.Position.X, (int)bullet.Position.Y, Bullet.Width, Bullet.Height); } else { bullet.Position = new Vector2((megaman.Position.X), (megaman.Position.Y + (megaman.SourceRect.Height / 2))); bullet.Velocity = new Vector2(-10, 0); bullet.bound = new Rectangle((int)bullet.Position.X, (int)bullet.Position.Y, Bullet.Width, Bullet.Height); } LiveProjectiles.Add(bullet); } foreach (Projectiles p in LiveProjectiles.ToArray()) { p.Position += p.Velocity; //check to see when the projectile leaves the visible part of the screen if (p.Position.X < 0 || p.Position.X > graphics.GraphicsDevice.Viewport.Width || p.Position.Y < 0 || p.Position.Y > graphics.GraphicsDevice.Viewport.Height) { LiveProjectiles.RemoveAt(LiveProjectiles.IndexOf(p)); } } if (ctrl.Pause()) { Pause.from = 0; BustinOutGame.setState(7, 0); } enemies.Update(gameTime, bgNum, LiveProjectiles); break; } } }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.WhiteSmoke); spriteBatch.Begin(); spriteBatch.Draw(black, new Vector2(0, 0), Color.White); switch (mCurrentState) { case GameState.Title: { titleScreen.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Hall: { hallOfFame.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Options: { optScn.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Controls: { control.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Sounds: { sound.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.MiniGames: { mini.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Graphics: { grph.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Pause: { pause.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); DrawHud(); break; } case GameState.Difficulty: { difficult.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Show: { show.Draw(spriteBatch, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Pong: { game.Draw(spriteBatch, timeRemaining, yCorrect, this.Window.ClientBounds.Width, this.Window.ClientBounds.Height - (yCorrect * 2)); break; } case GameState.Frogger: { frog.Draw(spriteBatch, timeRemaining); break; } case GameState.Playing: { base.Draw(gameTime); spriteBatch.Draw(getBG(), new Vector2(0, 160), Color.White); //draw the correct boards if (level == 1) { board1.Draw(); if (bgNum == 0) { spriteBatch.Draw(stairs, new Vector2(30, 170), Color.White); } } else { board2.Draw(); } spriteBatch.Draw(ui, new Vector2(0, 0), Color.White); if (debugBool) { WriteDebugInformation(); } DrawHud(); //---------------------Adding Bowser-----------------------// if (bgNum == 3 && level == 1) { if (hasQuarter == true) { //bowser sees that the player has a quarter and challenges him trigger(2); //player selects continue if (ctrl.shoot() && wonPong == false) { //enable controls AnimatedSprite.controlsOn = true; interact++; //start pong game BustinOutGame.setState(8, 0); } } else { //bowser tells player to get a quarter trigger(1); //player selects continue if (ctrl.shoot()) { AnimatedSprite.controlsOn = true; interact++; } //Debug to set player as having a quarter if (ctrl.jump()) { hasQuarter = true; } } } //remove wall by stairs if pong was won if (wonPong == true) { board1.Tiles[10, 1].IsBlocked = false; board1.Tiles[10, 1].Texture = null; board1.Tiles[10, 2].IsBlocked = false; board1.Tiles[10, 2].Texture = null; board1.Tiles[10, 3].IsBlocked = false; board1.Tiles[10, 3].Texture = null; board1.Tiles[10, 4].IsBlocked = false; board1.Tiles[10, 4].Texture = null; } //---------------------End Bowser-------------------------// //draw all projectiles for (int i = 0; i < LiveProjectiles.Count; i++) { spriteBatch.Draw(Bullet, LiveProjectiles[i].Position, null, Color.White, 0f, new Vector2(Bullet.Width / 2, Bullet.Height / 2), 1f, SpriteEffects.None, 0); } //draw all enemies enemies.Draw(spriteBatch, bgNum, level); //draw megaman spriteBatch.Draw(megaman.Texture, megaman.Position, megaman.SourceRect, Color.White, 0f, megaman.Origin, 1.0f, SpriteEffects.None, 0); break; } } //adds the controls box to the menu screens if (mCurrentState == GameState.Title || mCurrentState == GameState.Hall || mCurrentState == GameState.MiniGames || mCurrentState == GameState.Options || mCurrentState == GameState.Controls || mCurrentState == GameState.Sounds || mCurrentState == GameState.Pause) { spriteBatch.Draw(viewButtons, new Vector2(350, 775), Color.White); } spriteBatch.End(); }