# How to make “Events”/ Scripted Scenes

I want to make cutscenes etc, in my game.

I thought of a similar System like in the RPG Maker:

If you enter a certain Area, a list of commands and arguments is played.

E.g. like this:

[Move Object: Right, right, right; Wait until done;]
[play Sound: sound.sfx]
[Show Message: Speaker: player, message]

I don't want to use external libraries.
Someone has a basic idea on how to implement this?

I thought of a "stack" for these kind of "events", but I'm not sure about it.

You can create a static Script class to handle to handle scripted sequences and have a state in code that allows the script class to run its sequence without interruption. Here is an idea:

Instances

Arraylist<Event> events;

class Event {
boolean eventComplete;

//different Initializations based on what the event is.
//EXAMPLE Timer event
public Event(float timer);
//EXAMPLE move event();
public Event(vector2 target);
}


Methods

setCountDowntimer(float seconds);
lerpPositiontoTarget(Vector2 target);
MovePositiontoTarget(Vector2 target);
setActive(Object object, boolean active);


It's a bit tedious because I'm mobile right now.

• I used Polymorphism to solve this. I have a base "Event"-Class for example that also has a "Update" method. To move the Character with an Event, I sublass event and pass the character as a parameter. within the update Method I move the player around. – Raildex Oct 6 '16 at 7:49

You could develop a bytecode language for this. Take a look at this: http://gameprogrammingpatterns.com/bytecode.html

Instead of spells as in that example, see the commands as 'walk to' and 'display message' and so on.