Level 08 Lesson 01 [Writing Scripts]

In the last level you practiced using methods/scripts that are already made for you. In this level you will learn how to write your own scripts. You will also start to understand why writing your own scripts can improve the readability, re-useability, and efficiency of your code.

Part A – Creating Simple Scripts
Watch the video: 08-01-A
DoneFile: Lv08_01_A.gmk


Challenge 1 – Make Some Scripts

Use: 08-01-A.gmk to start

Lets add three scripts to the current game project. These scripts basically take existing code and place it in a script.

a) The ghost object currently has code to fire two different objects, a laser and a rock. Create two scripts called fireLaser and fireRock that can be used in the program to simplify the existing ghost firing code in the step event.

b) The player currently gets points when one of their arrows hits a ghost. Create a script called givePlayerPoints that will replace the current point code.

Challenge 1 Solution
Solution Video: 08-01-X1
Solution File: 08-01-X1Done.gmk