You are on page 1of 6

e ar n e a rn

ke2L k e
.com
rge n Ma ke2L k
.com
e r g en Ma
n .ti n n. ti n
ar Platformer With Infinite Levels2on ar
le GameGo With Makecode Arcade 2 l e
make ma k e

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
k e2 .com n a k e 2
Play games and edit code

n .com a
n .ti n k e r g e M n. ti n k e r g e M
a r https://www.youtube.com/embed/FO8AW7FpiEk
2 l e a r 2le
a k e
m portable console developed by TinkerGen STEM education. It is based onm a k e
GameGo is a Microsoft Makecode compatible retro gaming
STM32F401RET6 ARM Cortex M4 chip and made for STEM educators or just people who like having fun creating retro video games.You can
follow this tutorial and try the game in Makecode Arcade simulator and then run it on GameGo.

In this article we're going to make a platformer game with infinite randomly generated levels. In a platformer, the player controlled character

L e a rn e a r n
must jump and climb between suspended platforms while avoiding obstacles. Environments often feature uneven terrain of varying height that

L
ke 2 .com k e 2 .com
Ma Ma
must be traversed. The player often has some control over the height and distance of jumps to avoid letting their character fall to their death or

e r g e n e r g en
miss necessary jumps. We'll implement all these basic elements and also add a custom function that will generate new levels as we reach the

rn. ti nofkthe last one. Let's begin! r n.tink


a end
2 l e a 2 l e
Supplies: make ma ke

e a rn e a r n
ke2L .com
k e r ge n Ma ke2L k
.com
e r g en Ma
n . t i n n. ti n
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a r n
k e 2 .com k e 2 .com
n. t i nk e r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k
e ar n e a rn
ke2L k
.com
e rg e n Ma ke2L k
.com
e r g en Ma
n .ti n n. ti n
ar Step 1: The Hero
e 2 l e ar e 2 l e
ma k ma k
As a first step we will create our alter-ego. My drawing skills are pretty bad, so I just decided to use one from the Gallery ;) Unlike the previous
game we made, in this platformer our playable character can only move left and right and also it can jump. So instead of having two different
sprites for the main character, one is enough this time - we can just flip sprite's image when we change direction.

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
k e2 .com k e 2 .com
.tink e r g e n Ma . ti n k e r g en Ma
ar n 2 l e a rn 2l e
make m a k e

L e a rn L e a r n
ke 2 .com k e 2 .com
n. ti nk e r g e n Ma n.tink
e r g en Ma
a r 2 l e ar 2 l e
make ma ke

e a rn e a r n
ke2L .com
e r ge n M a ke2L
k to do is to add background and tile map. I have chosen 32x8 longntile.tmap
.com
e r g e n M
k- for the first level we'll draw it manually, as in screenshot a
n . t i n i n
ar 2. Then we add our playable character with set mySprite to spritee2of lkind
First thing
e r
aPlayer e 2 l e
m a k block and place it on the top of tile 0-5. We also set
m
the a k
camera
to move with playable character and control its left and right movement - we'll set velocity vy of movement to 0, since our character shouldn't be
able to float freely on the map along y-direction. Add two on ... button pressed blocks, one for left button, one for right. When left button is
pressed, we check if our direction was "left" before pressing the button. If it was, we just continue going left. If it wasn't we need to flip our
character's sprite image. Similar logic for right movement.

L e a rn L e a r n
e 2 e 2
All good for now, the only problem seems that our hero cannot seem to overcome any obstacle. So we need to add jumping. We'll monitor the

k k e r.com
g e n Ma k k e r .com
g en
controls for up button press and when it is detected, we'll set variable jumping to 1, make note of the time jumping movements started and set
Ma
n. t i n n. ti n
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k
e ar n e a rn
ke2L .com
e rge n M a ke2L
k sprite velocity vy to -200(going up). Then after specified period ofntime, e
.com
r g en
k set the velocity to 200(going down), so our hero M a
n . ti n . ti n
ar wouldn't shoot up to the sky as a rocket.
character's
e 2 l e ar we'll
e 2 l e
ma k ma k
I think we created a hero worthy of the challenge now! Well, where is the challenge?

Step 2: The Enemies

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
k e2 .com k e 2 .com
.tink e r g e n Ma . ti n k e r g en Ma
ar n 2 l e a rn 2l e
make m a k e
We will use an array structure to store the sprites of the enemies. For type of enemies we'll take a little shortcut and use bats :) not a
coronavirus reference, it's just bats can fly, that's why we won't need to "simulate" gravity for them, as we do with our playable character. Use

n n
on created sprite of kind Enemy block to place newly created bats on random spawn tile (marked with a little white mark) and set their vx

2L e a r 2 L e a r
velocity to -10(slowly drifting right). Then within on game update every 2000 ms block we iterate through each item of enemy_list and randomly

ke .com
e r g e M a k e .com
e r g en M a
change their direction, while also flipping the bats' sprites if necessary (to reflect the change in movement direction). Finally, we add on sprite of
n
nsetkhit flag to 1(has been hit) and start the timer. Once 500 ms since last nkpassed we change flag hit back to 0. We do that in order
kind Player overlaps with otherSprite of kind Enemy block, where we do a simple check if player has been hit already. If it wasn't we deduct one

