Originally appeared on instructables.com
In recent time, many parts of the world have released a series of protective measurements to fight against the intensive COVID-19 pandemic. One of their solutions is to stay home for keeping social distance. Undoubtedly, the virus becomes a common enemy for everyone. So, let’s make a game to ‘kill’ the viruses. Be safe and healthy!
In this tutorial, we are going to make a game about killing viruses through graphical programming using Grove Zero Starter Kit.
We will program the 4 sprites after one by another. Let’s start!
Step 1: Main Playable Character – Owl
The owl acts as the character to be controlled in the game. We will move it left and right to shoot the viruses.
First, select the “Stage” mode. Delete the default sprite and select a new sprite “Run”.
Now, follow the below example program and code. We add three main blocks in stage mode, from left to right:
1)Receive command from Twin Button module and move the character
2)Initialization. Set coordinates of the character and bullet.
3)End of game block
Step 2: Enemy Sprites – Viruses
Add a new sprite virus. Click “Upload” to upload the virus image to your sprite library.
You can select some viruses in various sizes and shapes. In this tutorial, we use three types
In the second screenshot you can see code related to virus sprites.
Step 3: Explosion Flames
Following the same method, add a new sprite explosion flame.
Here I add 4 types of explosion flames. You can also decide their patterns yourself and how many you want to use.
Below is the example program for the explosion flame. Let’s code.
Step 4: Mask
The masks work as the bullets. Let’s add a new sprite and upload a mask image to our sprite library.
Above is the example program for the mask.
Add a backdrop. You can select from the Backdrop Library or upload your own backdrop to decorate your game.
Step 5: Control the Game Character With Grove Zero
Next, switch Codecraft to a “Device” mode. Let’s bring Grove Zero modules in.
First, connect the mainboard to your computer with a USB cable. Then click the Connect button on Codecraft.
Let’s write some code for the control program. This part is very easy, which only requires us to press the button and send the message.
Next, snap the mainboard and twin button together. As we know, Grove Zero collection allows us to connect modules through the easy “snap-together” connection.
After the modules are connected successfully, click the Online debug button, then the game will be activated by the button.
Now, switch back to the “Stage” mode, and shoot the viruses!
For more information on Grove Zero series, Codecraft and other hardware for makers and STEM educators, visit our website, https://tinkergen.com/.