Randomized video play for “loading” scenes

Started by Barn Owl, Sat 10/05/2025 22:45:59

Previous topic - Next topic

Barn Owl

Hi all, hope everyone is well.

I am considering adding some fake loading scenes to my room transitions. The type of thing where there's a still image of the characters on the beach or getting lunch and says "loading". Of course it wouldn't actually be loading, it would just serve the purpose of adding more personality to the experience.

So let's say we've got load1.ogv, load2.ogv and load3.ogv, and we don't want the same one to always play when cEgo exits room 1 and enters room 2. The goal instead would be to have one of the loadX.ogvs randomly selected when transitioning between rooms.

And of course the randomized selection would only be between the LoadXs, not any other ogvs from the game folder.

Can anyone point me in the right direction of scripting this?

All help is greatly appreciated!

Rik_Vargard

#1
When the player leaves the room, you could, at that moment, create a code like this one:

Code: ags
int load = Random (2); // if you have three videos (random from 0 to 2)

if (load == 0) PlayVideo ("Load1.ogv", eVideoSkipNotAllowed, 21);
else if (Load == 1) PlayVideo ("Load2.ogv", eVideoSkipNotAllowed, 21);
else PlayVideo ("Load3.ogv", eVideoSkipNotAllowed, 21);

player.ChangeRoom (room number, etc);

But since I'm a beginner, too, there migtht be a better way to do this  (laugh)

Barn Owl

Thanks! That looks good, I will give it a try!

Crimson Wizard

If that's a "still image of the characters on the beach or getting lunch and says "loading"", then why use videos, and not a sprite?

Barn Owl

#4
Quote from: Crimson Wizard on Sun 11/05/2025 01:13:25If that's a "still image of the characters on the beach or getting lunch and says "loading"", then why use videos, and not a sprite?

Good question, I was unclear on that. My idea is to present a static image background with the word "Loading" animated in some way on top of it. So technically an animated image.

I may also use the same idea when cEgo switches on a tv, a random show/commercial is played, and in that case it would be a regular video clip. So those are the reasons for ogvs instead of sprites.

The loading scenes might also use a Ken Burns effect.

Crimson Wizard

#5
Animations may also be played with sprites, that's a standard way to do that, unless it's a too complex fullscreen animation.

Quote from: Barn Owl on Sun 11/05/2025 03:08:05The loading scenes might also use a Ken Burns effect.

I had to search for this, and if I understand it right, this may be easily done by moving and scaling a static sprite around the screen, or scrolling and zooming a room camera.

Barn Owl

I see. While I'm a newb with AGS script, I'm fairly experienced with video editing. So it's sometimes a shortcut for me to play the .ogv.

That said, the moving/scaling sprite makes sense, and that is once again helpful and noted.

Thanks Crimson Wizard & Rik_Vargard! I enjoy learning this and appreciate all guidance.

Khris

This will probably require thinking about room transitions. You can completely customize those if you turn off the built-in ones (i.e. setting them to "Instant" in General Settings -> Visual).

Next, using a global event is the proper way to do this. I'd personally go with eEventEnterRoomBeforeFadein:

Code: ags
void DoRandomTransition()
{
  String videofile = String.Format("transition%d.ogv", Random(2) + 1);
  PlayVideo(videofile, eVideoSkipAnyKeyOrMouse, 10);
}

function on_event(EventType event, int data)
{
  // only do a transition for room 3 and above
  if (event == eEventEnterRoomBeforeFadein && data >= 3) DoRandomTransition();
}

Barn Owl

Quote from: Rik_Vargard on Sat 10/05/2025 22:57:47When the player leaves the room, you could, at that moment, create a code like this one:

Code: ags
int load = Random (2); // if you have three videos (random from 0 to 2)

if (load == 0) PlayVideo ("Load1.ogv", eVideoSkipNotAllowed, 21);
else if (Load == 1) PlayVideo ("Load2.ogv", eVideoSkipNotAllowed, 21);
else PlayVideo ("Load3.ogv", eVideoSkipNotAllowed, 21);

player.ChangeRoom (room number, etc);

But since I'm a beginner, too, there migtht be a better way to do this  (laugh)

This worked, and I think it just ratcheted the fun of playing up another notch.

Thanks again!

Khris

Just to clarify, you aren't putting that code into every single room's onLeave event, are you?

Barn Owl

Quote from: Khris on Wed 14/05/2025 11:02:57Just to clarify, you aren't putting that code into every single room's onLeave event, are you?

For now, yes I am. The reason is because there are certain times I want an exception to the rule... For instance lets say room 1 to room 2 is unremarkable, so a randomized loading scene adds somr flair of personality. However, room 2 to room 3 triggers a jump scare which is more effective if it happens instantly without the a randomized loading scene. So, for now, copy & pasting on most onLeaves is okay. However, this is my initial learning experience with AGS, and it is a bit exploratory & experimental.

I see your recommendation to add the global script instead of the room by room scripts. And that is clearly a more efficient way to go about it. Yet because of the aforementioned exceptions, and my comprehension of AGS script being that of an infant aardvark, I think the copy/paste on all onLeaves will achieve my goal for now.

I'm in a learning process that if I had hired myself I would have already fired myself. It's going to take time and patience. Yet the game is taking shape and coming to life slowly but surely.

I really appreciate the pointers, Khris, and I will continue to experiment and become more proficient and efficient with the assistance of excellent folks like yourself!

Khris

I understand, but I have to point out that my method allows to easily check which room you're entering.

Like:

Code: ags
function on_event(EventType event, int data)
{
  if (event == eEventEnterRoomBeforeFadein) {
    if (data <= 2) return; // do nothing for room 1 and 2
    else if (data == 5 || data == 8) DoJumpScareTransition();
    else DoRandomTransition();
}

Note that I have again used the eEventEnterRoomBeforeFadein event as opposed to eEventLeaveRoom because I imagine the type of transition is primarily determined by the room the characters are entering, not the one they're leaving.
There's also a room event that only triggers when the room is entered for the first time, in case you don't want the jump scare to happen each time the room is visited.

I'm not sure how useful it is to learn bad stuff you'll have to unlearn later, especially in this case where doing it right isn't exactly rocket science :)
Anyway, just wanted to drop the "correct" way for reference.

SMF spam blocked by CleanTalk