Skip to Main Content

C'est qui?: Home

Assets

Fais ceci en premier (Do this first)

  1. Download the file below. It contains the pictures you need for the game
  2. Unzip the file to your H:\ drive
    1. Open it up
    2. Click 'extract all files'

Instructions

Veuillez lire attentivement et entièrement les instructions suivantes .  (Please read the instructions carefully and completely)

You will be creating a "C'est qui?" game using

The game will present the player with 3 faces then says a phrase in French. The player needs to write which person would have said the phrase. If the player gets it right, they score a point.

Part 1 - Creating the basic sprite

  1. Open up scratch using the link above.
  2. Delete Scratch Cat
  3. Create a new sprite using 'Paint New Sprite' () and then click on 'Upload Costume From File' ()
    • Open the folder where you extracted the pictures earlier
    • Select all the pictures (click on one and then use Ctrl+A to select the rest) and choose open
    • Delete the blank costume that is at number 1 on the list
  4. You should now have a sprite with 24 costumes - one for each of the pictures
    • Note: Each of these costumes is named and we can fetch up that name using the sensing block (costume name of [Sprite1])
  5. Duplicate the sprite 3 times. Later on the initial sprite (Sprite1) will be hidden and will let us create our list of costumes when we need it. The other 3 will be the ones that the player sees and chooses between.

Part 2 - About the game structure

  • This section describes how the game is going to work. You don't code anything in this section.
  1. A lot of the game involves using something called a list
    • A list is a lot like a list of verbs, or a grocery list, or a list of all your unfinished homework
    • A list has 'items' - things that are on the list
    • A list has an order to it
    • A list has a length
  2. We are going to have a lot of lists.
    • A list of phrases
    • A list of answers to who could have said each phrase (named in French)
    • A list that is everyone who is not an answer for the phrase you are using
  3. We are also going to have a bunch of variables
    • score - A score
    • pickedPhrase - Which phrase we are asking
    • pickedAnswer - Which number in the list of answers we pick from the phrase
    • pickedName - Which item in the list of answers we picked (based on the number above)
    • pickedWho - Which of our 3 contestants said the phrase
    • randomCostume1, randomCostume2 - Who the other 2 people are

Now this all probably sounds complicated, but the basic structure is actually pretty simple

