Zmiany

Skocz do: nawigacji, wyszukiwania
''
The answer to the second question may be a little more complicated. Students should remember from modules two and three how to control a character using the mouse. It is worth discussing how the racket should move (just left–right if the board we adopted is as in the example). Therefore we ask: Which coordinate will be constant (Y) for the racket, and which will vary (X)? We ask the students to find a block which will allow to move the racket the quickest in accordance with the movement of the computer mouse. Students should find two blocks which will work well together: '''Set x to <0>''' and '''x mouse'''.''
 
 
 
[[Plik:A25.png|center]]
 
 
Together with the students we write the algorithm for the Racket sprite on the board :
* ''When the green flag has been clicked''
* ''Set the Racket at the bottom of the Stage (e.g. Y=-150)''
* ''Always''
** ''Set x to <mouse x>''
'''Task:''' We ask students to add a script for the Racket, and then test whether the racket moves as desired. We allow three to four minutes to complete this task.
A sample script might look like this:
 
 
[[Plik:A26.jpg|center]]
 
'''We ask subsequent questions leading to the determination of all relevant points of the Ball sprite algorithm (we write down the findings on the board, e.g. on the schematic drawing):'''
1. Where should the ball be placed after the programme is started?
2. In which direction should it be placed?
3. How can we control the speed of the ball, how fast should it move?
4. What should happen when the ball reaches the edge of the screen?
5. What should happen when the ball touches the racket?
6. What should happen when the ball fails to touch the racket and passes behind it?
 
Various answers may be provided. We should collect and discuss them and propose some output data. For example:
* It is best when the ball starts to move from the centre of the screen (Y=0). The initial value of X may be any value (e.g. randomly selected from the range between -200 and 200).
* Setting the angle of the ball’s direction to 45 degrees, i.e. top right, will allow the player to figure out how to control the racket. At this point it is a good idea to revise directions with students – an angle of 0 degrees is the direction upwards, then we move clockwise, so an angle of 90 degrees is the direction to the right. Thus an angle of 45 degrees will direct the ball diagonally upwards and to the right. In discussing the value of each angle we can use the following illustration.
181
edycji