To change controls in GameMaker, you are typically looking to customize either the GameMaker IDE's own keyboard shortcuts (hotkeys for development tasks) or the controls within a game you are developing using GameMaker. Both processes involve different methods.
Customizing GameMaker IDE Keyboard Shortcuts
GameMaker allows you to personalize the development environment by reassigning keyboard shortcuts for various commands. This can significantly speed up your workflow.
How to Reassign IDE Shortcuts:
- Access Preferences: Navigate to
File > Preferences
from the main menu bar. - Select Keyboard Shortcuts: In the Preferences window, look for the
Keyboard Shortcuts
section in the left-hand menu. - Find the Command:
- You'll see a list of commands organized by category.
- Use the
Search
bar at the top to quickly find a specific command (e.g., "Save Project," "Run Game").
- Reassign the Key Combination:
- Click on the command you wish to modify.
- In the "Key Combination" field, press the new key(s) you want to assign to that command.
- If the new combination is already in use by another command, GameMaker will notify you. You will then have an option to manage this conflict:
- Override (ALL) and Reassign: Pressing this option will assign the new key combination to your selected command and clear the bindings of all other commands that previously used the same combination. This ensures your chosen command has exclusive access to that shortcut.
- Alternatively, you can choose a different key combination or leave the conflicting command as is.
- Apply Changes: After making your adjustments, click
Apply
orOK
to save your new keybindings.
Practical Tips for IDE Shortcuts:
- Search Functionality: Leverage the search bar to quickly locate specific actions rather than browsing through all categories.
- Reset to Defaults: If you find your custom shortcuts confusing, you can always revert to the default GameMaker keybindings by clicking the
Reset All
button within the Keyboard Shortcuts preferences. - Commonly Changed Shortcuts: Consider customizing shortcuts for frequent actions like running the game, saving, opening specific editors (e.g., Object Editor, Room Editor), or commenting/uncommenting code.
For more detailed information on GameMaker's preferences, refer to the official GameMaker Preferences documentation.
Changing Controls Within a Game Made with GameMaker
When you're developing a game in GameMaker, "changing controls" refers to how you program the input actions (keyboard, mouse, gamepad) that players use to interact with your game. Making these controls user-changeable involves a different approach, primarily through GameMaker Language (GML) scripting.
How Game Controls are Programmed in GML:
In GameMaker, you typically use event-driven programming and GML functions to detect input.
Keyboard Controls:
You check the state of keys using functions like keyboard_check()
, keyboard_check_pressed()
, or keyboard_check_released()
.
Example:
// In an object's Step Event
// Move right when 'D' key is held down
if (keyboard_check(ord("D"))) {
x += 4;
}
// Jump when 'Space' is pressed
if (keyboard_check_pressed(vk_space)) {
// Perform jump action
}
Mouse Controls:
Mouse input is detected using functions like mouse_check_button()
, mouse_check_button_pressed()
, along with mouse_x
and mouse_y
variables.
Example:
// In an object's Step Event
// Shoot when left mouse button is clicked
if (mouse_check_button_pressed(mb_left)) {
instance_create_layer(x, y, "Instances", obj_bullet);
}
Gamepad Controls:
GameMaker provides extensive functions for gamepad input, allowing you to detect button presses, analog stick movements, and trigger values.
Example:
// In an object's Step Event (for player 0)
// Move horizontally with left stick
var _h_input = gamepad_axis_value(0, gp_axislh);
x += _h_input * 5;
// Press A button
if (gamepad_button_check_pressed(0, gp_face1)) {
// Perform action
}
Implementing User-Changeable In-Game Controls:
To allow players to change controls within your game, you need to:
- Store Key Mappings: Instead of hardcoding keys directly in
if
statements, store key/button mappings in global variables, anini
file, ajson
file, or a data structure.- Example:
global.key_move_right = ord("D"); global.key_jump = vk_space;
- Example:
- Use Stored Mappings: Use these variables in your input checks.
- Example:
if (keyboard_check(global.key_move_right)) { x += 4; } if (keyboard_check_pressed(global.key_jump)) { // Jump }
- Example:
- Create an Options Menu: Design an in-game options menu where players can click on an action (e.g., "Move Right") and then press a new key/button to assign it.
- When a player assigns a new key, update the corresponding
global.key_move_right
variable.
- When a player assigns a new key, update the corresponding
- Save and Load Settings: Implement functionality to save these custom key mappings to a persistent file (e.g., using
ini_open
,json_save_file
) when the game exits and load them back when the game starts.
For more information on handling input in GameMaker, explore the official GameMaker Input documentation.
Comparison of Control Customization
Feature | GameMaker IDE Keyboard Shortcuts | In-Game Controls (GML) |
---|---|---|
Purpose | Customize developer workflow/hotkeys | Define player interaction with the game |
Method | Preferences menu | GML scripting (keyboard_check , etc.) |
User | The game developer | The player of your game |
Persistence | Saved within GameMaker's settings | Must be programmed (e.g., INI/JSON files) |
Complexity | Menu-driven, straightforward | Requires programming logic and UI design |