Happy New Year, and Happy Birthday, Eric!
Today I worked through Level 05 of the GPC. Level 03 introduced the irandom_range function, and provided a few examples of how I could throttle when actions occured – remember that in GML, action happens according to game speed (30 by default, or 30 steps/second).
This time, instead of leaving something up to random chance in hopes that it falls on the correct number or number range, we learned how to guarantee that the action occurred at a specified interval. This happened one of two ways:
- Using a counter – declare an instance variable in the create event for an object and set a value:
//"counter" is the name of the variable, //you could call it anything you wanted... //we set it to 0 so that it could count up //in the STEP EVENT later counter=0
Then create a step event (an event that cycles x# of iterations, 1 for every point you’ve set the game speed to):
//add + 1 to the counter every time the step runs, // 30 times per second by default counter=counter+1 //when the counter reaches 150, or 5 seconds, //do something if counter >=150 { ...code whatever you want to happen here... }
- Using Alarms – a built-in counter you can use. Each object can have up to 12 different alarms in it. They work like this:From another event’s code, enter:
//where 0 is the alarm # (0-11) and 90 is the //# of steps to wait (3 seconds) alarm[0]=90
When the alarm #0 goes off, you can execute a piece of code by adding an Alarm Event for that specific alarm #:
//e.g. create an explosion in a random location //on the screen effect_create_above (ef_explosion,irandom_range (100,600),irandom_range (100,600),0,c_orange) //makes the alarm reset to 3 seconds // comment out of if you want it to //only happen once. alarm[0]=90
###
Level 05, Lesson 3: Getting Out of Sync
I’d like to preface this by acknowledging two points:
a. It’s FREE…I didn’t have to pay for ANY of this, yet all of it represents his own time, effort and money (i.e. hosting fees for his website, cost of recording equipment and software and so on).
b. John Janetka is a teacher first and foremost – the GPC website, his YouTube channel and all the content therein are done in his spare time, and shared with me, you and everyone else who’s interested because he can and wants to, and with a ‘best-effort’ LoS.
Up to this point, I’d worked out that I needed to go to the website first, read the lesson, watch the video(s), then go back to the website to complete the challenges.
This pattern held true until you get to Level 05, Lesson 03. The first thing he asks you to do in Part A is to read the notes on “L05-03-Reading01.pdf”. There isn’t a link to it on the website, or anywhere!
Then he asks you to watch the video 05-03-A to review said notes, but again, there is no such video on his YouTube channel!
Further down, he asks you to go through the questions in L05-03-ConceptQuestions01.pdf, which, like the notes, aren’t linked on the page or anywhere else…
So where are they? Well, after doing some digging, I found the word document versions buried in the Lv05 resource folder that was included in the zip file from his resources page (the link labeled “Course Resources For All Levels”).
While I could have sworn that he’d touched on &&, || and != somewhere in one of his previous videos, they aren’t covered in any of the Level 05 videos up GPC-05-03-X1Preview. Not that it matters much as the lesson notes do a pretty good job explaining what they each do and when to use them.
By and large, the questions did a good job of reinforcing the lesson up to Part C, where the answers didn’t really follow the format he specified in his instructions…
Later still in the same lesson, he tosses in some functions not previously covered (e.g. room_exists, room_goto_next etc.). I hope these will be covered in more depth later as this was the first time we’d played around with a project that had more than one screen.
Welp, on to the rest of the lesson! Stay tuned for more…
Image Credit: Don’t Hug Me, I’m Scared 2