Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Sound Problem  (Read 766 times)

0 Members and 1 Guest are viewing this topic.
Sound Problem
« on: June 26, 2007, 08:52:28 pm »
  • The king of Awesome
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 198
Well when I try to play a sound, sound_loop(Run); it plays to fast but I need it to loop when I run.

Any idea's? it plays fine when I play it from the sound, just not in game. 


Double tap script
Code: [Select]
//Left Key
if (keyboard_check(vk_left) && global.movespeed < 6) {
if global.tap = 1{global.movespeed=2}
if global.tap = 2{global.movespeed=6}
}
if keyboard_check_pressed(vk_left) {
if alarm[0] > 0{global.tap = 2}
else
{global.tap = 1; alarm[0] = 10}
}

if keyboard_check_released(vk_left) {
global.tap = 0
global.movespeed=3
}
if (keyboard_check(vk_right) && global.movespeed < 6) {
if global.tap1 = 1{global.movespeed=2}
if global.tap1 = 2{global.movespeed=6}
}
if keyboard_check_pressed(vk_right) {
if alarm[1] > 0{global.tap1 = 2}
else
{global.tap1 = 1; alarm[1] = 10}
}

if keyboard_check_released(vk_right) {
global.tap1 = 0
global.movespeed=3
}
if (keyboard_check(vk_up) && global.movespeed < 6) {
if global.tap2 = 1{global.movespeed=2}
if global.tap2 = 2{global.movespeed=6}
}
if keyboard_check_pressed(vk_up) {
if alarm[2] > 0{global.tap2 = 2}
else
{global.tap2 = 1; alarm[2] = 10}
}

if keyboard_check_released(vk_up) {
global.tap2 = 0
global.movespeed=3
}
if (keyboard_check(vk_down) && global.movespeed < 6) {
if global.tap3 = 1{global.movespeed=2}
if global.tap3 = 2{global.movespeed=6}
}
if keyboard_check_pressed(vk_down) {
if alarm[3] > 0{global.tap3 = 2}
else
{global.tap3 = 1; alarm[3] = 10}
}

if keyboard_check_released(vk_down) {
global.tap3 = 0
global.movespeed=3
}

walking/running script
Code: [Select]
// LINK MOVEMENT ENGINE by GOODNIGHT
var fholdd, fholdu, fholdl, fholdr, cc;
script1()
// Check keys
holdd=keyboard_check(vk_down)
holdu=keyboard_check(vk_up)
holdl=keyboard_check(vk_left)
holdr=keyboard_check(vk_right)
// Cancel opposing keys
if holdu && holdd {
    holdu=0
    holdd=0
}
if holdl && holdr {
    holdl=0
    holdr=0
}


// This is where you may want to add other conditionals which keep you from moving,
// such as if you are using an item, or you are in a menu.
// Just add the conditions to the end of this next "if" line.
// example:
// if (holdd ||holdu || holdl || holdr) && !usingshield {

if holdd ||holdu || holdl || holdr {
    // If you are holding any key, start moving.
    // Change Link's direction if you weren't already moving.
    if !moving {
        if holdd { global.facing="D" }
        else if holdu { global.facing="U" }
        if holdl { global.facing="L" }
        else if holdr { global.facing="R" }
    }
    moving=1
    // Direction correction:
    // Get the correct sprite when you walk diagonally then release one arrow.
    if (holdd && !holdl && !holdr) { global.facing="D" }
    else if (holdu && !holdl && !holdr) { global.facing="U" }
    else if (holdl && !holdd && !holdu) { global.facing="L" }
    else if (holdr && !holdd && !holdu) { global.facing="R" }
    // Prevent direction glitches caused by inhuman keypress timing.
    if (holdd && holdl && global.facing!="D" && global.facing!="L") { global.facing="L" }
    else if (holdd && holdr && global.facing!="D" && global.facing!="R") { global.facing="R" }
    else if (holdu && holdl && global.facing!="U" && global.facing!="L") { global.facing="L" }
    else if (holdu && holdr && global.facing!="U" && global.facing!="R") { global.facing="R" }
// Stop moving if no key is held.
} else { moving=0 }

