Transcript
Extra: Make It a Game
Gamify It!
Do this
Continue with your previous program and add a shape that moves across the canvas.
The shape can move horizontally instead of moving vertically.
When the shape has crossed the canvas it should reappear with a new random x-coordinate (if moving vertically) or y-coordinate (if moving horizontally.)
What value does the system variable height include?
Adding Interaction
Do this
When your creature and the shape collide, make the shape disappear and appear from the top again.
EXTRA
- What if the idea would be to avoid the shapes? When the shape and the creature collide, the shape would destroy the creature and the creature would disappear.
- Use text-command to write "GAME OVER" on the screen if the shape and the creature collide.
- How do I add sound effects or music to my game? Check the documentation of SoundFile-objects in Processing Reference.
Educator notes
If students are keen to know more about games, search "game" in Open Processing and browse through some examples in the class.
The dist-command opens up many possibilities. Once you're able to measure the distance between two points, you can basically make two objects interact with each other. For example, when a given distance goes below a given point (...as written in the code), one of the objects can disappear or both the objects can bounce back.
Activity: If you have time, make simple games in groups of three. In each group, one student can be in charge of programming, one student in charge of visual design and one student can produce the music and sound effects for the game! Giving the students different roles can be motivating - allowing each student to work with their strengths!