# Magical Castle2: Zombie Attack

8-10 yrs old

11-13 yrs old

Computer Science

Follow on from Magical Castle lesson. Again we use positional sensing, this time to create a Zombie Attack game. Map kindly provided by Faith Shupee.

Submitted By: Philip Golden

February 23, 2018

#### Skills

• Creativity
• Critical Thinking

### External References

Chapter 2 gives detailed descriptions of positional sensing for Minecraft (albeit using Python), and was the catalyst for creating this lesson

This is a slightly modified version of the Magical World map with Lapis Lazuli added to a chest. Again thanks to Faith Shupee for the map!

This handout provides an example solution using MakeCode

### Learning Objectives

• Students will further develop real time sensing of the player, a key concept in many Minecraft mini-games
• Reinforces importance of 3D co-ordinate in sensing, spawning mobs and placing blocks. Both relative and absolute co-ordinates used
• This game is another example of the 'sense, calculate, action' framework that is the foundation of many Minecraft mini-games. Emphasising this framework is particularly useful to allow students to use decomposition on games they play, which in turn can enhance both their analytical skills and understanding.

### Guiding Ideas

• Real time sensing of the players position is a fundamental concept behind the lesson, as is using co-ordinates to spawn mobs and place objects
• How can we distinguish (using code) between relative and absolute co-ordinates?
• What are the tradeoffs between relative and absolute co-ordinates?
• Which makes the program easier to read/understand?
• Are there problems with relative co-ordinates in the case of spawning zombies? (Because there is a pause after the players position is sensed, it is possible that the zombies are spawned outside if the player runs forward)
• Why do we use pause blocks in the program?
• How would the game change if we removed them? (For a start it would likely crash as we would spawn an infinite number of zombies!)
• The player is sensed as she both enters and exits the room. Is this desired behaviour? If not, how could we change our code to prevent sensing when the player leaves?
• The original game can be extended with different mobs, weapons etc. Students are largely limited by their imagination!

### Student Activities

• Use code connection to create two variables that continually sense the player's x and z location
• Ensure that 'show co-ordinates' is on. Fly to the entrance of the castle and proceed to the room just on the right at x = 634, z = -48
• When a player enters the room:
• Change the time to night
• Change the mode to survival
• Place two glowstone blocks in the room (optional)
• Give the player a diamond sword & wait 3 seconds
• Set difficulty to normal
• Spawn 3 zombies in front of the player
• Add a 10 second wait before these steps can be repeated
• Once the basic game is working, expand the game either in the same room or other rooms. Note that there is some Lapis Lazuli in one of the chests in the room, and there is an enchantment table hidden elsewhere in the castle!

### Performance Expectations

Students should have reinforced their knowledge of 3D co-ordinates, using both absolute and relative co-ordinates for sensing and triggering events

Students should appreciate the importance of sequencing, in particular adding pauses to improve gameplay and prevent crashing!

Significant creative scope is possible for students to experiment with enhancements to the game in the same room, or adding different experiences or 'levels' in other rooms.

#### Skills

• Creativity
• Critical Thinking

### External References

Chapter 2 gives detailed descriptions of positional sensing for Minecraft (albeit using Python), and was the catalyst for creating this lesson

This is a slightly modified version of the Magical World map with Lapis Lazuli added to a chest. Again thanks to Faith Shupee for the map!

This handout provides an example solution using MakeCode