I personally implemented a cutscene "scripting" language for my cutscenes using XML. XML isn't necessarily the best choice, and since it's not a real scripting language with programming language features, it can be a little limiting, but for my needs it worked just fine.
My cutscene definition files look like this:
<CutScene disableBars="1" replayOnRestart="1">
<Parallel>
<CameraTarget tag="Bomb" time="1.0"/>
<DelayExecution time="0.4">
<CameraZoom zoom="4.0" time="0.6"/>
</DelayExecution>
</Parallel>
<Wait time="5.0"/>
<WaitForKey/>
</CutScene>
When I want to display a cutscene, I create a cutscene object, that is updated and rendered from my level class.
The cutscene object loads the file, and converts each XML element into an instruction, that gets updated. Only the current instruction gets executed, which is why a Parallel
instruction exists. The instructions let the cutscene object know when the next instruction can be executed.
The instruction loading might look something like this (pseudo-C++):
void CutScene::Load()
{
XMLFile* file = new XMLFile(...);
for (XMLElement* element : file->GetElement("CutScene")->Children)
{
m_Instructions.push_back(InstructionFactory::Create(element));
}
}
Instruction* InstructionFactory::Create(XMLElement* element)
{
if (element->Name == "CameraTarget")
{
std::string tag = element->GetStringAttribute("tag");
float time = element->GetFloatAttribute("time");
return new CameraTargetInstruction(tag, time);
}
...
}
I use tags to reference entities in the level, so I have set the name of the bomb-entity in the level editor to "Bomb", and I use that same string to tell the camera zoom target instruction to center on the correct entity.
Creating cutscenes in a neat way can be a pain and a lot of work, but with a data-based approach like mine, you can improve your content interation speed, since you don't have to recompile every time you want to change the way a cutscene plays out.
You could of course look into integrating something like Lua into your framework/engine, but that can be a lot of work too.
The fastest approach to code might be just pure C++ code, but you'll get faster iteration speed with a data-based approach, and using a full-fledged scripting language will get you fast iteration speed and a lot of flexibility.