Part 3 - Creating the structure - In the backdrop

  • For this part we will be looking at how to create the basic structure. Once we have gone over that for this demo phrase (which will not be allowed to count towards your mark) you will be on your own to create the rest.
    1. Start by creating a new list. Call it Phrases
      1. Add an item to the list ("Je suis blond")
      2. Uncheck it on the data screen to make it disappear from the screen
    2. Create a new list. Call it blond
      1. Look at the sprites costumes. Add all the people that fit that phrase to the list. Remember to copy the name of the costume exactly. All the costumes use lowercase names. Think about whether blond is masculine or feminine.
      2. Uncheck it on the data screen to make it disappear from the screen
    3. Create a list called EveryoneElse.
      1. Leave it blank.
      2. Uncheck it on the data screen to make it disappear from the screen
    4. Create all the variables listed in Part 2
      1. On the data tab uncheck each variable to make it disappear from the screen. We don't need them at the moment and they will clutter your screen up.
    5. Go to the backdrop
    6. Use 'when the green flag is clicked'
    7. Set all of your variables to 0
    8. Use delete (all) of [EveryoneElse] to make sure that we start with a clean list for this each time.
  • Now comes the actual structure.
  • We need to pick a phrase from our list of phrases randomly:
    • We can only pick a phrase between 1 and the length of the list of phrases
    • We will do this using "set pickedPhrase to [0]"
    • Then using "pick random (1) to (10)" connect it to the block you just put in over the [0]
    • The biggest number we want to pick should be the size of the list. So we will use the 'length of [Phrases]' block
    • Our final code should look like: "set [pickedPhrase] to (pick random (1) to (length of [Phrases]))"
  • We also need to pick which of our 3 faces will be the correct answer (which will also make the other two automatically incorrect, we don't have to spell it out:
    • What would the code be for picking which face will be the correct one? It should be a single line using two separate blocks and is similar to the code we used above
    • One is a "Set" block
    • One is a "Pick random" block
  • Next we need to use a broadcast to let the sprite know we are ready to choose a costume.
    • Use the 'broadcast and wait' block. Call the broadcast ChangeCostume

Part 4 - Creating the structure - In Sprite1

  • Now we are ready to go over to the sprite and code the basic structure over there
    1. Click on the sprite and go to its script
    2. Start off with the block 'When I receive [ChangeCostume]'
  •  This next structure is almost identical for each phrase you want to use. Remember this because it will make your life easier
  • Here are the instructions in Plain English:
    • We will use an if-then-else statement -
    • The aim here is to choose who from the list of our answers is going to appear as the 'correct answer'
      • We don't want to accidentally have two possible people for the same phrase to appear.
      • So we also want to create the list of everyone who isn't a possible correct answer.
    • If the pickedPhrase is the first phrase on the list then we can create the list of costumes and make our selection.
    • If the pickedPhrase is not the first phrase on the list we need to see if it's the second, or the third, and so on.
  • The code for each phrase is the same, except for which list of answers you are checking.
  • // means a comment you don't code these.
  • Irritatingly you can't create the sensing block inside Sprite1.To make this go to another sprite, create the block and then drag it into Sprite1.
  • Here's the pseudocode

          if  <(pickedPhrase) = [1]> then

              // Choose one person from the list of people who are masculine blond at random

              set [pickedAnswer] to (pick random (1) to (length of [blond]))

              set [pickedName] to (item (pickedAnswer) of [blond])

              // This next section will fill the EveryoneElse list with the names of those who aren't blond

              // There are 24 costumes so we need to do this 24 times

              repeat (24) times

                  // Check if the current costume is one of the ones that is blond

                  If <[blond] contains (costume name of Sprite1)> then

                      // If it is, don't add it to the list, just move on to the next costume

                      next costume

                  else

                      // If it isn't, add it to the list then move on to the next costume

                      add (costume name of Sprite1) to [EveryoneElse]

                      next costume

          else

              // Leave this blank right now

  • Here are the next instructions in plain English:
    • After all the if-then-elses for each phrase we can choose our other costumes.
    • At this point EveryoneElse contains a list of all the costumes that don't match the answers in blond (or whatever answer we are seeking to avoid)
    • We also want to avoid setting the two random people to the same costume. So we are going to randomly select costumes until we get two that aren't the same
  • Here's the pseudocode:

          repeat until <not<(randomCostume1) = (randomCostume2)>>

              set [randomCostume1] to (pick random (1) to (length of [EveryoneElse]))

              set [randomCostume2] to (pick random (1) to (length of [EveryoneElse]))

  • Finally we want to trigger the other 2 sprites to change to their random costumes. We will do that using a broadcast of a message called 'Randomize'

Part 5 - Creating the structure - In Sprite2, Sprite3, and Sprite4

  • We start off with the 'when I receive Randomize' block
  • Sprite2 and Sprite4 have two choices, and Sprite 3 has a third.
  • Basically
    • If Sprite is chosen to be the correct answer, switch it's costume to the correct answer
    • if the sprite is not chosen to be the correct answer, switch it's costume to one of the random answers. See the table below to get an idea of how that will work.

Which variable should be used to select the costume

Sprite2 Sprite3 Sprite4
Sprite2 is correct (pickWho = 1) pickedName randomCostume1 randomCostume2
Sprite3 is correct (pickWho = 2) randomCostume1 pickedName randomCostume2
Sprite4 is correct (pickWho = 3) randomCostume1 randomCostume2 pickedName
  • Hopefully it is obvious from the table why Sprite3 works differently. If Sprite2 is correct then Sprite3 is the first random one, but if Sprite4 is correct then Sprite2 is the first random one. Sprite2 and Sprite4 always use the same randomCostume when they are the randomly selected one.
  • Here's the pseudocode for Sprite2:

          // if we are changing the first visible sprite (Sprite 2) to the correct answer

          if <(pickWho) = 1> then

              // Change to the correct answer

              switch costume to (pickName)

          else

              // Switch to whichever random costume we decided on

              switch costume to (item (randomCostume1) of [EveryoneElse])

Part 6 - Creating the structure - In the backdrop (again)

  • Go back to the backdrop
  • Now that the costumes have been randomly selected including our answer, it's time to ask the phrase
  • Under the broadcast [ChangeCostume] and wait block is where the next chunk of code will go. Here's the pseudocode for it:

          ask (item (pickedPhrase) of [Phrases]) and wait

          if <(answer) = (pickedName)> then

               // Do whatever you want to happen when they guess right

          else

               // Do whatever you want to happen when they guess wrong

  • To make a game picking a phrase and displaying it is going to have to happen several times so we will be using a 'repeat (x)'  block to go around everything after setting the variables to 0.
  • Now the basic structure is complete. Hi-5 yourself!
  • From here on out things get A LOT easier in terms of coding, and A LOT harder in terms of French
    • You need to add more than 1 question (remember this first one doesn't count)
    • Create some instructions that display at the start of the game (in French)
  • Now that you have the basic structure it's over to you to complete the game and add any additional features you want.
  • Please see the tab at the top for adding plurals