Zmiany

Skocz do: nawigacji, wyszukiwania

Module 5 - The “Bounce the Ball Arcade Game” Project

Dodane 7437 bajtów, 18:14, 6 lip 2015
[[Plik:M_5_4.JPG|center]]
 
 
[[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.png|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
''
 
[[Plik:A30.png|center]]
 
* ''if the Y coordinate <-150, then:''
** ''say “Game Over”,''
** end the script.
 
'''Task:''' We ask the students to create and test the Ball sprite script according to the jointly developed algorithm.
Students work individually. We keep an eye on their progress and, if necessary, provide individual help. We can ask the students who finish quicker to help others (if they can explain to them where mistakes have been made rather than complete the task for them) or give them tasks from the list of additional tasks.
 
'''A sample ball script may look as follows:'''
 
[[Plik:A31.jpg|center]]
 
[[Plik:A32.png|center]]
 
===Modifications to the programme – adding the Game Over board ===
'''Time to complete this part: about 15 minutes'''
 
[[Plik:A33.png|center]]
 
We ask the students how they like the way the programme works. They will probably notice that the words ending the game cannot really be seen by the player because they disappear very quickly from the screen. We propose to make a change. In the majority of games, the game over board is different than the board visible during the game. We propose the following modification:
1. Creation of an additional background for the stage with GAME OVER written on it in large letters. We propose that students name it '''The End'''. At the same time the first stage background can be named '''The Game'''.
2. We suggest making use of sending and receiving messages. We ask the students to find appropriate blocks:
 
 
[[Plik:A34.jpg|center]]
 
 
3. We ask them to introduce the following modifications:
* '''In the ball script'''
** add the '''show''' block operating after the programme has been starts with the green flag,
** modify the script so that instead of displaying '''Game over''':
*** a message called '''Game over''' is displayed,
*** the Ball sprite is hidden.
* '''In the racket scripts'''
** add a script responding to receiving the '''Game over''' message by hiding the Racket sprite
** add a block showing the Racket sprite after the programme has been started with the green flag.
* '''In the stage scripts'''
** when the programme has been started with the green flag: set the background to the one named '''The Game''',
** add a script responding in the following manner to receiving the message '''Game over''':
*** change the background to the one named '''The End''',
*** terminate the operation of all scripts.
'''Task:''' We ask the students to introduce the discussed modifications to the programme and test it. We allow a few minutes for students to complete the task.
 
Individual scripts can look like this:
 
 
'''The ball script:'''
 
[[Plik:A35.jpg|center]]
 
'''The racket scripts:'''
 
 
[[Plik:A36.jpg|center]]
 
'''The stage scripts:'''
 
 
[[Plik:A37.jpg|center]]
 
===Discussion of additional tasks and tasks for self-completion===
'''Time to complete this part: about 15 minutes '''
 
[[Plik:A38.png|center]]
 
Below is a list of proposed modifications for the game we have discussed. Depending on the time remaining after the completion of previous parts, we can implement them in class or propose their completion at home. Students can choose from them the ones they would like to develop. It is worth presenting and discussing the briefly at the beginning of the next module. It is a good idea to present different solutions to the same problem as suggested by individual students.
 
'''The proposed list of additional tasks:'''
* Speeding up the game after each bouncing of the ball
''The ball speed should be increased by one step each time it is bounced off the racket. For this purpose a variable, e.g. Speed, should be created and used.''
* Adding a number of lives (e.g. three) for the player controlling the racket
''A life counter in the form of a variable should be used and modified accordingly depending on lives lost (failures to bounce the ball).''
* A version of the game for two players, controlling two rackets using the keyboard (e.g. the first player uses A and Z keys, the second player K and M keys). Here it is worth remembering about such modifications as:
* ''racket settings (left and right sides of the screen are more convenient),''
* ''change of the ball script (reaction to two rackets),''
* ''change of the ball script (the possibility of a victory of the first or the second player – detecting when the ball is out of the game field, depending on which racket was bypassed by the ball).''
* ''change of the board ending the game so that it informs us which player has won,''
* ''adding a board informing us about the rules of the game,''
* ''adding a game score counter showing points scored/lost by a given player and new rules – e.g. the first to lose the ball 5 times loses the game.''
181
edycji