Module 5 - The “Bounce the Ball Arcade Game” Project: Różnice pomiędzy wersjami

Z Wiki Mistrzowie Kodowania
Skocz do: nawigacji, wyszukiwania
Linia 94: Linia 94:
 
* 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).   
 
* 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.
 
* 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.
 +
 +
 +
[[Plik:M_5_4.JPG|center]]

Wersja z 18:34, 6 lip 2015

Logo Mistrzowie.png

These materials have been developed by Ośrodek Edukacji Informatycznej i Zastosowań Komputerów (Centre for Information Technology Education and Application of Computers) in Warsaw as part of the “Mistrzowie Kodowania”(“Coding Masters”)Programme funded by Samsung Electronics Polska, licensed under CC BY-SA “Attribution – Share Alike 3.0”.


Information

Objectives

General objectives:

  • Review and revision of previously presented Scratch commands and language structures;
  • Introduction of the message mechanism in the Scratch environment;
  • Development of an arcade game outline;
  • Implementation of the game in the Scratch environment.

Specific objectives:

  • The student will understand and be able to use appropriate structural instructions.
  • The student will understand the concept of variable and be able to use it in the programme.
  • The student will be able to send messages and programme reactions to a received message.
  • The student will be able to use stage backgrounds.
  • The student will understand how events work and know how to use them in the programme.
  • The student will be able to implement a simple arcade game in the Scratch environment.


Stages

Discussion of selected solutions of module IV additional tasks

Time to complete this part: about 15 minutes

At the beginning of the lesson we remind the students what they were supposed to prepare between classes. We invite a volunteer to present his/her solution. We discuss with the students if anyone found a different solution. We discuss the solutions (we praise every correct solution to a task).

If there was no homework, we start by repeating key issues from the previous module. We also ask if students have any doubts about their own projects. If anyone wants to show something he/she is proud of, we allow him/her to do so.

Designing and implementing a game involving hitting a ball with a racket controlled by the player using a computer mouse

Time to complete this part: about 45 minutes


We propose to create an arcade game which will involve hitting a ball using a racket controlled with the use of a computer mouse. We will start with the simplest version and then supplement it with additional elements – including a version of the game for two players controlled with the use of the keyboard.

We sketch a drawing on the board next to which we will be able to write algorithms of actions of individual sprites and what we need to do to make our game work.

Modul 5 1.png


A24.png


We ask the following question: What should the ball and the racket be? Students will probably quite quickly answer that both the racket and the ball should be sprites which we will be able to control. If necessary, they should be prompted to come up with this answer, justifying this rather than any other choice. Task: We ask the students to change the sprite’s name to Racket, and then draw a racket costume for it. Next, they should add a new sprite, name it Ball, and draw it a suitable costume as well. We allow a few minutes to complete this task.

Together with the students we analyse and write the algorithm for the sprites: Racket and Ball.

We ask the following question: Where should the Racket sprite be placed after the programme is started? How should it move? How can it be simply controlled with the computer mouse?

E.g. on the line where it will move. Additional question: what must we set? – Y coordinate. To what value? – One corresponding to the bottom part of the screen, e.g. 150. The X coordinate can be set to any value or to 0 if students come to such a conclusion. It is worth noting the findings on the schematic drawing on the board.


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.


A25.png


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:


A26.jpg

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.


M 5 4.JPG