8-10 yrs old
11-13 yrs old
Art and Design
Math & Economics
This project shows how you can create a rainbow in Minecraft using code and the mathematical equation for a circle.
May 2, 2017
PDF of this lesson
Includes all images and directions to use this lesson plan. Please see attached PDF file.
Here's how this project will work:
When this project is run (by pressing the "play" button) it creates a rainbow.
You can think of the rainbow as being one half of a circle.
This project uses the equation of a circle to create a rainbow.
This animation demonstrates how to calculate the coordinates for a circle with a radius of 20.
The x-values start at -20 and count up by 1.
When the x-values reach 20, the rainbow will be finished.
The "create rainbow" function calculates these values for you.
This project also uses a special tool used for building in Minecraft called the bot.
These are the code blocks used in this project that affect the bot:
This block moves the bot to the player's position.
This block saves the bot's current location with the provided name.
This block will return the bot to the named checkpoint.
This block will move the drone in the provided direction, the distance provided.
Here's how the project plots the x-and y-values for the rainbow:
For every x-value:
Once the drone is in position, it places the colored Minecraft blocks by calling the "rainbow colors" function.
The "rainbow colors" function does the work of placing the colored blocks for the rainbow once the drone is in the correct position.
This function places colors for the rainbow by:
This process repeats for all the colors in your rainbow.
This project has already added red, orange, and yellow for your rainbow with this code:
Can you modify the "rainbow colors" function to draw all the colors of the rainbow?
These blocks will help you get started:
It's actually pretty simple to change the size of the rainbow. All you have to do is change the number in the "create rainbow" block.
The function parameter (currently 20) represents the radius for the rainbow that will be drawn.
Change the number to draw a bigger or smaller rainbow.
If you're an advanced coder you get access to cool power ups; like making code faster!
By default the bot tool places blocks one-at-a-time.
By using something called a buffer you can tell the bot to place all the blocks at once.
To use the bot buffer:
Modify the "create rainbow" function to make use of the bot buffer.
Your code might look like this:
<img src="https://education.minecraft.net/wp-content/uploads/Picturelastrainbow.png" alt="" width="975" height="538" class="alignnone size-full wp-image-95766" />
To see the full lesson with images to guide your work, download the attached PDF. Thanks!
Sign up for the Minecraft: Education Edition newsletter. We promise to respect your inbox.