Legacy GM How to fix the bugged Gamepad controls in Hello Mario Engine

H

HenrikoNumberOne

Guest
Hello! I'm currently making a small Mario fan game using the Hello Mario Engine (a neat GMS project / game builder that has a lot of the features present in most Mario games and it's free to use!). It has worked like a charm, until I found about about the horrendous game pad controls!

What happens is that when using a game pad Mario won't jump correctly most of the time. Specifically, sometimes he will jump really short even though I've long pressed the jump button, and sometimes he won't even jump at all. He also sporadically jumps about at random even when I'm not pressing the jump button, which becomes very annoying when you're trying to complete tight platforming sections. This only happens when using a gamepad.

I've left an issue report on the project's GitHub page, but it has been inactive for more than a year so I don't expect any replies any time soon.

Then, I tried fixing this issue myself - but I can't seem to figure out the problem. I think it has something to do with the fact that the project uses gamepad_button_check_pressed(...) instead of gamepad_button_check(...), but I'm not entirely sure.

Here is the code for the step event that handles the game pad controls;

Code:
///Gamepad support
if gamepad
{
    //Up button
    if gamepad_button_check_pressed(0,gp_padu)
        keyboard_key_press(vk_up)
    else if gamepad_button_check_released(0,gp_padu)
        keyboard_key_release(vk_up)

    //Down button
    if gamepad_button_check_pressed(0,gp_padd)
        keyboard_key_press(vk_down)
    else if gamepad_button_check_released(0,gp_padd)
        keyboard_key_release(vk_down)

    //Left button
    if gamepad_button_check_pressed(0,gp_padl)
        keyboard_key_press(vk_left)
    else if gamepad_button_check_released(0,gp_padl)
        keyboard_key_release(vk_left)

    //Right button
    if gamepad_button_check_pressed(0,gp_padr)
        keyboard_key_press(vk_right)
    else if gamepad_button_check_released(0,gp_padr)
        keyboard_key_release(vk_right)

    //A button
    if gamepad_button_check_pressed(0,gp_face1)
        keyboard_key_press(vk_shift)
    else if gamepad_button_check_released(0,gp_face1)
        keyboard_key_release(vk_shift)

    //B button
    if gamepad_button_check_pressed(0,gp_face2)
        keyboard_key_press(vk_control)
    else if gamepad_button_check_released(0,gp_face2)
        keyboard_key_release(vk_control)

    //X button
    if gamepad_button_check_pressed(0,gp_face3)
        keyboard_key_press(ord('Z'))
    else if gamepad_button_check_released(0,gp_face3)
        keyboard_key_release(ord('Z'))

    //Start button
    if gamepad_button_check_pressed(0,gp_start)
        keyboard_key_press(vk_enter)
    else if gamepad_button_check_released(0,gp_start)
        keyboard_key_release(vk_enter)

    //Select button
    if gamepad_button_check_pressed(0,gp_select)
        keyboard_key_press(vk_space)
    else if gamepad_button_check_released(0,gp_select)
        keyboard_key_release(vk_space)

}
... and here is the "jumping section" code of Mario's step event;

Code:
//Handles Mario's jumping
if keyboard_check_pressed(vk_shift)
and disablecontrols = 0

//Make sure that Mario can jump
and ((jumpnow = 0
and state < 2)

//Allow Mario to jump off of Yoshi or a shoe while in midair
or (keyboard_check(vk_up)
and isduck = 0
and global.yoshi > 0)

//Allow propeller Mario to do his special jump
or (global.powerup = cs_propeller
and stompstyle = 0
and isduck = 0
and holding = 0))
{

    //Jump higher if Mario is running
    if abs(hspeed) > 2.8
        vspeed = -4.5

    //If Mario is not running
    else
    {

        //Jump high if you are frog Mario, and you are not riding anything
        if global.powerup = cs_frog
        and global.yoshi = 0
            vspeed = -4.5

        //Jump lower if you are not running
        else
        {

            //Jump even lower if you are walking super slowly
            if round(hspeed/2) = 0
                vspeed = -3.85

            //Jump slightly higher if you are walking
            else
                vspeed = -4.05

        }
    }
And of course, as this is a free project, you can download the entire thing and test it out for yourself if that's to any help.

Either way, any help would be very much appreciated!

- Henriko
 

Hello

Member
Change it so the A button presses and releases the alternate jump key ord('X') instead of vk_shift. There seems to be a bug somewhere that is causing problems when pressing the Shift key, and this workaround seems to make the problem go away.
 
H

HenrikoNumberOne

Guest
Change it so the A button presses and releases the alternate jump key ord('X') instead of vk_shift. There seems to be a bug somewhere that is causing problems when pressing the Shift key, and this workaround seems to make the problem go away.
Thanks!
 
Top