Legacy GM [SOLVED] Footstep Sound Help

L

Ludicrous Raptor

Guest
Hello People Of The Internet I Cant Figure Out How To Put A Walking Sound In My Game Without Sounding Like A Machine Gun On Steroids Can You Help Here Is My Movement Code.

Code:
//Camera Movement With Mouse
window_mouse_set(window_get_width() / 2, window_get_height() / 2);

if (mouse_x < 640) {
    target_dir = target_dir + ((1 + mouse_x) / 640);
}

if (mouse_x > 640) {
    target_dir = target_dir - ((1 + mouse_x) / 640);
}

//Movment With W,A,S,D (WALKING)
var forward = keyboard_check(ord('W'));
var backward = keyboard_check(ord('S'));
var right = keyboard_check(ord('D'));
var left = keyboard_check(ord('A'));

if(forward){
    var vect_x = lengthdir_x(2,target_dir);
    var vect_y = lengthdir_y(2,target_dir);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;   
    if(place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x -= vect_x;
        target_y -= vect_y;
    }
    }
    }

if(backward){
    var vect_x = lengthdir_x(2,target_dir);
    var vect_y = lengthdir_y(2,target_dir);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x -= vect_x;
        target_y -= vect_y;
    if(place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
    }
    
if(left){
    var vect_x = lengthdir_x(1, target_dir + 90);
    var vect_y = lengthdir_y(1, target_dir + 90);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
    
if(right){
    var vect_x = lengthdir_x(1, target_dir - 90);
    var vect_y = lengthdir_y(1, target_dir - 90);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
 
Hello People Of The Internet I Cant Figure Out How To Put A Walking Sound In My Game Without Sounding Like A Machine Gun On Steroids Can You Help Here Is My Movement Code.

Code:
//Camera Movement With Mouse
window_mouse_set(window_get_width() / 2, window_get_height() / 2);

if (mouse_x < 640) {
    target_dir = target_dir + ((1 + mouse_x) / 640);
}

if (mouse_x > 640) {
    target_dir = target_dir - ((1 + mouse_x) / 640);
}

//Movment With W,A,S,D (WALKING)
var forward = keyboard_check(ord('W'));
var backward = keyboard_check(ord('S'));
var right = keyboard_check(ord('D'));
var left = keyboard_check(ord('A'));

if(forward){
    var vect_x = lengthdir_x(2,target_dir);
    var vect_y = lengthdir_y(2,target_dir);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;  
    if(place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x -= vect_x;
        target_y -= vect_y;
    }
    }
    }

if(backward){
    var vect_x = lengthdir_x(2,target_dir);
    var vect_y = lengthdir_y(2,target_dir);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x -= vect_x;
        target_y -= vect_y;
    if(place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
    }
   
if(left){
    var vect_x = lengthdir_x(1, target_dir + 90);
    var vect_y = lengthdir_y(1, target_dir + 90);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
   
if(right){
    var vect_x = lengthdir_x(1, target_dir - 90);
    var vect_y = lengthdir_y(1, target_dir - 90);
    if(!place_meeting(target_x+vect_x, target_y+vect_y, obj_wall)){
        target_x += vect_x;
        target_y += vect_y;
    }
    }
I see 0% code that pertains to sound... where is it? :confused:
 
L

Ludicrous Raptor

Guest
I see 0% code that pertains to sound... where is it? :confused:
I removed the sound I added because it kept breaking I meant where would the sound code go because when ever I put it in any of if statements for moving, it repeats its self so much and sounds more like a machine gun and less like walking
 
L

Ludicrous Raptor

Guest
Do you get what I mean Or have I confused you more?
 
Do you get what I mean Or have I confused you more?
Oh okay I understand, you want us to find a place for your sound code? That's not too hard if you want it for footsteps.
Now I don't know how your game runs or what kind of mechanics are involved, but if you want something simple I suggest you try something like this:
Code:
if(forward)
{
//This code checks for a sound playing... if not:
    if (!audio_is_playing(sound_footstep))
    {
//Play footstep sound
        audio_play_sound(sound_footstep, 5, false);
    }
    var vect_x = lengthdir_x(2,target_dir);
    var vect_y = lengthdir_y(2,target_dir);

(The rest of your code...)
All you need to do is check if the sound is playing, and then only play the sound after it's played once. It wont sound like a machine gun.
Place the same code in the rest of the keyboard check if statements and it should work in all directions. :)
 
Top