Instructors should review the simulation ahead of time and recreate the simulation activity in MakeCode Arcade ahead of class. Before students dive into the simulation, instructors should show students what the output looks like.
To create different levels in our game, we will be using functions. Ask students if they know what functions are? Why do we use them?
Functions are a “chunk” of code that you can use over and over again, rather than writing it out multiple times.
Functions have a name and are created to perform a particular task.
Let students know to follow along closely as you work with them on a new simulation
We are going to create a nature themed tilemap maze game with 3 levels
Have them open up a new MakeCode Arcade file and name it ‘Nature Maze’
First we need to create our main character sprite that will explore our different levels.
Find set mySprite to in Sprites. Drag it into the on start. Open the image editor for mySprite, and select an animal sprite from the gallery of preset images. Find move mySprite with buttons in Controller. Drag it onto the on start. Find camera follow sprite mySprite in Scene. Drag it onto the on start.
The camera follow block allows the point of view of the game screen to always stay on our player, no matter where they move on the tilemap.
Next we will create our function.
Click on the Advanced dropdown menu in the toolbox to reveal Functions. Click on Functions and select Make a Function… Rename the function from doSomething to Change_Level. Click on the Number parameter. Change the name of the array parameter from num to Level_Number. Click done.
Next we will write the code inside our function that will repeat every time the Change_Level function is called.
Find if true then, else in Logic. Drag and drop it inside the Change_Level function. Click on the plus sign and then click the minus sign to create one “if” statement and one “else if” statement.
This block sets up a conditional. If the first “if” condidion is true, then the code inside that section will run. If not, then it will check if the “else if” conditional is true. If the “else if” condidion is true, then the code inside that section will run. If none of the conditions are true, then nothing will happen.
Find 0=0 in Logic. Drag and drop if over the true value in the “if true then” statement. Update the values of 0=0 to Level_Number=1. Copy the Level_Number=1 block and place it inside the next “else if” statement. Update the value to Level_Number=2.
We are adding a condition: the first condition is if level number = 1. The else if condition is if level number = 2.
Find set tilemap to in Scene and drag and drop 2 of these blocks after the if and else if statements. Customize both of these tilemaps to be 2 distinct levels with a Nature Maze theme.
Go to Variables and select Make a Variable… Name this new variable Current_Level. Find set Current_Level to 0 in Variables. Drag it onto the on start. Change 0 to 1. Find call Change_Level 1 in Functions. Drag it onto the on start.
Lastly we need to add a way for our player sprite to traverse the different levels.
Go back and edit your tilemap for level 1 so that it contains a staircase tile somewhere on the screen that is accessible to the player.
Find on sprite of kind Player overlaps tile at location in Scene. Drag and drop it onto the canvas. Click on the gray box and select the staircase tile.
Find change Current_Level by 1 in Variables. Drag and drop it inside on sprite of kind Player overlaps tile at location. Find call Change_Level 1 in Functions. Drag and drop it inside on sprite of kind Player overlaps tile at location. Change the number variable to Current_Level.
Find place mySprite on top of random tile in Scene. Drag and drop it inside the Change_Level function. Select the floor tile.
Congratulations, your game is complete!
Don’t forget to test out your game, and make sure that:
You can travel between level 1 and level 2 using the staircase tile
Your tilemap is set up so that you can access your levels
Activity 2: Checkpoint Activity
Duration: 15 minutes
This is a perfect time for students to test their knowledge of functions and creating levels.
Students will add a level 3 to their game, which will be much more challenging for the player.
Ask students what are you going to add to your tilemap to make it more difficult? Ex. more turns in the maze, obstacles, enemies, etc.
The teacher should list out student ideas on the board
Student Task:
Students will add a level 3 to their Nature Maze.
Hint: Students need to add another “else if” statement to their function.
Students will create a new tilemap for level 3.
The new tilemap will be much more difficult or include some form of obstacle to make it more challenging.
Students need to add a staircase tile to their tilemap for Level 2 which will help them travel to Level 3.
*Please note if students would like to add a way in their game to back up levels (for example go from level 3 to level 1) the Kodely team has included a screenshot to make this possible. This is the circled piece of code in red.
Activity 3: Design Thinking Activity
Duration: 5 minutes
Game Testing
This is where students will test out other students’ checkpoint activities, share feedback, help them where they are stuck….
Questions for students to ask while testing their partner’s game:
Are there any bugs in the code?
Does the game run as intended?
Can you access all 3 levels of the game?
Is level 3 more challenging than the previous levels?
Is there some new challenge or obstacle included in the new level?
Is there anything else your partner can do to make their game better?
Activity 4: Creative Time
Duration: Remainder of Class Time
Once students are finished with the checkpoint activity and you review their work, give them time to pick their own themes, Sprites, and game objectives to design their own game. Encourage them to use the topic they learned in today’s class with functions and find ways to incorporate it into their game.
If students are stuck on idea help them brainstorm by asking them the following questions:
What characters are you including
What theme did you choose?
What tilemaps are you using?
How many levels are there?
What is the objective?
Login
Accessing this course requires a login. Please enter your credentials below!