Main menu:
use media_loop()
Code:
//Volume for media
define MenuVol, 100;
//Sound File
string sndMMBG = "Menu.mp3";
//
var BGSound;
Function StartMenu()
{
BGSound = media_loop(sndMMBG, null, MenuVol);
}
Function EndMenu()
{
media_stop(BGSound);
}
Texture for footsteps:
Use a trace from the player to the ground. You can either name your textures starting with a x digit code such as dirtblabla.tga or graswhatever.bmp. Then in your trace include the flag scan_texture.
then you'd use string comparisons to get the tex name, copy and clip it to 4 (or so) digits, then use IF statements to figure out which sound to use...
Code:
//volume for footsteps
define StepVol, 100;
//
string tstr;
function PlayFootstep(Texname)
{
str_cpy(tstr, Texname);
var i;
i = str_len(tstr);
if (i < 5)
{return(0);}
i -= 4;
str_trunc(tstr, i);
//
if (str_cmpi(tstr, "dirt"))
{ent_playsound(my, sndStepDirt, StepVol); return(1);}
if (str_cmpi(tstr, "gras"))
{ent_playsound(my, sndStepGrass, StepVol); return(1);}
if (str_cmpi(tstr, "metl"))
{ent_playsound(my, sndStepMetal, StepVol); return(1);}
return(2);
}
Use:
call PlayFootstep(tex_name); after using a trace with the scan_texture flag.
returns:
0: the input string had less than enough characters
1: function ran successfully
2: No matching sound could be found
Code:
Function Footstep()
{
vec_set(temp, my.x);
temp.z -= 500;
c_trace(my.x, temp, scan_texture);
PlayFootstep(tex_name);
}