5 registered members (AndrewAMD, SBGuy, Petra, flink, 1 invisible),
699
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
snd_play on key press?
#125351
04/21/07 00:32
04/21/07 00:32
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
This code I THOUGHT would play a sound when I hit the "j" key. Instead, it plays at startup and if i do press the "j" key, the engine aborts with "acknex.exe has encountered a problem..."! Is this not the right code for it? Code:
on_j= smb_jump();
...
function smb_jump() { snd_play (jump_snd,100,0); }
I already tried a while() loop, but all that does is play the sound every frame cycle, and that gets really annoying. So, can anyone help?
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
Re: snd_play on key press?
[Re: MrCode]
#125352
04/21/07 00:51
04/21/07 00:51
|
Joined: Oct 2003
Posts: 1,258 Virginia, USA
qwerty823
Senior Developer
|
Senior Developer
Joined: Oct 2003
Posts: 1,258
Virginia, USA
|
Quote:
This code I THOUGHT would play a sound when I hit the "j" key.
Instead, it plays at startup and if i do press the "j" key, the engine aborts with "acknex.exe has encountered a problem..."!
Is this not the right code for it?
Code:
on_j= smb_jump();
...
function smb_jump() { snd_play (jump_snd,100,0); }
I already tried a while() loop, but all that does is play the sound every frame cycle, and that gets really annoying.
So, can anyone help?
Common mistake.
on_j = smb_jump(); // This *runs* the function smb_jump, and assigns its return to on_j
on_j = smb_jump; // This assigns the function itself to on_j
You want the second one.
Never argue with an idiot. They drag you down to their level then beat you with experience
|
|
|
Re: snd_play on key press?
[Re: qwerty823]
#125353
04/21/07 02:29
04/21/07 02:29
|
Joined: Mar 2007
Posts: 677 0x00000USA
MrCode
OP
User
|
OP
User
Joined: Mar 2007
Posts: 677
0x00000USA
|
Parameter unknown smb_jump. is there something else I'm missing? Here's the whole Code:
var video_mode= 8; var video_screen= 1; var video_depth= 32;
var walk_speed; var breath_speed; var jump_speed;
string anim_wmb= <JumpDude.wmb>;
string keys_str= "Use the arrow keys to move around."; string keys2_str= "Press the J key to jump."; string keys3_str= "Press I to see these instructions again.";
sound jump_snd= <smb_jumpsmall.wav>;
bmap intro_pcx= "jdudeintro.pcx";
function main() { level_load (anim_wmb); wait(3); camera.x= -48; camera.y= 334; camera.z= 149; camera.pan= 281; camera.tilt= -48; camera.roll= 0; pan_fade(); txt_show(); show_again(); on_j= smb_jump; }
action char_walk { my.fat= on; my.narrow= on; c_setminmax(my); while(1) { if(key_cuu== on) { c_move(my,vector(0,6 * time_step,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= 7 * time_step; } else { ent_animate(my,"stand",breath_speed,anm_cycle); breath_speed+= 3 * time_step; } if(key_cud== on) { c_move(my,vector(0,-6 * time_step,0),nullvector,glide); ent_animate(my,"walk",walk_speed,anm_cycle); walk_speed+= -7 * time_step; } if(key_cul== on) { my.pan+= 10 * time_step; } if(key_cur== on) { my.pan-= 10 * time_step; } if(key_j== on) { c_move(my,vector(0,0,15 * time_step),nullvector,glide); ent_animate(my,"jump",jump_speed,anm_cycle); jump_speed+= 14 * time_step; } else { c_move(my,vector(0,0,-15 * time_step),nullvector,glide); } wait(1); } }
panel intro { pos_x= 0; pos_y= 0; bmap= intro_pcx; flags= transparent, overlay, visible; alpha= 100; }
font big_fnt= "Times New Roman",1,20;
text keys_txt { pos_x= 384; pos_y= 550; font= big_fnt; string= keys_str; }
function pan_fade() { wait(-2); while(1) { intro.alpha-= 3 * time_step; wait(1); } }
function txt_show() { wait(-3); keys_txt.visible= on; wait(-3); keys_txt.string= keys2_str; wait(-3); keys_txt.string= keys3_str; wait(-3); keys_txt.visible= off; }
function show_again() { while(1) { if(key_i== on) { keys_txt.visible= on; wait(1); keys_txt.string= keys_str; wait(-3); keys_txt.string= keys2_str; wait(-3); keys_txt.string= keys3_str; wait(-3); keys_txt.visible= off; } wait(1); } }
function smb_jump() { snd_play(jump_snd,100,0); }
void main()
{
cout << "I am MrCode,";
cout << "hear me roar!";
system("PAUSE");
}
|
|
|
|