Level 07 Lesson 02 [id’s as Return Values]

In the last lesson you learned that some methods will return values back to you. Sometimes those values can be the ID’s of other game objects. When you know the ID of a game object you have the power to control it or interact with it. Confusing? Just watch the video!

Part A – ID’s as Return Values
Watch the video: 07-02-A

Challenge 1 – Stop Far Ghost
Use: 07-02-X1Start

a) when the player presses F, find the ghost object that is furthest from the player using the instance_furthest method. Make this ghost stop moving.

Challenge 1 Solution
Solution Video: 07-02-X1
Solution File: 07-02-X1Done.gmk

Part B – More About Using ID Values
Watch the video: 07-02-B

Challenge 2 – Run Away Walls
Use: 07-02-X2Start

a) the Step event occurs 30 times a second by default. Add this code into the Step Event of the player. Find the id of the nearest wall. Then find out how far away this wall is using the point_distance method. If the wall is within 100 pixels of the player, make the wall move away from the player at a speed of 2 (hint: away from the player is the direction from the player to the wall object!).

Challenge 2 Solution
Solution Video: 07-02-X2
Solution File: 07-02-X2Done.gmk