Zmiany

Skocz do: nawigacji, wyszukiwania
[[Plik:A40.png|center]]
 
* Setting the ball speed to 5 steps, which will ensure that the initial speed will not be too high. This will determine the game’s level of difficulty. Afterwards we can experiment with this parameter.
* The ball should bounce off the wall (the bottom edge will be an exception, because the ball should not reach it).
* The ball should bounce off the racket producing a bouncing sound.
* When the ball misses the racket, the game should be over – e.g. the words Game over! should be displayed.
 
'''We ask the following question:''' Which of the listed actions are we able to programme? What raises our doubts? Together we look for blocks which can be useful in solving specific problems.
''
The students already know most of the blocks necessary for programming the described game. When it comes to new ones, a few movement blocks may come of use – in particular:''
* ''bouncing off walls,''
 
 
[[Plik:A27.jpg|center]]
 
* ''checking the direction in which the ball is currently moving,''
 
 
[[Plik:A28.jpg|center]]
 
* we should discuss with the students how we can tell that the ball has gone past the racket. We can guide them by asking what we are able to control in the case of the ball. They will arrive at the answer that, among others, the X and Y coordinates. Next, if necessary, we can ask what the value of the coordinates is for the racket. X is changeable, and Y determines the height of the stage at which the racket moves. Previously we have found that Y for the racket is -150, so if the Y coordinate of the ball is less than -150, this means that the ball has gone past the racket.
 
'''Students’ task:''' We ask the students to think about and write down (individually) on a piece of paper the algorithm (rule) determining the actions of the Ball sprite. We allow them a few minutes to complete this task.
Together with the students we write down the algorithm on the board and take this opportunity to clarify any doubts.
 
 
[[Plik:A29.jpg|center]]
 
Sample algorithm for the Ball sprite:
* ''when the green flag has been clicked,''
* ''set the ball at mid-height of the Stage (Y=0) with determining the X coordinate by means of a draw,''
* ''set the ball direction at 45 degrees (upwards and to the right),''
* ''always:''
** ''move the ball by 5 steps,''
** ''if it is touching the edge of the stage, bounce it off,''
** ''if it is touching the racket:''
*** ''play a bounce sound,''
*** ''if the direction is: to the right and downwards (direction=135 degrees)''
**** ''rotate by 90 degrees to the left''
*** ''otherwise''
**** ''rotate by 90 degrees to the right
''
181
edycji