Scratch Math Game Project Guide
Scratch Math Game Project Guide
In the Scratch project, a variable named questionCount is created to manage the flow of questions. It is initialized to 1 whenever the green flag is clicked, ensuring a fresh start for counting questions. The variable is incremented by 1 after each question is processed, enabling the program to cycle through questions 1 to 4 before stopping .
Broadcast messages are directly linked to sprite groups by naming conventions that correspond with question answers. Each group of trash sprites (e.g., trash1.y) is programmed to respond to a specific broadcast message triggered by the GameMaster (e.g., removeTrash1). When the appropriate message is received, the designated sprite group uses the Look block to execute hide, effectively removing themselves from the stage .
Broadcasting in the Scratch project serves to synchronize and trigger events in response to specific conditions. For each correct answer, the GameMaster broadcasts a unique message (e.g., removeTrash1), which is received by specific groups of trash sprites, prompting them to hide. This mechanism allows for coordinated and conditional actions based on game state changes .
To reset the visibility of all trash sprites at the start of a new game session, a block sequence is added to each trash sprite that contains a when green flag clicked followed by a show block. This ensures that when the green flag is clicked, all trash sprites are made visible again, resetting their state for the new session .
To open and set up the 'Do the Math' project in Scratch, start by opening the Scratch application and download the file Do the Math.zip from the Downloadables section. Extract the file to reveal a folder named Do the Math. Open Scratch, click File ► Open in the Menu, navigate to the Do the Math folder, select the necessary project file, and click OK to open it .
The progression through different questions is controlled by a variable called questionCount, which initializes at 1 when the green flag is clicked. A loop with a condition that tests if questionCount is greater than 0 and less than 5 is used to iterate through the questions. After each question, the questionCount is incremented by 1 to move to the next question .
Upon correctly answering a question, the GameMaster sprite uses a broadcast block to send a message specific to the question (e.g., removeTrash1 for the first question). This message is received by the corresponding group of trash sprites, triggering them to execute the Looks block hide, making those sprites disappear from the stage .
The feedback mechanism involves visual and timing responses using the Looks block. For a correct answer, the GameMaster says 'Correct!' for 2 seconds and triggers a broadcast message after 0.5 seconds to remove corresponding trash. For incorrect answers, the message 'Your answer is incorrect' is displayed for 2 seconds with no further actions triggered, highlighting the feedback loop dependence on conditional checks .
User input is handled by Sensing blocks, which ask specific mathematical questions and wait for input. The responses are checked using If else statements where each If condition tests if the answer is correct. Correct inputs trigger a 'Correct' message and corresponding events (e.g., broadcasting to make trash disappear); incorrect inputs prompt 'Your answer is incorrect' without triggering any broadcast .
The GameMaster uses an If else block to evaluate user inputs against the correct answer for each question. For every question, a specific condition (e.g., answer=100 for the first question) is set within the If block. If the user's input matches the condition, the GameMaster uses the Looks block say [ ] to display 'Correct'. If the condition is not met, the else statement prompts the Looks block to say 'Your answer is incorrect' .