play sound once at title screen

rafhot

Member
im trying to play a sound as an announces speeching "Fantastic Four!" at the tittle screen of my game but i cannot make it to stop looping
im using in updated.c
those lines:

Code:
void main ()
{
	int SFX1 = loadsample("data/sounds/FF.wav");
	int count = 0;

	if(openborvariant("in_titlescreen"))//||openborvariant("in_menuscreen")
	{
		while(count<=0)
		{
	          playsample(SFX1, 0, 120, 120, 100, 0);
		  count=1; //count++;
		}
        }
}

what i need to do in updated.c to increase my counter and make it stop play more than once?
 
thanks!

Code:
void main ()
{

	if(openborvariant("in_titlescreen"))//||openborvariant("in_menuscreen")
	{	
                void contador = getlocalvar("contador"); 
		int SFX1 = loadsample("data/sounds/FF.wav");
		while(contador!=1)
		{
	        playsample(SFX1, 0, 120, 120, 100, 0);
		contador = setlocalvar("contador",1);
		}
		
	}
}
 
Cool idea, I tried something like this and failed, I thought I'd ask about it before I try again myself using this script as a base.

I was trying to make it so when you are on 'stage complete' screen it will play an explosion sound effect if you press a key to skip it.

Also I've wanted to ask can you add script to a cutscene file? like an @script or @cmd to play a sound effect at a certain frame of a .GIF anim ? or simply add playsound command that can be added between each .gif

example.

music data/music/mytrack.ogg
animation data/scenes/part1.gif
@cmd playsound "boom.wav"
animation data/scenes/part2.gif


Being able to play sound based on .GIF frame position thou would be pretty cool thing to have thou.  It would allow creating cutscenes that have music and sfx handled separately. So music tracks don't need to have sfx added. 

If the music is also a level track it's one less music file to worry about, instead of two version one with music and sfx, one just music.
 
BeasTie said:
Cool idea, I tried something like this and failed, I thought I'd ask about it before I try again myself using this script as a base.

I was trying to make it so when you are on 'stage complete' screen it will play an explosion sound effect if you press a key to skip it.

Also I've wanted to ask can you add script to a cutscene file? like an @script or @cmd to play a sound effect at a certain frame of a .GIF anim ? or simply add playsound command that can be added between each .gif

example.

music data/music/mytrack.ogg
animation data/scenes/part1.gif
@cmd playsound "boom.wav"
animation data/scenes/part2.gif


Being able to play sound based on .GIF frame position thou would be pretty cool thing to have thou.  It would allow creating cutscenes that have music and sfx handled separately. So music tracks don't need to have sfx added. 

If the music is also a level track it's one less music file to worry about, instead of two version one with music and sfx, one just music.

love this idea ;D
 
Why not have an unskippable pre-title screen intro that's the "Fantastic Four," and then switch to a copy of the title screen where you would play remix.bor? Example...

[intro.txt]

music data/music/fantfour.bor 0
animation data/scenes/[first title screen].gif 0 0 0 1
music data/music/remix.bor 1
animation data/scenes/[copy of actual title screen].gif 0 0 0 1 <-- make this short, like a delay 10
 
Using this script to add sound to the game over screen.  (avoids having an extra music file)

How do I make it so it will play everytime? instead of just once per session?
 
I think that's what prevents the sound from looping over itself, which was rafhot's original problem.

I did try it, but the looping issue arises.
 
i have updated this long time ago but i forgot to post here

so now i use it to shout  "fantastic four" at title screen and also shout "select your hero!" at select screen
when player is at title screen it sets var to 0 to select screen be shouted, also when player are in select screen it set var to 0 for title screen,  so if player press esc on select screen it will be shouted again " fantastic four" in title screen

i hope it helps

Code:
void main() 
{

  void contador2 = getlocalvar("contador2");
void contador = getlocalvar("contador"); 

	if(openborvariant("in_selectscreen"))
	{
	
	    inTitleLoop(1); 
        	
		//void contador2 = getlocalvar("contador2"); 
		int SFX1 = loadsample("data/sounds/syh.wav");
		while(contador2!=1)
		{
	     playsample(SFX1, 0, 120, 120, 100, 0);
		contador2 = setlocalvar("contador2",1);
		contador = setlocalvar("contador",0); //reseta o contador da tela do titulo
		}
	
	
	
		
	}


	if(openborvariant("in_titlescreen"))//||openborvariant("in_menuscreen")
	{	
		//void contador = getlocalvar("contador"); 
		int SFX1 = loadsample("data/sounds/FF.wav");
		while(contador!=1)
		{
	     playsample(SFX1, 0, 120, 120, 100, 0);
		contador = setlocalvar("contador",1);
		contador2 = setlocalvar("contador2",0); //reseta o contador da tela de selecao de personagem
		}
		
	}
}
 
Cool! many thanks dude, I suspected something like this, but thought it best to ask first - glad I did! Much appreciated.

I also edited it to play additional sounds on select screen, new game, gameover and options menu.

This is for Fallout mod, it has the narrator's voice. 

PRESS START - 'War...War Never Changes...' (type 1)
NEW GAME    - 'Fallout... a post nuclear adventure'
SELECT SCREEN - 'War Never Changes' (type 2)
OPTIONS      -  'War Never Changes...' (type 3) (yeah repeating a bit , but how often you go to options? :p)

Also for GAME OVER screen I added random quotes

- You have died
- your life ends in the wasteland....
- you fought valiantly...but to no avail....
- etc.

I could listen to Ron Perlman reading the dictionary and it would still be entertaining.  ;D

---------------
Code for random in case someone needs an example

Code:
		if(openborvariant("in_gameoverscreen"))
	{	
        void contadorg = getlocalvar("contadorg"); 
		int SFX1 = loadsample("data/speech/NAR_4.wav");		
		int SFX2 = loadsample("data/speech/NAR_6.wav");
		int SFX3 = loadsample("data/speech/NAR_5.wav");
		int SFX4 = loadsample("data/speech/NAR_8.wav");
		int r = rand()%30;
		while(contadorg!=1)
		if( r > 11){
	    playsample(SFX1, 0, 120, 120, 100, 0);
		contadorg = setlocalvar("contadorg",1);
		}
		else if(r < -10){
		playsample(SFX2, 0, 120, 120, 100, 0);
		contadorg = setlocalvar("contadorg",1);
		}
		else if(r < 0){
		playsample(SFX3, 0, 120, 120, 100, 0);
		contadorg = setlocalvar("contadorg",1);
		}
		else if(r > 0){
		playsample(SFX4, 0, 120, 120, 100, 0);
		contadorg = setlocalvar("contadorg",1);
		}
	}
	
}

----

Also my other post in this thread from a while back, I'm still after solution to make sound play when it shows the COMPLETE SCREEN.  But only when the count ends or you press a key to skip the tally.
 
BeasTie said:
I think that's what prevents the sound from looping over itself, which was rafhot's original problem.

I did try it, but the looping issue arises.

Duh, my mistake, sorry.
I use that code on Avengers too, so I think I will update the code too :)
 
none of these work for me, do i need some setting in levels txt or models txt to make it work? Also  "     inTitleLoop(1); " makes the engine crash its probably from other c file which isnt included.
 
Back
Top Bottom