In addition to creating a way to control characters on-screen, we need to create a system that will allow them to interact with other object. In this week’s session, we focused on programming interaction between sprites on the screen. There are many ways to do this, but this is one way to go about it.
The “forever” loop constantly checks to see if the condition is met. The “if” condition checks to see if the cat character is touching the ball. If the condition is true, if the cat is touching the ball, then the program will play a “meow” sound. So long as the cat is touching the ball, the “meow” sound will continue to play.
Here are some of the words and phrases from this week’s lesson:
- if [ ] then
- touching [ ]
- touching [ ]
- play sound
- Can you help me please?
- How do I [ ]
- move this sprite?
The next thing on the agenda is to learn how to use the cloning features of Scratch to make projectiles and enemies. There are many different ways to code projectiles; this is just one way and I can assure you that there are better ways.
The first part of the code creates a clone, or copy, of the ball whenever the spacebar is pressed. After the clone is created, the clone, not the original, will continuously move 10 steps and then repeat. The if condition continuously checks to see if the ball is touching the edge of the screen and will delete the clone if it touches the edge. This check and deletion ensures that clones do not accumulate on screen.
Here are some of the words and phrases we’re working on this week:
- wait [ ] sec
- zero point five
Variables are the last of the four foundational concepts which the students are learning in the programming course. Variables (and lists) allow us to store data for display or use at a different time. We are using variables to construct a system for keeping track of points and a timer.
This setup make sure that the variable is reset to zero at the start of every game. The second part of the code increments the “bananaTouch” variable by one if the Scratch Cat touches the bunch of bananas. The “wait 1 secs” block prevents the variable from incrementing more than once on a single contact between cat and banana.
Here are some of the words and phrases we went over in this week’s lesson:
- floating point
We are more than halfway through the programming course and are starting to prepare for our final presentations. The final presentations will happen in each class on the last week of the semester. For this week and the following two weeks, students will continue to work on their final projects and write their presentations.
Our final presentations focus on three parts:
- how to use the program
- how the program works
Here is a sample presentation for a simple game I put together. The presentation is followed by feedback from the other students in the class. Students must give one piece of positive feedback and a suggestion for improvement. A playable link to the game follows the presentation.
Hello. My name is Hiroki. This is my Scratch project. My project is an arcade style shooting game.
First, click the green flag. Then, press the arrow keys. If you press the right arrow key, the space ship moves right. If you press the left arrow key, the space ship moves left. Press the spacebar to shoot. Try to shoot the alien. Try to get a high score!
If you change this number, you can shoot faster or slower. If you change this number, the alien moves faster or slower.
Space Shooter by Hiroki: https://scratch.mit.edu/projects/255397063/