• Advertisement
Sign in to follow this  

2D Rpg Cutscenes

This topic is 630 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What might be some guidelines for creating a system that can handle cutscenes in a 2D RPG? The scope of the requirements currently would be limited to movement, animation, dialogue, music, sound effects, fade in/out and camera panning. Control would be limited to progressing the dialogue.

 

To see the exact kind of cutscenes I'd like to implement, have a look at this video.

 

Edited by Seer

Share this post


Link to post
Share on other sites
Advertisement

In a 2D RPG? It's all event based really. Not that complicated.

It's basically saying that these two AI's are to walk here. Check if they are at destination, then walk here. Play sprite animation. And then send an event that tells the UI system to do the text stuff.

Share this post


Link to post
Share on other sites
There's different solutions to this, the basic premise is:

* having some kind of scripting (either a real scripting language or a simple enum based scripting)
* allowing to run those scripts in slices (e.g. coroutines in Lua) or simply a set number of events per frame
* scripting events may actually be spread across several frames (e.g. an action move npc 17 to location 12,10 and wait until he arrived, etc.)

Share this post


Link to post
Share on other sites

Well, I know nothing about scripting languages. All my programming is done using Java. Could a type of scripting be done just using Java? You might for example have a Cutscene mode/state that arrests the flow of the rest of the game and executes a list of instructions while checking for user input to progress dialogue, kind of like Tangletail suggested.

 

Are there any significant drawbacks to this approach versus using a scripting language, or is it manageable given the scope of my requirements?

Share this post


Link to post
Share on other sites

Yup. build a limited set of APIs, like MoveTo(X,Y).

Build a small string parser that reads in a text file.

So for example.... if an entity loads in a txt script file that says

MoveTo 40, 20

The engine immediately plugs that line into the function Moveto(40,20).

 

This is as simple as it gets. It's dog slow, so I don't recommend this for a lot of game code. But it's fast enough for use in a scripted sequence.

Share this post


Link to post
Share on other sites

Why would instructions need to be read from a file? Wouldn't it be simpler to hard code the instructions, since each of the scripted sequences will stay the same? It would improve performance too since there wouldn't be any file io.

 

 

Are there any significant drawbacks to this approach versus using a scripting language, or is it manageable given the scope of my requirements?

Share this post


Link to post
Share on other sites

 

Why would instructions need to be read from a file? Wouldn't it be simpler to hard code the instructions, since each of the scripted sequences will stay the same? It would improve performance too since there wouldn't be any file io.

 

 

Are there any significant drawbacks to this approach versus using a scripting language, or is it manageable given the scope of my requirements?

 

 

The general benefit of reading scripts (and configuration data) from a file rather than being hard-coded is that changes do not require your entire program to be rebuilt for every change (scripting can even be implemented in such a way that you can modify and re-run scripts without even stopping the program), and that scripts are "sandboxed" -- that is, the only actions exposed to the script are safe, and can't make mistakes or take harmful actions that could destabilize the program or overwrite important data. As a single developer, that second part is perhaps less of a concern to you, but the the first part helps reduce your iteration time (time to identify problems, make changes, and see results) for scripting sequences.

 

For very simple scripting activities such as moving characters around a screen, showing dialog, and setting or testing flags (as to indicate progression past a plot point, and testing for it later) those sorts of things can be done with a simple, command-based scripting language. This kind of language generally has one command per line in a text file, where the first word is a verb (some kind of action to undertake), and the remainder of the line serves as parameters -- this is basically like a function call.

 

A simple script might look like:

MOVE Goku, Slow, 10, 0, 0, 0
TALK Goku, "Hi Master Roshi!"
TALK Roshi, "Goku! Piccolo needs your help!"
TALK Goku, "OK!"
MOVE Goku, Fast, 0, 0, 20, 0

Its not difficult to write a simple script interpreter, especially in a language like Java that has good support for Regex. In your code, you need a means of parsing the file to recognize commands, classes and methods to implement those commands, and a system for dispatching those commands. Depending how you handle movement and how fine a control you want, and how hands-free you want your script to be, you might need to implement some basic "concurrency" so that commands can complete simultaneously (as in, two characters can move at the same time, rather than in order). Timing also plays a big part in scripting, so you'll want to build in various pauses, delays, timers, and time-based triggers into your system. Many kinds of scripting languages employ the Actor model and/or some form of coroutines, which form the basis for concurrency and timing.

 

When you want to talk about moving game logic into scripts (again, to reduce turn-around time) then you definitely want to look into readily-available scripting languages like Lua, unless you actually have an interested in building a scripting language of your own (And if you have no interest at all, even to build a simple, command-based scripting language, you might want to adopt something like Lua regardless). Lua is generally considered to be a simple and effective scripting language for games, and its widely used -- I'm not sure what its Java binding story is though. If Lua is too complex, Java/TCL (Wikipedia) [project homepage] is a command-based scripting language that can be embedded into your Java application.

 

Finally, you don't *have* to use a scripting language if you're willing to forego its advantages with regard to iteration speed, security, and flexibility. What that generally looks like is that you provide yourself an API that does all the common things you want to do in your cut-scenes, and then you have methods that correspond to each scripted sequence that linearly call those functions; In this approach you don't need to implement value setting and testing because you can rely on the language's normal operations and flow-control. You can even use the language's timing primitives to an extent, but you probably don't want timing to block your thread -- you'll probably need to provide a non-blocking system eventually, and you might find a library or framework (again, "Actor Model") that does this and more for you, if you don't want to write it yourself.

Share this post


Link to post
Share on other sites

Fantastic reply, thank you.

 

I'm not yet at a point where I need to implement cutscenes, but once I am I'll have a look at Lua.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement