Upcoming SlideShare
×

A mazing Game

996
-1

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
996
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide
• Left and right arrow both point right (90). Left arrow should point left (-90).
• Yes. The forever/ if touching colour? stacks are both executed throughout the program, despite being in separate stacks in the right-hand example . This could be a good opportunity to discuss the concepts of parallelism and modularity again: Q: Why might some think the right-hand script is better than the left-hand? A: It separates movement and collisions into two stacks. These are two separate problems which should arguably be solved separately. This will make the code easier to maintain if new features are added to either aspect.
• The sprite moves before pointing in the correct direction. This will make it move 5 steps in the previously selected direction, causing it to touch colour blue if it happens to be close.
• The touching colour? block is inside the final if statement, meaning it will only ever be executed if the down arrow is pressed.
• A mazing Game

1. 1. A Mazing Game
2. 2. Starter Activity: Maze Games Check out the maze style games: http://scratch.mit.edu/tagged/shared/maze A Mazing Game
3. 3. A Mazing Game In this lesson you will use algorithms to help code a solution that uses conditional statements to make a program loop. You will create a maze style game. Lesson  Understand the use of an algorithm to develop a solution to a problem  Translate an algorithm into code  Use conditional statements Objectives
4. 4. Introduction You are going to create a simple game where the player guides an ‘explorer’ character around a maze using the arrow keys. The game will end when the explorer rescues its friend in the middle. A Mazing Game
5. 5. Watch the video Maze which is in the programming in scratch folder in Groupwork to learn how to create the game. A Mazing Game
6. 6. Task 6: Setting the Scene Set up the game by importing the stage costume (Maze) and two sprites – an explorer and a friend for the explorer to rescue. N.B The maze is already in the backgrounds folder Don’t do any more at this point. A Mazing Game
7. 7. The Importance of Design Before you make anything – a house, a car or a computer program – you should start with a design. There are two important parts to most programs – the interface (how it looks) and the code – you design these separately. A Mazing Game
8. 8. The easiest way to design the interface is by sketching it out on paper. To design the code, the easiest way is to write out a list of steps you want the code to perform in English. This is known as an algorithm. Algorithms let programmers concentrate on what the code has to do, instead of how to do it on the computer. A Mazing Game
9. 9. Designing the Solution Think about the two main things that you will need to code: 1. Moving the explorer around the maze 2. Getting the explorer to rescue its friend The table on the next slide shows an algorithm for moving the explorer around the maze and the Scratch code that does the same thing. A Mazing Game
10. 10. Algorithm for moving explorer Code when the flag is clicked repeat forever if right arrow key is pressed point right move 5 steps if left arrow key is pressed point left move 5 steps if up arrow key is pressed point up move 5 steps if down arrow key is pressed point down move 5 steps if explorer touches the same colour as the maze wall
11. 11. Task 7: Moving the Explorer Using a combination of the algorithm and the code, develop your game so that you are able to move the explorer around the maze. Use of the video is forbidden from this point onwards. A Mazing Game
12. 12. Algorithm for moving explorer Code when the flag is clicked repeat forever if right arrow key is pressed point right move 5 steps if left arrow key is pressed point left move 5 steps if up arrow key is pressed point up move 5 steps if down arrow key is pressed point down move 5 steps if explorer touches the same colour as the maze wall
13. 13. Test your game to see if it works If it doesn’t see if you can identify the problem. A Mazing Game
14. 14. Task 8: Rescuing the Explorers Friend From this algorithm, see if you can create the code for the friend sprite! A Mazing Game Algorithm for reaching centre of maze Code for friend sprite when the flag is clicked show sprite repeat forever if touching explorer sprite say “Thank you!” hide sprite stop all scripts Code this one yourself!
15. 15. Test your game to see if it works If it doesn’t see if you can identify the problem. A Mazing Game
16. 16. Plenary: Question 1 A programmer creates a maze game like the one you’ve just created. Unfortunately, the character doesn’t move as expected. What mistake has the programmer made? A Mazing Game
17. 17. Plenary: Look at the two examples of code. Do they perform the same task? A Mazing Game Question 2
18. 18. Plenary: Question 3 The code adjacent controls a sprite going round a maze. If the sprite touches the side of the maze (the colour blue), it returns to its starting position of -150, 150. Unfortunately, the sprite sometimes touches the walls of the maze and returns to the start when the player doesn’t expect. What mistake has the programmer made? A Mazing Game
19. 19. Plenary: Question 4 In this example, the sprite is supposed to return to the centre of the maze when it touches the sides (coloured blue); however, it only does this sometimes. What mistake has the programmer made? A Mazing Game
20. 20. A Mazing Game Keywords  Understand the use of an algorithm to develop a solution to a problem  Translate an algorithm into code  Use conditional statements Objectives  Loop  Sprites  Interface  Code  Indented  Conditional Statements  Collision Detection  Repetition   