Remember Prometheus? He works with instructor Andrew as part of Game-U’s Accelerate program, and has put together games like the Project Spark Dragon Quest, or the Tarzan-style GameMaker platformer. Today in GameMaker, he created the sprite equivalent of coffee!
What human beings accomplish with coffee, sprites like Prometheus’ GameMaker character accomplish with power-ups. After fixing a few minor bugs left over from last class, Prometheus and Andrew focused on creating a speed power-up for the player sprite to collect. Sprite, meet coffee! Prometheus wanted the power-up to temporarily increase the player’s speed. Here’s how he made it happen.
First, Prometheus selected an object for his player sprite to collect. He then selected another sprite (a series of character-based images that play in quick succession) to give the object form and motion. Using the collection trigger, Prometheus coded a global boolean variable to signal other code that power-up rules are now in force. The boolean, which is valued at either true or false, acts like a flag to the rest of the program. If it’s false, the program operates on non-power-up conditions. If it’s true, the program switches to operate according to power-up rules. Since the power-up boosts the player’s speed, any part of the program related to speed must pay attention to the flag’s value. Like a row of dominoes, the true value causes a cascade effect – changing the speed variable from “basespeed” (the default speed of the player) to “speedboost” (the player’s speed on digital coffee). Since Prometheus also added a Special Points meter to limit the use of power-ups, a true value also triggers a decrease in the meter value (watch the bar in the top left corner of the video). A false value, on the other hand, preserves the ordinary state of operations. Once the player sprite collects the virtual coffee, the boolean variable is set to true and the player gets all the benefits of speed boost conditions!
Cool stuff, Prometheus. You’ve got a great handle on the logic that goes into coding games. Keep sharing your progress, especially on that unfinished SP meter. We look forward to playing your platformer for ourselves!