Connect 4
- Ask if the user wants to play connect 4. The user input must be either 0 to quit or 1 to play. If the user enters anything else, display a message saying invalid input and keep asking until a valid input is given using a while loop.
- If the input is 1, display a welcome message and continue to the next step. If the input is 0, display a goodbye message and end the game.
- Ask for player 1 and player 2 name and store them in player_1 and player_2.
- Create the board for the game using the simple game engine
- Create three different variables to hold the two different chips and one to keep track of empty spots.
- Display the board created (empty) which is 6 x 7.
- Create two more variables; color and winner to keep track of each player’s color and keep track if a winning situation is found or the board is full.
- Using get mouse input function have player 1 choose the location.
- If the first choice is not in row 6, show an error message and tell the user to click in row 6 for their choice.
- Once the player 1 makes select a spot, display a red chip in that spot and display the board with the added chip.
- Set up a while loop with the condition of winner == 0 which is simply no winner has been determined.
- Check if color is 1 which is color for red chip and player 1. If it is true, go the next step. If not go to step 16.
- Allow player 1 to choose a position on the grid.
- Check if the position is empty using the empty_sprite. If it is, show an error message saying “choose an empty sprite”. If not go to the next step.
- Using switch statements, determine the lowest possible location for the chip and drop the chip in that location and draw the board/scene.
- Then assign a color to 0 to make sure next time is player 2 (black chip) turn. The following if statement will assign color back to 1 to get back to player 1 (red chip) turn as well.
- Set up four for loop to check whether the horizontal, vertical, and two diagonal directions have four consecutive patterns.
- Once the chips of a certain color meet the conditions, set winner == 1 and jump out of while loop and display a message to show the winner is born.
- The last if statement represents a special condition, where the board is full of chips but no winner appears. The game ends with a draw.
MEMORY
- Display a welcome message and ask if the user wants to play the memory game.
- Store the input in playedBefore variable.
- Using a while loop to check if the input is anything other than 0 (user doesn’t know how to play) or 1 (user knows how to play the game). If it is, keep asking until a valid input is given. If not continue to the next step.
- If the input is 0, display the rules and add pause so that the user has a chance to read and understand the rules. Then continue to the next step. If the input is 1, go to the next step.
- Create a scene using a simple game engine.
- Create variable empty_sprite to be used for vector creation.
- card_spritesFace holds a vector for cards.
- Create a counter to be used while creating cards.
- Using a while loop, create 52 cards (backFace).
- Create 4 rows with 13 cards.
- Create a variable cardDuplicate to flip the wrong guess back to face down
- Create numGuesses to keep track of the number of guesses.
- Create a vector with 52 cards.
- Create two different vectors and randomize it with the first 26 cards.
- Join both vectors and display the board.
- Using a while loop with conditions endLoop ~= 52 allow user to start clicking on cards.
- The user selects one card. Then the user selects another card.
- If user clicks on a card that is already face-up show an error message and tell them to choose another card.
- When user selects two cards, check if the value of each card is the same. If they are the same, go to the next step. If not, display a message “not a match try again” and turn the cards back face down and increment numGuess and go back to step 17.
- Show a message saying you found a match and increment numGuess by 1 and keep those two cards face up. Then go to step 17 and the process is repeated until all cards are face up.
- When all cards are face-up, display a message saying “you won the game, congrats”.
- Then display the numGuesses.
Hi-Low Seven
- Display a message asking the user if they have played over/under seven before.
- If the user inputs an invalid response, display a message saying “Invalid input, you must enter 0 or 1!”, If not, go on to Step 3.
- If the player inputs yes they have played before, go to Step 5, If they input no they have not played before, go to Step 4.
- Display a message explaining the rules of Over/Under Seven.
- Display a message with the amount of money the player has to bet.
- Display a message asking if the user wants to play
- If the user wants to play, go to Step 8, If the user does not want to play, display a message saying, “Maybe next time. Goodbye!”.
- Display a message asking the user to input an amount to bet.
- If the user inputs a valid bet, go to Step 10, if the user inputs an invalid bet, display a message saying, “Your bet must be between 0 and 100 dollars” and go back to Step 8.
- Ask the user if they want to place their bet on High, Low, or sevens.
- Generate a sum for two randomly rolled die.
- Display a message saying what the sum of the two dies is.
- If the player’s bet High (>7), Low (<7), or Sevens (=7) matches the sum of the die, display a message saying “You won (bet amount) dollars”, if the players bet does not match the sum of the die, display a message saying “You lost (bet amount) dollars”. Go to Step 16.
- If the user bets Sevens and the sum of the dice is 7, then the user’s earnings are the bet amount multiplied by 4.
- If the player earns money to add it to their total and if the user loses money subtract the amount from their total.
- Ask the user if they want to play again.
- If the user inputs yes, go to Step 8, if the user inputs no, display a message saying “Thank you for playing. Goodbye!”.
- If a player runs out of money, display a message saying “You ran out of money! Better luck next time!”.
- End