Challenge: Make A Cards Game
Do you know any cool card games that would be suitable to turn into a computer game? How about a solitaire game (single player) or a 2 player game where you play against the computer or a friend? To keep this project manageable just pick a 1 player or 2 player game.
To get started you’re going to need a deck of cards. Start by re-mixing this project which has a deck of cards (one sprite with a costume for each card and a costume for the back of the cards):
Re-mix this: https://scratch.mit.edu/projects/128591387/
First Challenge – Shuffle the Deck
What ways can you think of to shuffle your cards? I’m thinking a list would be useful here. You will need to create a shuffling algorithm (an algorithm is a step-by-step set of operations to perform a task). Make a demonstration of your shuffling program.
When you complete this challenge you should have the following:
- At start you should just see a single deck with no cards turned over (just the back of a card)
- When you deal a card (e.g. you could deal a card each time you press the space key) one card should be turned over – start in top right of screen the deck should remain where it is until the last card is turned over.
- Each time you press the space key again another card should be turned over. This card should be on top of the previous card but slightly to the right so that you can see what card is under it. You will need 2 rows so that you can see all the cards when all 52 are turned over. It should look something like this as the cards are being dealt out:
- Check that your cards are shuffled differently every time you run it. Make sure that there are no duplicates and no missing cards!
Next Challenge – Start planning your game
Decide on what card game you are going to create and start planning how you are going to make it. If you don’t know many card games that would be relatively straight-forward to program here are some suggestions:
Next Challenge – Set up the deal for your game
For each card game it usually starts by the dealer dealing out the initial cards. Figure out how many cards need to be dealt, whether they should be turned over or not and where on the table the cards should be placed. Use lists to keep track of what cards have been dealt.
Next Challenge – Set up the game-play
What are the rules? What is the player able to do? How does computer play to respond to the player’s move? Is there scoring?