public void Update() { // If the game timer surpasses the timer, the game ends. Otherwise, the timer is updated. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.LostGame(); } else { Globals.GameDuration.UpdateCooldown(); } // If the player inputs the correct key, the game progresses. Otherwise, they lose. if (Globals.CheckKey(Globals.GetFirstLetter(ReversedWord))) { Game1.hitSnd.CreateInstance().Play(); if (ReversedWord.Length == 1) { MinigameSelection.WonGame(); } else { ReversedWord = ReversedWord.Substring(1); Blanks += "_"; } } else if (Globals.IsWrongKey(Globals.GetFirstLetter(ReversedWord))) { MinigameSelection.LostGame(); } }
public void Update() { // If the game timer surpasses the timer, the game ends. Otherwise, the timer is updated. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.LostGame(); } else { Globals.GameDuration.UpdateCooldown(); } // Checks if each of the circles have been clicked for (int i = 0; i < ColorCircles.Count(); i++) { if (ColorCircles[i].CheckButton()) { // If it is incorrect, the player loses. Otherwise, the player wins. if (!ColorCircles[i].Correct) { MinigameSelection.LostGame(); } else { MinigameSelection.WonGame(); } } } }
public void Update() { // If the game timer surpasses the timer, the game ends. Otherwise, the timer is updated. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.WonGame(); } else { Globals.GameDuration.UpdateCooldown(); } // Moves the ball and the player Ball.Move(); Globals.Player.PlayerMovement(); // If the ball touches any of the boundaries, it bounces off if (Ball.CheckCollision(Globals.Player.GetRec()) || Ball.Pos.Y <= 0) { Ball.Vel.Y *= -1; Game1.bounceSnd.CreateInstance().Play(); } else if (Ball.Pos.X + Ball.Size.X >= Globals.ScreenWidth || Ball.Pos.X <= 0) { Ball.Vel.X *= -1; Game1.bounceSnd.CreateInstance().Play(); } // If the ball reaches the ground, the game ends if (Ball.Pos.Y + Ball.Size.Y >= Globals.ScreenHeight) { MinigameSelection.LostGame(); } }
/// <summary> /// Pre: n/a /// Post: n/a /// Description: Shortens the word. /// </summary> public void ShortenWord() { // If the word has only one letter left, the game ends. Otherwise, it is shortened and a blank is added to the progress. if (Word.Length == 1) { MinigameSelection.WonGame(); } else { Word = Word.Substring(1); WordProgress += "_"; } }
public void Update() { // If the player runs out of time, the game ends. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.WonGame(); } else { Globals.GameDuration.UpdateCooldown(); } Globals.Player.PlayerMovement(); // If the cooldown for riandrop spawning is met, a new raindrop is spawned if (RaindropCd.CheckCooldown()) { Projectiles.Add(new Projectile ( // Spawns at a random X location new Vector2(Globals.Rng.Next(0, Globals.ScreenWidth), 0), // No X velocity, Y velocity of 5 new Vector2(0, 5), // Each raindrop is 10x20 new Vector2(10, 20)) ); } else { RaindropCd.UpdateCooldown(); } // Moves each of the raindrops. If it touches the player, the game ends for (int i = 0; i < Projectiles.Count; i++) { Projectiles[i].Move(); if (Projectiles[i].CheckCollision(Globals.Player.GetRec())) { MinigameSelection.LostGame(); break; } } }
public void Update() { // If the game timer surpasses the timer, the game ends. Otherwise, the timer is updated. if (Duration.CheckCooldown()) { MinigameSelection.LostGame(); } else { Duration.UpdateCooldown(); } // The diameter increases by the growth rate DiameterGrowth += DiameterGrowthRate; // Produces a new button with the updated diameter Btn = new Button(Game1.blankCircleImg, new Rectangle((int)StartLoc.X - (int)DiameterGrowth / 2, (int)StartLoc.Y - (int)DiameterGrowth / 2, Diameter + (int)DiameterGrowth, Diameter + (int)DiameterGrowth)); }
/// <summary> /// Pre: typewriterKeys as the row of keys /// Post: n/a /// Description: Checks each of the keys in a row to see if it has been pressed. /// </summary> /// <param name="typewriterKeys"></param> public void CheckKeyRow(List <TypewriterKey> typewriterKeys) { foreach (TypewriterKey key in typewriterKeys) { if (key.KeyButton.CheckButton()) { // If the key is the first letter of the word, the word is shortened. Otherwise, the player loses. if (key.Letter == FirstLetter) { ShortenWord(); Game1.hitSnd.CreateInstance().Play(); } else { MinigameSelection.LostGame(); } } } }
public void Update() { // If the player runs out of time, they lose if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.LostGame(); } else { Globals.GameDuration.UpdateCooldown(); } // Gets the first letter of the word FirstLetter = Word[0]; // Checks each of the rows of keys CheckKeyRow(FirstRowKeys); CheckKeyRow(SecondRowKeys); CheckKeyRow(ThirdRowKeys); }
public void Update() { // If the player runs out of time, they lose. Otherwise, the timer is updated. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.WonGame(); } else { Globals.GameDuration.UpdateCooldown(); } Globals.Player.PlayerMovement(); // Moves each of the spikes. If they go off the screen, they are removed. If they touch the player, the game ends. for (int i = 0; i < Spikes.Count; i++) { Spikes[i].Move(); if (Spikes[i].Y < 0) { Spikes.RemoveAt(i); i--; } else if (Spikes[i].CheckPlayer()) { MinigameSelection.LostGame(); break; } } // If the spawn cooldown is met, a spike is spawned. Otherwise, the cooldown is updated. if (SpikeSpawnCd.CheckCooldown()) { Spikes.Add(new SideSpike()); } else { SpikeSpawnCd.UpdateCooldown(); } }
public static void Update() { // If the player presses the start button in practice mode, it returns to the menu screen. if (StartBtn.CheckButton()) { if (Globals.Practice) { Globals.Fade.Start(Globals.MENU, 1); } else { // If the player's health is now at 0, the game ends and they are sent to the results screen. Otherwise, the next game starts. if (Globals.Health == 0) { Globals.Fade.Start(Globals.RESULTS, 1); } else { MinigameSelection.NextGame(); } } } }
public void Update() { // If the game timer surpasses the timer, the game ends. Otherwise, the timer is updated. if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.WonGame(); } else { Globals.GameDuration.UpdateCooldown(); } // If the circle spawn cooldown is met, a new circle is spawned. Otherwise, the timer is updated. if (CircleSpawnCd.CheckCooldown()) { Circles.Add(new Circle()); } else { CircleSpawnCd.UpdateCooldown(); } // Checks each of the circles for if they are being clicked for (int i = 0; i < Circles.Count; i++) { // If the player has clicked on the circle, it is removed. Otherwise, the circle is updated. if (Circles[i].Btn.CheckButton()) { Circles.RemoveAt(i); i--; } else { Circles[i].Update(); } } }
public void Update() { // If the player has filled the distance bar, they move on. If they run out of time, they lose. Otherwise, the timer is updated. if (DistanceTravelled > DistanceNeeded) { MinigameSelection.WonGame(); } else if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.LostGame(); } else { Globals.GameDuration.UpdateCooldown(); } // If the jug is not currently held and the player clicks on it, it becomes held. Otherwise, the movement of the jug is checked. if (!JugHeld && Jug.CheckButton()) { JugHeld = true; } else if (JugHeld) { // If the player lets go of the jug, they no longer hold it. Otherwise, the distance travelled is updated and the jug is moved. if (Globals.MouseCurrent.LeftButton != ButtonState.Pressed) { JugHeld = false; } else { JugDistanceMoved = new Vector2(Globals.MouseCurrent.X - Globals.MousePast.X, Globals.MouseCurrent.Y - Globals.MousePast.Y); DistanceTravelled += Math.Abs(JugDistanceMoved.Y); Jug = new Button(Game1.blankRecImg, new Rectangle((int)(Jug.Rec.X + JugDistanceMoved.X), (int)(Jug.Rec.Y + JugDistanceMoved.Y), (int)JugSize.X, (int)JugSize.Y)); } } }
public void Update() { // Player wins if he survives for the length of the game, and loses if they touch the lava if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.WonGame(); } else if (Globals.Player.CheckCollision(Lava)) { MinigameSelection.LostGame(); } else { Globals.GameDuration.UpdateCooldown(); } // If the player is in the air (indicated by a non-zero Y velocity), it is indicated and their velocity is increased by gravity if (Globals.Player.Vel.Y != 0) { Globals.Player.Vel.Y += Gravity; PlayerInAir = true; } // Sets IsOnPlatform to false, which is checked right after IsOnPlatform = false; // Goes through each platform // If the player is in the air and they touch a platform, it is now indicated that they are on a platform, no longer in the air, and their Y velocity is reset // If the player is in the air and they touch a platform, their Y velocity is reset and it is indicated // Otherwise, if the platform touches the lava, it disappears for (int i = 0; i < Platforms.Count; i++) { if (PlayerInAir && Globals.Player.CheckPlatformCollision(Platforms[i])) { IsOnPlatform = true; PlayerInAir = false; Globals.Player.Vel.Y = 0; } else if (Globals.Player.CheckOnPlatform(Platforms[i])) { Globals.Player.Vel.Y = 0; IsOnPlatform = true; } else if (Platforms[i].Y > Lava.Y) { Platforms.RemoveAt(i); i++; } } // If the player is not on a platform and they are not in the air, they begin falling (Y velocity has to be set to .001f so it is not zero) if (!IsOnPlatform && !PlayerInAir) { PlayerInAir = true; Globals.Player.Vel.Y = .001f; } // Moves player, platforms, and lava Globals.Player.PlayerMovement(); for (int i = 0; i < Platforms.Count; i++) { Platforms[i] = MovePlatform(Platforms[i], (int)Globals.Player.Vel.Y); } MoveLava(); // If the player's velocity is below 0 (going up), the CurrentY increases (you must subtract since the Y velocity is negative) if (Globals.Player.Vel.Y < 0) { CurrentY -= (int)Globals.Player.Vel.Y; } // If the CurrentY is greater than ExploredY, it is updated if (CurrentY > ExploredY) { ExploredY = CurrentY; } // Checks if the player has moved enough to spawn another platform, and spawns a new platform if so if (ExploredY > LastPlatformSpawn + PlatformSpawnInterval) { SpawnPlatforms(); LastPlatformSpawn = ExploredY; } }
public void Update() { // If the player has collected enough coins to win, the player moves on. Otherwise, they lose. if (Collected >= Goal) { MinigameSelection.WonGame(); } else if (Globals.GameDuration.CheckCooldown()) { MinigameSelection.LostGame(); } // The player moves Globals.Player.PlayerMovement(); // If the gold spawn cooldown is met, two coins are spawned on each side. Otherwise, the cooldown is updated. if (GoldCd.CheckCooldown()) { // Left coin Coins.Add(new Projectile ( // Spawns at X of 0, a Y value between 0 (top of the screen) and 2/3 of the screen's height new Vector2(0, Globals.Rng.Next(0, (int)((2.0 / 3.0) * Globals.ScreenHeight))), // An X range is chosen between the range, Y velocity starts at 0 new Vector2(Globals.Rng.Next((int)VelocityXRange.X, (int)VelocityXRange.Y), 0), // Size is 30x30 new Vector2(30, 30)) ); // Right Coin Coins.Add(new Projectile ( // Spawns at the right of the screen instead new Vector2(Globals.ScreenWidth - 50, Globals.Rng.Next(0, (int)(2.0 / 3.0 * Globals.ScreenHeight))), // Makes the velocity negative, as it is travelling left new Vector2(-1 * Globals.Rng.Next((int)VelocityXRange.X, (int)VelocityXRange.Y), 0), new Vector2(30, 30)) ); } else { GoldCd.UpdateCooldown(); } // Moves each of the coins. If the coin collides with the player, it is removed and the amount is collected. If it touches the ground, it is just removed. for (int i = 0; i < Coins.Count; i++) { Coins[i].Move(); if (Coins[i].CheckCollision(Globals.Player.GetRec())) { Collected++; Game1.coinSnd.CreateInstance().Play(); Coins.RemoveAt(i); i--; continue; } else if (Coins[i].CheckBoundaries()) { Coins.RemoveAt(i); i--; continue; } } Globals.GameDuration.UpdateCooldown(); }
public static void Update() { switch (Screen) { case START: { // Checks each of the buttons on the start screen if (StartBtn.CheckButton()) { Screen = DIFFICULTY; } else if (PracticeBtn.CheckButton()) { Screen = PRACTICE; Globals.Difficulty = Globals.MEDIUM; } else if (LeaderboardBtn.CheckButton()) { Globals.Gamestate = Globals.LEADERBOARD; } else if (HelpBtn.CheckButton()) { Screen = HELP; } break; } case PRACTICE: { // Checks the button for each of the practice games. If it is clicked, it starts the game. for (int i = 0; i < PracticeGames.Count; i++) { if (PracticeGames[i].CheckButton()) { MinigameSelection.StartPractice(i); Globals.Fade.Start(Globals.GAMEPLAY, 1); break; } } // Difficulty changing buttons if (IncDifficultyBtn.CheckButton() && Globals.Difficulty != Globals.HARD) { Globals.Difficulty++; } else if (DecDifficultyBtn.CheckButton() && Globals.Difficulty != Globals.EASY) { Globals.Difficulty--; } // Back button if (BackBtn.CheckButton()) { Screen = START; } break; } case DIFFICULTY: { // Checks each of the difficulty buttons, and starts the game with the corresponding difficulty if (EasyBtn.CheckButton()) { Globals.Fade.Start(Globals.GAMEPLAY, 1); MinigameSelection.NextGame(); Globals.Difficulty = Globals.EASY; MinigameSelection.Reset(); } else if (MediumBtn.CheckButton()) { Globals.Fade.Start(Globals.GAMEPLAY, 1); MinigameSelection.NextGame(); Globals.Difficulty = Globals.MEDIUM; MinigameSelection.Reset(); } else if (HardBtn.CheckButton()) { Globals.Fade.Start(Globals.GAMEPLAY, 1); MinigameSelection.NextGame(); Globals.Difficulty = Globals.HARD; MinigameSelection.Reset(); } else if (BackBtn.CheckButton()) { Screen = START; } break; } case HELP: { // Back button if (BackBtn.CheckButton()) { Screen = START; } break; } } }