Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: d1mpz on Fri 25/05/2012 14:29:55

Title: How do i add a video intro at the beginning of my game?
Post by: d1mpz on Fri 25/05/2012 14:29:55
I am an extremely new user to AGS. I am creating a point and click adventure game for my college assignment. I have done all my design work and am now about to start creating my game. How do I add a video intro for the game.
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Fri 25/05/2012 14:55:46
Use the PlayVideo command: PlayVideo (string filename, VideoSkipStyle, int flags)

It's fully documented in the manual, and you can call it from the game's starting room's "after_fadein" event.

AGS supports quite a lot of video formats too, and for an assignment I think download size isn't a factor, but keep in mind that fullscreen videos can blow up file size easily (without an impact on performance, though).

Best of luck with the project, by the way! Always cool to see AGS used in college projects!

Title: Re: How do i add a video intro at the beginning of my game?
Post by: d1mpz on Fri 25/05/2012 15:19:39
Thank you for your fast reply. However i have tried the playVideo command but i still keep getting errors. I have looked through the manual and it does not specify where to paste the code. I have tried directly at the beginning of the room script and the error below is all i keep receiving.

Failed to save room room1.crm; details below
room1.asc(3): Error (line 3): Parse error: unexpected 'PlayVideo'

Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Fri 25/05/2012 15:39:18
I see. Have you just typed that line into the script? If yes, then this does not work. You need to set up an event handler, like this:

- open the room ("edit room") and click on that small "flash" button in the bottom right panel.
- click on "enter room after fadein" to create the event handler

Now, in the room script, you have the following code:

function room_AfterFadeIn()
{
}

Add the command between the brackets- this is how you set up a code handler in AGS.

Note: Whenever you want AGS to process code depending on "engine events" (like clicking on something, entering a room, or using an item on something else) you need to set up an event handler!
Title: Re: How do i add a video intro at the beginning of my game?
Post by: d1mpz on Fri 25/05/2012 16:02:20
Thanks very much, problem fixed. I had  the avi file in the wrong place and was missing small bits of coding.

function room_AfterFadeIn() {
  PlayVideo("testing.avi", eVideoSkipEscKey, 0);
}
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 09:55:24
I'm trying to loading the intro to my game, I've set all like above (put the file in the game folder with ogg extension).
Black screen and then starts room_2

The only code is this or I need to change something else?
Code (AGS) Select
function room_AfterFadeIn()
{
PlayVideo("Indy_Intro.ogg",eVideoSkipNotAllowed, 0);
}
Title: Re: How do i add a video intro at the beginning of my game?
Post by: Khris on Wed 06/06/2012 10:34:28
Try naming it "Indy_Intro.ogv" (http://www.adventuregamestudio.co.uk/manual/PlayVideo.htm)
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 11:08:26
Well, after some tries I managed to start the video :)

-Converted in ogv
-Put in game folder as "Intro"
-Setting the code with "Intro.ogv"

Now I ask: I need a new blank room to load properly? Because if I load it in the main first room seems not working properly...
Title: Re: How do i add a video intro at the beginning of my game?
Post by: Khris on Wed 06/06/2012 11:51:11
If you uncheck "hide known file extensions" in Windows' folder settings, you'll always see the complete filename.

What does "seems not working properly" mean? We can't read your mind nor see what's happening on your screen.
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 12:21:50
Basically what I want to do is this:

Loading the video (and this works), but when it loads the GUI and the player appears for 1 second and then the video loads. I want to turn off the GUI and the player and then after video has played start my other script for that room.
Title: Re: How do i add a video intro at the beginning of my game?
Post by: Khris on Wed 06/06/2012 12:39:33
In the room's before fadein event (function room_Load), call

Code (ags) Select
  gMaingui.Visible = false;  // replace gMaingui with whatever your GUI is called
  player.Transparency = 100;


Set the values back to true/0 after the PlayVideo call.
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 12:42:01
Thanks! your help is much appreciated, i don't know why there is no music along with intro video but i will try to solve...
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 14:42:58
To be clear once for all, here what happens when the game starts:

(http://s13.postimage.org/mbaoyfp7r/start.jpg)

And here is my code:

Code (AGS) Select
function room_FirstLoad()
{

PlayVideo("Intro.ogv",eVideoSkipEscKey, 0);

gAction.Visible = false;
gMaingui.Visible = false;
cEgo.Transparency = 100;

player.ChangeRoom(1, 185, 91);
}


Even if I've set that code the GUI still appears for just a second and then video starts. And the intro plays without music.
Title: Re: How do i add a video intro at the beginning of my game?
Post by: arj0n on Wed 06/06/2012 15:53:14
Quote from: Guybrush379 on Wed 06/06/2012 14:42:58
Even if I've set that code the GUI still appears for just a second and then video starts. And the intro plays without music.
Why first the playvideo command followed by the gui's and character commands?
Shouldn't that be the other way around?

b.t.w. Can you send me/upload the video file so I can analyse it?
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 15:59:05
Quote
Why first the playvideo command followed by the gui's and character commands?
Shouldn't that be the other way around?

It doesn't change at all, even if I use After Room fade in and put the right way I still got the 1 second GUI + action showing before video. The video is fine if I launch with VLC...
Title: Re: How do i add a video intro at the beginning of my game?
Post by: Khris on Wed 06/06/2012 16:45:20
Like I said in my previous post, turn off the GUI and character in the room_Load function, which is associated with a different event, before fadein.

After you've clicked the ...-Button next to "enters room before fadein" and the function is created, the script should look like this:

Code (ags) Select
function room_Load()
{
  // this code is executed while the screen is still black
  gAction.Visible = false;
  gMaingui.Visible = false;
  cEgo.Transparency = 100;
}

function room_FirstLoad()
{
  // this is executed after AGS has faded in the room
  PlayVideo("Intro.ogv",eVideoSkipEscKey, 0);
  player.ChangeRoom(1, 185, 91);
}


(The order of the functions doesn't matter.)
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 17:49:05
The audio now works fine (I've switched from office pc to my home pc but I think was a problem of ogg compression, now I have avi and it works).

Now the properties are more clear and when use them but unfortunately I still got that 1 second GUI before my video... :(
Title: Re: How do i add a video intro at the beginning of my game?
Post by: Khris on Wed 06/06/2012 18:01:45
It could be that AGS doesn't start faded out at the very beginning...
In that case, set both GUIs' visibility to "Normal, initially off" and change the player character's y starting position to -1
Title: Re: How do i add a video intro at the beginning of my game?
Post by: on Wed 06/06/2012 18:54:01
YES YES!! :) I've finally solved it! Damn, if you leave some values or even a string in bad position is such going madly thing!

Khris forget about the file I've sent you (it even contains scurrile bad language in italian in the library room! :)

I've created a new blank room with the proper value for starting the video and then changeRoom value
Now works very good as I wanted! I'm happy :)