• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] GML Coding Best Practices - Building Cutscenes with Paths & Timers

TheJoe

Member
Hi everyone!

This is my first time posting but I've been working with GML & Gamemaker for about a year and a half now. For a little background I'm a total hobbyist, no coding experience other than some batch files in DOS when I was way young, and just make games for my friends (this one is for a wedding present for my friends who are REALLY into their dog).

For some reason I've always had a really hard time making cutscenes and I'd love if I could get a second pair of eyes on a bit of code I wrote for one. While I'm really excited for Sequences, I need to finish this wedding present before I'll have access, and so lo and behold I finally stumble upon Paths as a potentially great solution. I'm wondering to myself why nobody has any tutorials out there on them or why they're not mentioned much in the forums or tutorials, but now after been banging my head against my desk trying to get them to do what I want, I think I might get why (ex. I first tried this with a switch statement for path_position and that led me down a dark nightmarish hellscape hole, and why isn't it easier to fire events at a point in the path?).

Sorry for the long preamble! Here's the working code and my question is, is there a better way to achieve this? Small scene where a dog walks into view, does some doggy stuff.

GML:
timer++;

//Dog turns around to wait, barks
if timer >= 120
{
    image_xscale = 1;
    sprite_index = s_dog_bark;
    path_speed = 0;
}
        
//Dog sits down and pants
if timer >= 240
{
    sprite_index = s_dog_sit_pant;
}

//Dog turns around and walks away
if timer >= 500
{
    path_speed = 1;
    sprite_index = s_dog_walk;
    image_xscale = -1;
}

//Dog waits standing and panting
if timer >= 750
{
    path_speed = 0;
    sprite_index = s_dog_stand_pant   
}
Since I've been working in a total vacuum for my entire coding life, I write this stuff and think to myself 'Joe, while this works, you're probably coding like a dummy."

Really appreciate any thoughts or recommendations!

(PS I've implemented FriendlyCosmonaut's Cutscene system in a previous project and it just seemed like overkill for the stuff I do.)
 
If everything in the cutscene is on a strict time table (e.g. you've planned the exact moment that every action will happen), timelines are definitely the way to go.

However, if certain actions are based on other actions within the cutscene, the method you used is best, in my opinion. For example:
GML:
//A cannon launches a cannonball after a specified time
if timer>=100
{
obj_ball.hspeed=20
obj_ball.gravity=.5
}

//After the ball is past a certain point in the room, something else happens
if obj_ball.x>=1000
{
instance_create(obj_ball.x,obj_ball.y,obj_explosion)
}
I've done it both ways. It just depends on what works best for your cutscene.
 
Last edited:

TheJoe

Member
Great! Thanks for the help all. Timelines is something I still haven't looked into and it does look like for the simplicity of this cutscene, that might be all I need. Good to hear confirmation that I'm not way off on my methods (while I wait anxiously for Sequences).
 
Top