// If Link is attempting to move now,
if moving {
    // "charge up" the number of pixels to move during this step,
    movestep+=global.movespeed
    // prepare movement variables,
    xstep=0
    ystep=0
    // and start doing the movement.

    while movestep>=1 {

        // Corner-cutting loop. This for-loop determines if Link is blocked by a solid,
        // but is close enough to its edge to cut around it.
        // If so, a "fake hold" variable is set, and the engine acts as if that arrow key is held.
       
                // Feel free to change the initial "cc" variable for corner sensitivity.
        // Between 4 and 8 is recommended - even less if your solids have curved masks. Use 0 for none.

        fholdd=0; fholdu=0; fholdl=0; fholdr=0;
        for (cc=6; cc>0; cc-=1) {
            if holdu {
                // If you're walking upwards and blocked by a solid...
                if !place_free(x,y-1) {
                    // ...but pressing left or right, release the "up" key.
                    if holdl || holdr { holdu=0 }
                    // ...but close to the left edge, and NOT holding left or right, and not fake-holding either, perform a fake left hold.
                    // And if you are only 1 pixel from the edge, also perform a fake up hold, to move diagonally through the corner.
                    else if place_free(x-cc,y-1) && !(fholdl || fholdr) { fholdl=1; fholdu=place_free(x-1,y-1) }
                    // Same as above, for the right edge.
                    else if place_free(x+cc,y-1) && !(fholdl || fholdr) { fholdr=1; fholdu=place_free(x+1,y-1) }
                }
            // Same thing transposed for the other three directions:
            } else if holdd {
                if !place_free(x,y+1) {
                    if holdl || holdr { holdd=0 }
                    else if place_free(x-cc,y+1) && !(fholdl || fholdr) { fholdl=1; fholdd=place_free(x-1,y+1) }
                    else if place_free(x+cc,y+1) && !(fholdl || fholdr) { fholdr=1; fholdd=place_free(x+1,y+1) }
                }
            }
            if holdl {
                if !place_free(x-1,y) {
                    if holdu || holdd { holdl=0 }
                    else if place_free(x-1,y-cc) && !(fholdu || fholdd) { fholdu=1; fholdl=place_free(x-1,y-1) }
                    else if place_free(x-1,y+cc) && !(fholdu || fholdd) { fholdd=1; fholdl=place_free(x-1,y+1) }
                }
            } else if holdr {
                if !place_free(x+1,y) {
                    if holdu || holdd { holdr=0 }
                    else if place_free(x+1,y-cc) && !(fholdu || fholdd) { fholdu=1; fholdr=place_free(x+1,y-1) }
                    else if place_free(x+1,y+cc) && !(fholdu || fholdd) { fholdd=1; fholdr=place_free(x+1,y+1) }
                }
            }
        }
        // End corner-cutting loop.

        // Determine the number of pixels to move horizontally and vertically (-1, 0, or 1).
        xstep=(holdr || fholdr)-(holdl || fholdl)
        ystep=(holdd || fholdd)-(holdu || fholdu)
        // If you can move hor. and vert. at the same time, do so.
        if place_free(x+xstep,y+ystep) {
            x+=xstep
            y+=ystep
        } else {
            // Otherwise, just move in the direction that you can.
            if place_free(x+xstep,y) { x+=xstep }
            else if place_free(x,y+ystep) { y+=ystep }
        }
        // If you only moved up, down, left, or right, take 1 (pixel) off your movement steps.
        // If you moved diagonally, take the square root of 2 (about 1.41) off your movement steps.
        // Allowing less diagonal movements per step gives the proper 'slowdown' effect.
        if xstep!=0 && ystep!=0 { movestep-=sqrt(2) }
        //if ((holdd || holdu) && (holdl || holdr)) || ((fholdd || fholdu) && (fholdl || fholdr)) { movestep-=sqrt(2) }
        else { movestep-=1 }
    }

    // Wall-pushing detection code.
    // Just to clarify, Link's pushcount activates his pushing animation,
    // while the block's pushcount activates its movement.

    // If you weren't moving diagonally, and weren't able to move, check for a solid for Link to push.
 
                // and it's not already moving,
               




    // Set the right sprite when you are moving.
    // If Link has been pushing for at least 15 steps, use the pushing animation.
     if global.movespeed=6 {
        switch global.facing {
        case "D": sprite_index=spr_goku_run_d; break;
        case "U": sprite_index=spr_goku_run_u; break;
        case "L": sprite_index=spr_goku_run_l; break;
        case "R": sprite_index=spr_goku_run_r; break;
        }
        // (Which is slightly slower than the running animation.)
                image_speed=animspeed
    // Otherwise, use the running animation.
    } else {
        switch global.facing {
        case "D": sprite_index=spr_goku_walk_d; break;
        case "U": sprite_index=spr_goku_walk_u; break;
        case "L": sprite_index=spr_goku_walk_l; break;
        case "R": sprite_index=spr_goku_walk_r; break;
        }
        global.movespeed=3
        image_speed=animspeed
    }
// If Link is not moving this step,
} else {
    // Set the right standing sprite.
    switch global.facing {
        case "D": sprite_index=spr_goku_stand_d; break;
        case "U": sprite_index=spr_goku_stand_u; break;
        case "L": sprite_index=spr_goku_stand_l; break;
        case "R": sprite_index=spr_goku_stand_r; break;
    }
    movestep=0
}

// Almighty depth leverage technique
depth=-y

// end of Link Movement
Logged

Goodnight

Once and future Captain
Re: Sound Problem
« Reply #1 on: June 27, 2007, 08:01:25 pm »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Hoy there. I didn't see sound_loop(Run) anywhere in either of those scripts, but I'm guessing the problem is that you have it in the Step event, so it starts over 30 times each second.

If that's true, then put this line right before it:
if !sound_isplaying(Run)
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.054 seconds with 38 queries.