rn. t i
a for player to avoid loosing too many of it's precious lives after colliding a r n . t i
life,
k e 2 l e hit time
k e 2 l e
ma with an enemy.
ma
Let's check how are we doing. Well, the scene certainly seems livelier with all the bats flying around and biting our player. Now we need a
weapon to do our heroic deeds!

Step 3: The Weapon

e a rn e a r n
ke2L .com
k e r ge n Ma ke2L k
.com
e r g en Ma
n . t i n n. ti n
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a r n
k e 2 .com k e 2 .com
n. t i nk e r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k
e ar n e a rn
ke2L k e
.com
rge n Ma ke2L k e
.com
r g en Ma
n .ti n n. ti n
ar e 2 l ear e 2 l e
ma k ma k

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
e2 e 2
For the weapon, I was drawing the inspiration from an old Nintendo game about two chipmunk brothers :) Let's add the crate sprites to the

k e
.com
r e n Ma k .com
e r g en
level, the similar way we do with adding the enemies. We also initialize has_crate variable to -1, which indicates our character doesn't carry a
g M a
.tink . ti k
n block we move that sprite together with player's sprite and
crate. In on sprite of kind Player overlaps with otherSprite of kind Food block, we check if we already holding a crate and if we don't, we set the

a r n 2 l e a r n 2 l e
e e
has_crate variable to the index of the crate sprite in the list. Then in on game update
a k
m or -1200(depending on the direction of movement of the character). We also
if button A is pressed, we change crate's vx velocity to 1200 mset a k
has_crate variable back to -1 again and change the type of sprite of the crate that was launched into the air just now to Projectile.

Lastly, we need for the crates to actually destroy the enemies when launched (but not when the enemies just randomly stumble across a crate!
that's why we assigned crates to type Food and change it to Projectile only when launched) and self-destroy when hitting the wall. We use

L e a rn L e a r n
another on sprite of kind Projectile overlaps with otherSprite of kind Enemy block for that - in that case we destroy both sprites and raise score

ke 2 by one. If Projectile hits the wall, we destroy its sprite.

.com n a k e 2 .com
n a
n. ti e r g e M
nk or write an algorithm that would generate these levels automatically
n . t e r g e M
n- kalthough they won't be as pretty as human-made levels of
Almost done now! The game is playable now, but hardly any challenge still - only one level and fairly simple at that. We could make more levels
i
r
a course.
by hand
2 l e a r for us
2 l e
ma k e ma k e
Step 4: Infinite Adventures

e a rn e a r n
ke2L .com
k e r ge n Ma ke2L k
.com
e r g en Ma
n . t i n n. ti n
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a r n
k e 2 .com k e 2 .com
n. t i nk e r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k
e ar n e a rn
ke2L k e
.com
rge n Ma ke2L k e
.com
r g en Ma
n .ti n n. ti n
ar e 2 l ear e 2 l e
ma k ma k

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
k e2 .com k e 2 .com
.tink e r g e n Ma . ti n k e r g en Ma
ar n 2 l e a rn 2le
make m a k e

L e a rn L e a r n
ke 2 .com k e 2 .com
n. ti nk e r g e n Ma n.tink
e r g en Ma
a r 2 l e ar 2 l e
make ma ke

e a rn e a r n
ke2L .com
k e r ge n Ma ke2L k
.com
e r g en Ma
n . t i n n. ti n
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a r n
k e 2 .com k e 2 .com
n. t i nk e r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k
e ar n e a rn
ke2L .com
e r g e n M a ke2L
k bats and destroying crates. if you are encountering problems, youncan
.com
e r g en
k the code from our GitHub repository. M a
n . t i n . ti n
ar , defeating
e 2 l e ar download
e 2 l e
k
ma that can be made, for example different kinds of enemies, bonuses, better
It is just a blueprint and there are definitely some improvements
k
malevel
generation and so on. If you do make an improved version of the game, share it in the comments below! For more information on GameGo and
other hardware for makers and STEM educators, visit our website, https://www.tinkergen.com/ and subscribe to our newsletter.

TinkerGen has created a Kickstarter campaign for MARK(Make A Robot Kit), a robot kit for teaching coding, robotics, AI!

L e ar n L e a r n
k e2 .com k e 2 .com
n .ti n ke r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a rn
k e2 .com k e 2 .com
.tink e r g e n Ma . ti n k e r g en Ma
ar n 2 l e a rn 2l e
make m a k e

L e a rn L e a r n
ke 2 .com k e 2 .com
n. ti nk e r g e n Ma n.tink
e r g en Ma
a r 2 l e ar 2 l e
make ma ke

e a rn e a r n
ke2L .com
k e r ge n Ma ke2L k
.com
e r g en Ma
n . t i n n. ti n
ar e 2 l e ar e 2 l e
ma k ma k

L e a rn L e a r n
k e 2 .com k e 2 .com
n. t i nk e r g e n Ma n. ti n k e r g en Ma
ar e 2 l e ar e 2 l e
By:TinkerGen ma k ma k

You might also like