11-13 yrs old
14-18 yrs old
Oh no! Alien pixel spaceships are descending on the Minecraft world! You'll have to pilot a pixel spaceship of your own and fire pixel bullets to stop them!
In this project, you will recreate a classic arcade game. You'll use Minecraft blocks to simulate the iconic pixelated appearance of older video games.
Use the bot to place and remove the elements of the game, detect the presence of a "button" to steer the player's ship, and manage everything in a game loop that runs periodically.
May 2, 2017
How can you use game loop function to create an arcade game?
To recreate this classic game in Minecraft, you will "draw" the visuals of the game--ships and bullets--with blocks. You need to repeatedly draw and redraw these blocks as the game's state changes. That way you can animate the movement of the player's ship, enemy ships, and bullets.
In the code given to you, look for the "game loop" function:
Once this function is called, it repeatedly does several things over and over, several times per second:
Try playing this game as is. Punch the glass blocks to move the player ship (the emerald box) left and right. The player ship will fire at the alien ships (redstone boxes) automatically.
As it is right now, the "game loop" function will keep running forever. There's no point to leaving the game running after the player has beat it, though!
Let's add a "win condition" to the loop so that if the player has won, the game ends.
Your edited code might look like this:
Once you've added this code to your game loop, try playing the game again. After you beat the game, you should see the game area vanish and a victory message appear.
So far, you can shoot down the alien ships, but there is no danger to you! Let's make the game more dangerous by making the alien ships fire back.
Drag the "draw alien bullet" function into the game loop, right after the "draw player bullet" function, so that the loop looks something like this:
Test your game. Notice that the first alien ship will periodically fire a bullet downwards toward the player.
The aliens are attacking now, but there's no danger yet; the alien bullet doesn't actually harm the player ship. Let's fix this so the game is actually challenging.
Your code should look something like this now:
Test your game. Now, if you allow the player ship to be hit by an alien bullet, the game should disappear and display a loss message.
You might have noticed how it is always the first alien that fires a bullet at the player, even if that alien has already been destroyed!
Let's make this behavior more interesting, so that it is always a random (living) alien that fires.
Scroll down to the "draw alien bullet" function at the very bottom of the code area. It's complex, but don't worry too much about how it works. Find the last section of the function, which looks like this:
Test your game. Notice that different aliens fire at the player now!
Awesome! Your game is working pretty well now. Have fun playing it!
If you feel brave, you can play with the game's underlying code and try to make even more improvements, such as...
To view the full lesson with images, please download the attached pdf document. Thanks!
Minecraft Boolean Logic
Learn how to create Boolean logic gates in MC:Edu
Binary Numbers Simulator
Simulator to understand the binary concept
This project shows you how you can use just a little bit of code ...
Create a Refugee Camp
Project Based Learning activity
Conocer el funcionamiento de las puertas lógicas