Jump to content


Jakup

Member Since 13 Mar 2012
Offline Last Active Apr 29 2012 06:42 PM

Topics I've Started

2 animations in one event

24 March 2012 - 12:34 AM

Hi, I'm having a problem with using 2 animations in one event. My problem is that when I'm changing to the second animation, the first one comes right back before the second one even loops once.

I have 2 sprites:

spr_t_runrightstart :
5 sub-images - loop once
used when character starts running

spr_t_runright :
6 sub-images - loop as long as shift + direction key is being held down
used when spr_t_runrightstart animation ends

I'm not sure where the error could be, so here's all the code for my controls:
if ((keyboard_check_direct(vk_right)) && (place_free(x+maxRunSpeed,y))) {
    image_speed = 0.5                                                     // Allow animations
    if (keyboard_check_direct(vk_control)) {                              // Sneaking ?
        hspeed = maxRunSpeed * 0.1                                        // Sneak speed : 10% of max run speed
        if !(place_free(x,y+1)) {                                         // On ground ?
            sprite_index = spr_t_sneakright
        } else {                                                          // In air ?
            sprite_index = spr_t_jumpkickright
        }
    } else if (keyboard_check_direct(vk_shift)) {                         // Running
        hspeed = maxRunSpeed                                              // Run speed : 100%
        if !(place_free(x,y+1)) {                                         // On ground ?
            if (sprite_index != spr_t_runright) {                         // If animation isn't spr_t_runright
                sprite_index = spr_t_runrightstart                        // Set animation to spr_t_runrightstart
            }
            if (sprite_index = spr_t_runrightstart) {                     // If animation is spr_t_runrightstart
                if (image_index = (image_number - 1)) {                   // And animation ended
                    sprite_index = spr_t_runright                         // Set animation to spr_t_runright
                }
            }
        } else {                                                          // In air ?
            sprite_index = spr_t_jumpright
        }
    } else {                                                              // Walking
        hspeed = maxRunSpeed * 0.5                                        // Walk speed : 50% of max run speed
        if !(place_free(x,y+1)) {                                         // On ground ?
            sprite_index = spr_t_walkright
        } else {                                                          // In air ?
            sprite_index = spr_t_jumpright
        }
    }
}

If you find my code to be not optimal, don't hesitate to tell me how to do it in a better way :P
I appreciate any help

Regards,
Jakup

Weird collision problems

22 March 2012 - 12:36 PM

Hi

I have an object called InvisibleBlock41x41 that is solid, which I use to point out blocks that you can't move through.
I don't know if it's relevant, but the sprite is a transparent blue color, so you can see what's behind it in the room editor.

I'm having weird problems with when you jump towards the corner of the block, if you hit exactly the corner, my character falls through. This is the only time I have noticed this happen.
I've had lots of collision problems before, which I've fixed by looking at the forums and various places for "normal" problems.
I have unchecked precise collision checking on all my moving objects.

I'm not sure where the problem lies, but I'm obviously thinking it's in the collision event:

if vspeed > 0 && !place_free (x,y+vspeed) {
    move_contact(270)
}
vspeed = 0

Anyone know what could be the problem? I'll gladly post more of the code if needed :)

Regards,
Jakup