protected override void Draw(GameTime gameTime) { if ((GameStatus == GameState.Playing) || (GameStatus == GameState.Pause)) { GraphicsDevice.Clear(Color.CornflowerBlue); World.Draw(Location); World.Draw(new Vector2(Camera.CameraPositionX, Camera.CameraPositionY)); MarioSprite.Draw(SpriteBatch, new Vector2(Mario.LocationX - Camera.CameraPositionX, Mario.LocationY)); PlayerStat.Draw(new Vector2(Camera.CameraPositionX, Camera.CameraPositionY)); foreach (MarioFireball aFireball in Game1.Mfireballs) { aFireball.Draw(SpriteBatch); } if (Mario.GodStatus) { SpriteBatch.Begin(); SpriteBatch.Draw(blackHole, new Vector2(MouseState.X - 20, MouseState.Y - 20), Color.White); SpriteBatch.End(); } base.Draw(gameTime); } else if (GameStatus == GameState.LivesScreen) { DisableControl = true; MediaPlayer.Stop(); continueTimer += gameTime.ElapsedGameTime.Milliseconds; if (continueTimer > 2500) { continueTimer -= 2500; GameStatus = GameState.Playing; MediaPlayer.Play(BackgroundMusic); DisableControl = false; } GraphicsDevice.Clear(Color.Black); PlayerStat.Draw(new Vector2(Camera.CameraPositionX, Camera.CameraPositionY)); MarioSprite.Draw(SpriteBatch, new Vector2(250, 200)); } else if (GameStatus == GameState.End) { DisableControl = true; MediaPlayer.Stop(); if (!playSound) { Game1Utility.GameOverSoundEffect.Play(); playSound = true; } GraphicsDevice.Clear(Color.Black); PlayerStat.Draw(new Vector2(Camera.CameraPositionX, Camera.CameraPositionY)); } }
public FeedbackLayer(GraphicsDeviceManager graphics) { Player = ""; Graphics = graphics; Font = Game1.ContentLoad.Load <SpriteFont>("File"); Time = 400; Scores = 0; Coins = 0; Lives = 3; coinsprite = new Coin(new Vector2(360, 80)); playertexture = Game1.ContentLoad.Load <Texture2D>("StandardMario/RightIdle"); mario = new MarioSprite(playertexture, false, 1, 1, new Vector2(540, 115)); }
protected override void Update(GameTime gameTime) { newKeyboardState = Keyboard.GetState(); newGamepadState = GamePad.GetState(PlayerIndex.One); MouseState = Mouse.GetState(); if ((newKeyboardState.IsKeyDown(Keys.P) && oldKeyboardState.IsKeyUp(Keys.P)) || newGamepadState.IsButtonDown(Buttons.Start) && oldGamepadState.IsButtonUp(Buttons.Start)) { if (GameStatus == GameState.Pause) { MediaPlayer.Resume(); GameStatus = GameState.Playing; pauseSoundEffect.Play(); } else if (GameStatus == GameState.Playing) { MediaPlayer.Pause(); GameStatus = GameState.Pause; pauseSoundEffect.Play(); } } if ((newKeyboardState.IsKeyDown(Keys.M) && oldKeyboardState.IsKeyUp(Keys.M))) { MouseControl = !MouseControl; IsMouseVisible = !IsMouseVisible; } Cheat.Update(oldKeyboardState, newKeyboardState); oldKeyboardState = newKeyboardState; oldGamepadState = newGamepadState; if (GameStatus == GameState.Playing) { this.GameTime = gameTime; if (!DisableControl) { KeyboardController.Update(); GamepadController.Update(); MouseController.Update(); CameraPointer.UpdateX(Mario.LocationX); } MarioSprite.Update(gameTime); World.Update(gameTime); Collision_Detection_and_Responses.CollisionHandling.Update(World.Level, this); PlayerStat.Update(gameTime); base.Update(gameTime); } }
private void CollectItem(ICollectable pu) { MarioSprite mSprite = sprite as MarioSprite; if (pu is Fireflower && State != MarioState.Fire) { mSprite.SetTransitionStates(MarioState.Fire); PowerUpTimer = 80; State = MarioState.Fire; } else if (pu is TNTPowerUp && State != MarioState.TNT) { mSprite.SetTransitionStates(MarioState.TNT); PowerUpTimer = 80; State = MarioState.TNT; } else if (pu is Gun && State != MarioState.Gun) { mSprite.SetTransitionStates(MarioState.Gun); PowerUpTimer = 90; State = MarioState.Gun; } else if (pu is Mushroom && State < MarioState.Big) { mSprite.SetTransitionStates(MarioState.Big); PowerUpTimer = 80; State = MarioState.Big; } else if (pu is Star) { StarTimer = 600; } else if (pu is Coin) { world.CollectCoin(pu as Coin); } else if (pu is OneUp) { world.Lives++; } pu.Kill(); }
public Sprite BuildSprite(Mario sprite, Vector2 location) //finding the Sprite corresponding to the enum. { Sprite toReturn = null; switch (sprite) { case Mario.Dead: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/DeadMario"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftIdlingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/LeftIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftIdlingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/LeftIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftIdlingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/LeftIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftIdlingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/LIdle"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } case Mario.RightIdlingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/RightIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightIdlingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/RightIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightIdlingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/RightIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightIdlingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/RIdle"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } case Mario.LeftCrouchingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/LeftIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftCrouchingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/LeftCrouching"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftCrouchingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/LeftCrouching"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftCrouchingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/LCrouch"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } case Mario.RightCrouchingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/RightIdle"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightCrouchingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/RightCrouching"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightCrouchingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/RightCrouching"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightCrouchingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/RCrouch"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } case Mario.LeftRunningSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/LeftMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.LeftRunningFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/LeftMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.LeftRunningBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/LeftMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.LeftRunningIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/LMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.RightRunningSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/RightMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.RightRunningFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/RightMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.RightRunningBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/RightMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.RightRunningIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/RMoving"); toReturn = new MarioSprite(product, true, 1, 4, location); break; } case Mario.LeftJumpingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/LeftJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftJumpingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/LeftJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftJumpingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/LeftJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.LeftJumpingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/LJump"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } case Mario.RightJumpingSm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("StandardMario/RightJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightJumpingFm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("FireMario/RightJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightJumpingBm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("SuperMario/RightJumping"); toReturn = new MarioSprite(product, false, 1, 1, location); break; } case Mario.RightJumpingIm: { Texture2D product = Game1.ContentLoad.Load <Texture2D>("InvincibleMario/RJump"); toReturn = new MarioSprite(product, true, 1, 2, location); break; } } return(toReturn); }