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 Yesterday at 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 Yesterday at 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();
}

SMF spam blocked by CleanTalk