Skip to content

yuigoto/gamemaker-control-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GameMaker Control Scripts

This repo contains some scripts I use to handle controller bindings on some of my games. They were hugely inspired by how Derek Yu wrote control handling scripts for his game Spelunky Classic.

I kinda did some clean-room engineering to build these control scripts here, and ended up adding more stuff here and there, but it basically follows the same principles: each button has 3 states and, for each state we have a script (down, pressed and released).

There's support for movement keys (d-pad, WASD), start (enter), select (esc) and 8 action buttons for up to 4 players, though only the first player gets the mapping for keyboard out of the box.

In addition to that, there's also the optional use of analog sticks, for which I've added scripts to also emulate the down, pressed and released states. BUT these scripts require the use of the obj_controlsAnalog object, which can be initialized when calling the bootstrap script (and setting use_analog to true).

There's also a global for each player, indicating if the user's using the "gamepad" or "keyboard" schemes.

It's not a perfect scheme, still needs work and optimization, but it worked for me pretty nicely, and I hope it does work for you, or at least helps you reach your own control scheme scripts! 😄

Use it on your project, game jam or whatever! No need to credit (though appreciated)! 😉

P.s.: I'm also using the approach script from Matt Thorson's Grandma Engine to test the movement controls.


Dependencies

There are two projects in this repository, one for GameMaker: Studio (gms1-control-scripts.gmx) and another for GameMaker Studio 2 (gms2-control-scripts), so you'll need to have one of these editors installed in your machine.


How To

Just fire controlsInit() at the very beginning of your game to bootstrap all control globals, then use each button's specific script to check states.

There are more things I'm working on for this, like a control mapper (which is kinda "built", but not good enough). Since it saves the controls on a INI file, you should be able to map them, as there's also scripts to help you output which key or button the user pressed. 😉


Authors

See AUTHORS.md for more information.


Thanks

  • Robert Rüdiger (@ruerobgames), for help in testing and improving this project;
  • Derek Yu, for making Spelunky, since without it I'd never think about this solution before;

©2020 Fabio Y. Goto

About

GMS1 and GMS2 control handling scripts, inspired by Derek Yu's Spelunky way of handling them 🎮

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published