Zmiany

Module 6 - The “Guess the NumberLogic Game” Project

Dodane 126 bajtów, 20:47, 7 lip 2015
''After the programme has been started: ''
* it displays a message telling you how to play, e.g. '''“I thought of a number between 1 and 100. Guess what number it is!”'''* it draws a number (in the range '''from 1 to 100''') and stores in a variable * it displays the words '''“Give a number” ''' and waits for the player’s '''answer'''
* it compares the player’s answer with the drawn number:
** if the number does not match
*** it checks if the number given by the player is higher than the randomly selected number
**** if it is
***** it displays the message: '''“Too high!”'''
**** otherwise
***** it displays the message '''“Too low!” '''
*** once again it prompts the player, waits for an answer and compares it with the drawn number
** if the number matches
*** it displays '''“Well done!” '''
*** it ends the script execution
''After the first algorithm version has been written down we point out that we are dealing with certain actions which will be repeated.''
'''We ask the following question:''' Which loop will work here and what should it comprise? We ask the students to find a loop block that they think fits best.
''In this case, we help students find the loop '''repeat until'''.''
[[Plik:Tip2.png|center]]
We modify the algorithm written down on the boardaccordingly and include the loop '''repeat untilin ''' '''until'''in it. The modified algorithm may look like this:
After the programme is started:
* it displays a message telling you how to play, e.g. '''“I thought of a number between 1 and 100. Guess what number it is!”'''* it draws a number (in the range '''from 1 to 100''') and stores it in a variable * it displays the words '''“Give a number” ''' and waits for the player’s '''answer'''* it '''repeats the following instructions until the player’s answer matches the randomly selected number stored in the variable''':
*** it checks if the number given by the player is greater than the randomly selected one
**** if it is
***** it displays the message: '''“Too high!”'''
**** otherwise
***** it displays the message '''“Too low!” ''' *** it displays the words '''“Give a number” ''' and waits for the player’s '''answer'''* it displays '''“Well done!” '''
* it ends the script execution
''Additionally, we tell students that they can use blocks which let them verify which number is higher, which will be useful when creating the game script.''
'''Task: ''' We ask the students to create a script in accordance with the developed algorithm, as well as to choose a suitable game background and a sprite which will communicate with the player.
Sample script may look as follows:
[[Plik:A6.pngjpg|center]]
Jaś’s script:
181
edycji