Input Layout and more!


So! New stuff, new stuff. But before getting to that, I am sorry, but a few things within have changed names…and I haven’t kept track too well. But from memory:

  • struct_get() has become data_get() and has been moved away from the scr_bhg_structs file.
  • What’s now variable_struct_get_set_fallback() and variable_struct_get_set_typed_fallback() is renames of methods I already forgot the old names of.

There may be one or two others, but I am not sure… (again, sorry) I have also restructured the folders to (within the “Bless Hay Gaming Utils” folder) be divided in a “Core” folder and an “Extras” folder. “Core” is some very general stuff, and things related to GameMaker’s asset and value types. Generally the script files within are not dependent on other scripts or objects (except the scr_bhg_ALWAYS_INCLUDE script, in some cases). Stuff in “Extras” are, well extra things. More complex structs, constructors and objects, often relying on other scripts themselves.

New stuff

I have added a few smaller methods here and there, but the main thing of this update is the InputLayout constructor and accompanying scripts as well as InputHelper object. Quite a mouthful, but in short it allows you to setup input layouts with multiple input types (keyboard, gamepad, mouse) being keyed to the same input references. For example, you may make a layout with the references “left”, “right” and “up”, where fx. “left” will check on both vk_left, ord("A") and gp_padl. Also added some custom macros for a few extra inputs, like direction-specific joysticks on gamepads.

As with the rest of this pack, you will have to look into the code to see how it is used, which may be hard with something of this size but… That’s just how it is :) But hey, a small snippet to give you an idea:

// Create
globalvar playerInput;
playerInput = new InputLayout({ name: "player" });

playerInput.set({
	left: [vk_left, ord("A"), m_move_left, gp_axisl_left],
	right: [vk_right, ord("D"), m_move_right, gp_axisl_right],
	up: [vk_up, ord("W"), m_move_up, m_wheel_up, gp_axisl_up],
	down: [vk_down, ord("S"), m_move_down, m_wheel_down, gp_axisl_down],
});


// Step
if (playerInput.check("left")) {
	x -= 10;
}
if (playerInput.check("right")) {
	x += 10;
}

if (playerInput.checkDoublePressed("left")) {
	x -= 100;
}
if (playerInput.checkDoublePressed("right")) {
	x += 100;
}

if (playerInput.anyPressed()) {
	Debug.message("Pressed:", playerInput.pressed());
}

Sincerely, Simon

Files

bhg_utils.yymps 70 kB
Feb 27, 2021

Get Bless Hay Gaming Utils for GameMaker:Studio 2

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.