Weekly Sneak Peek - Week 22 (Patreon)
Content
Hello! ^w^
Thank you for checking out this sneak peek! You really want to see some naked kobolds, huh? Well here you go!
Cutescene System
Hi Null here! :3 People really enjoyed last week’s section so I thought I'd showcase coding stuff more regularly!
This week I’ll cover how I implemented the cutscene system.
One thing I missed a lot coming from Unity are coroutines, which were super handy for things like cutscenes, boss patterns, AI, etc.
To emulate coroutines, I wrote a little scripting system inside of GameMaker that can accomplish the same.
A cutscene is made up of events:
An event can basically do whatever it wants, and the cutscene controller will keep calling it until its “done” flag is set to true.
Because the system needs to support jumping and branching, the events are kept in memory until the cutscene finished. That’s also why there is a second “Setup/Reset” event on the object in addition to GameMaker’s standard Create event.
Event types, such as camera shake, walking a character, opening a dialogue box, panning the camera, etc. will inherit this base event and flesh it out with their own implementation.
Most of them are very simple. For example, all the camera shake event does is set the appropriate attribute for the active camera and then set itself to "done".
For the actual scripting language I made short functions that create and setup the events and also add them to the cutscene:
The cutscene controller itself is very simple, too:
Putting it all together it looks like this:
This would loop indefinitely, because the last line jumps back to the beginning.
Result:
And there you have it! It is very simple but we can easily extend it and it is highly flexible! I’m looking forward to using this for all kinds of scripted encounters. :D
Cheers!
Cookie & Null