It’s time to practice the concepts taught in the course so far. To do this you will code a bunch of features and modifications into the Get The Ghosts project that you cloned in an earlier lesson.
You should work through all the modifications since each one has been selected to review a particular concept. The mods will start easy and finish off a little more challenging. Don’t worry if you get stuck along the way; there are video and code solutions for all the modifications. Do, however, give your BEST effort to solve the problems on your own before you check the solutions. That’s how you get better at coding!
There is no instructional video for this lesson, just a long list of challenges.
Huge Challenge 1 – Modify Get The Ghosts
You can start with this project:
L04-01-X1-GetTheGhostsStart.gmk
To see all the modifications in action, you can run the completed projected (but no peeking at the code!) or the application provided:
L04-01-X1-GetTheGhostsDone.gmk
L04-01-X1-GetTheGhostsDone.exe
Don’t skip modifications since some of them build upon each other!
These modifications are solved in the first solution video.
** The time at which the mod is solve in the video is provided so you can jump to particular solutions quickly. The time given is about 10 seconds ahead of the solution so you don’t miss the start **
a) Give the player two new variables, life and points. Set the life to 100 and the points to 0. (solved at 0:00)
b) Draw these two variables somewhere in the room. Since the room has a black background, you won’t see the variables being drawn out unless you switch to a different drawing color. To do this, make the first line in the Draw Event draw_set_color(c_white) and you will be drawing in white. Follow this line with your normal draw code. (solved at 0:47)
c) Give the ghosts a variable called life and set it to 2 and change the existing code so that the ghost will have to get hit twice before it is destroyed. (solved at 4:14).
d) Give the player 5 points every time they hit the ghost with their laser. (solved at 6:25)
e) Add this section of code to the event Ghost collides with Wall.
direction = direction + 180
It will make the ghost appear to bounce off of walls when the collide with walls once we get them moving. (Solved at 7:48)
f) Make the boss randomly produce a ghost every few seconds. The ghost that is made should be moving to the right. (Solved at 8:47)
These modifications are solved in the second solution video.
g) Make a new object called laserred and get the ghosts to fire, every second or two, red lasers at an angle of 260-280 degrees every second or two. Remember to set the image_angle of the laser so it looks correct in the game. (Solved at 0:00)
h) Since there are no walls located along the bottom of the screen, red lasers just keep on going and going. We need to destroy them when they leave the room. There is an event called Other->Outside Room that is called when an object leaves the room. Add an instance destroy method inside this event for the red laser. (Solved at 3:30)
i) When the player gets hit by the red laser, destroy the laser and reduce the player’s life by 10. (Solved at 4:54)
j) Just after you take 10 off the player’s life, check to see if the player’s life is below or equal to 0. If it is, show the message, “Game Over! Click to Restart!” and then use the line game_restart() to have the game restart itself. (Solved at 6:20)
k) Create a new object called healthpack. When the player collects a health pack it should be destroyed and the player should get +25 onto their life and make sure that the player’s life doesn’t go over 100. Add a health pack or two neaer the player to test it out. (Solved at 8:05)
l) Last modification! When a ghost is destroyed, there should be a 1 in 10 chance that it drops a health pack downward. If a health pack goes outside the room, it should destroy itself. (Solved at 11:15)
Huge Challenge 1 Solution
The solution is split into 2 videos
Solution Video #1: 04-01-X1Solution1
Solution Video #2: 04-01-X1Solution2
Solution File: L04-01-X1-GetTheGhostsDone.gmk
And a few people asked about how the background music is started properly in the game (did you notice the problem?), so here’s a quick video about that…
Solution Video #3: 04-01-X1Solution3MusicFix