Remember Prometheus? He and instructor Andrew get up to some cool tricks as part of Game-U’s Accelerate program! Prometheus gave us dragon combat, X-ray vision power-ups, and even a laser gazein Project Spark. Recently, he’s branched into GameMaker, and pulled off yet another awesome stunt – this time with swinging vines!
For most platformers, the jumping challenges employ pure platforms as well as objects with platform-like surfaces, including walls, towers, and bridges. Using GameMaker, a block-based, 2D gaming engine, Prometheus created a jump-driven obstacle course for his player to navigate. This week, when Andrew encouraged Prometheus to play-test his game for possible improvements or additions, Prometheus decided the platformer needed a little bit of Tarzan. Together, he and Andrew came up with a plan to create swinging vines as the player’s means of crossing a particularly large gap.
Using sprites (think flipbooks – a series of images played in rapid succession), Prometheus added two “vines” to his game screen and began coding them to rotate. Rather than allow them to swing the whole 360 degrees, however, the guys set a maximum rotation limit to more accurately mimic the pendulum-style swing of a vine. The guys also made sure that when a vine sprite reaches its max, the direction of its rotation changes. Now, how to find the pixel coordinates for each vine’s farthest right and left positions? Trigonometry, of course! Prometheus and Andrew coded two new functions, lengthdir_x and lengthdir_y, which calculate the appropriate XY coordinates for the vines based on their length and angle. Armed with the right Xs and Ys, and after enlarging the coordinates’ collision radar (Tarzan could hit exactly the right pixel on the screen, but not everyone is Tarzan) the guys made it possible for the player to attach to the vines and swing across the gap.
But how does the player detach from the vines? To prevent the player from immediately reattaching to the vine after he tries to jump off, the guys set an alarm in the vines to delay their “sticky” powers. Once the player lets go of a vine, he can’t reattach for a while. He’s got to swing straight for the next vine – or, if he’s past the next vine, onto the far platform!
Prometheus, this game looks incredible. You’re as patient and detail-oriented as ever, and your effort clearly paid off with this new platformer mechanic. Thanks for sharing it with us, and keep us updated on your future projects!