Autofire O X + Swap O X

Published 2023-06-12


TO LOAD THIS CART IN PICO-8, type in immediate mode: load #autofire

VVhat's new ?
(01-07-22)
✅ Added menu to reload after selecting an option instead of closing like earlier.

There have been many Pico-8 game players wanting to have autofire ability, mostly for shooters and auto-selection RPG choices, and in some cases players want to be able to swap the O and X buttons.

Well this program has a foundation that is about as simple as you can get.

In it you use 6-single key variables, ⬅️ ➡️ ⬆️ ⬇️ 🅾️ ❎ which can be easily typed in Pico-8 source-code by holding down the shift key and pressing any of L R U D O X which will appear as a special non-ASCII character.

If any of these variables are TRUE, then that means the player is holding down the button for the corresponding switch.

However, if you pause for the MENU with P or ENTER you will see 3-new options.

AUTOFIRE 🅾️ ON
AUTOFIRE ❎ ON
SWAP 🅾️ AND ❎

In selecting the first or second options, you will now have variable 🅾️ or ❎ stagger its shots. And of course in selecting one or the other it does not automatically turn autofire on both buttons. You get to select which, none, first, second, or both.

The last option is pretty self-explanatory. It will swap reading the 🅾️ AND ❎ buttons thus later if selected and you press the 🅾️ button, the ❎ variable will become true and vice-versa.

Feel free to examine the code and see what is happening here. The code in _UPDATE() is about as simple as it can get it. In _INIT() call function initbuttons().

In your main program when you are ready to read keystrokes, call the function getkeys().

Where you type each of the special arrows above by holding down the SHIFT key and L, R, U, and D respectively.

And that's it ! The rest is handled automatically.

It is my wish that future Pico-8 will have these options automatically available for any cart, and can be optionally turned on or off to appear in menus and to select your autofire rate, currently defined in _init().

Hope This Helps !