-
Notifications
You must be signed in to change notification settings - Fork 0
API Input
Get button B state for player PL (default 0)
B: 0..5: left right up down button_o button_x
PL: player index 0..7
Instead of using a number for B, it is also possible to use a button glyph. (In the coded editor, use Shift-L R U D O X)
If no parameters supplied, returns a bitfield of all 12 button states for player 0 & 1
P0: bits 0..5 P1: bits 8..13
Default keyboard mappings to player buttons:
player 0: [DPAD]: cursors, [O]: Z C N [X]: X V M
player 1: [DPAD]: SFED, [O]: LSHIFT [X]: TAB W Q A
Although PICO-8 accepts all button combinations, note that it is generally impossible to press both LEFT and RIGHT at the same time on a physical game controller. On some controllers, UP + LEFT/RIGHT is also awkward if [X] or [O] could be used instead of UP (e.g. to jump / accelerate).
BTNP is short for "Button Pressed"; Instead of being true when a button is held down, BTNP returns true when a button is down AND it was not down the last frame. It also repeats after 15 frames, returning true every 4 frames after that (at 30fps; double that at 60fps). This can be used for things like menu navigation or grid-wise player movement.
The state that BTNP reads is reset at the start of each call to _UPDATE or _UPDATE60, so it is preferable to use BTNP from inside one of those functions.
Custom delays (in frames at 30fps) can be set by poking the following memory addresses:
POKE(0X5F5C, DELAY) -- SET THE INITIAL DELAY BEFORE REPEATING. 255 MEANS NEVER REPEAT.
POKE(0X5F5D, DELAY) -- SET THE REPEATING DELAY.
In both cases, 0 can be used for the default behaviour (delays 15 and 4)
- ๐ Keys
- ๐ Hello World
- ๐พ Example Cartridges
- ๐ File System
โคด๏ธ Loading and Saving- ๐ Using an External Text Editor
- ๐ฝ Backups
- ๐ง Configuration
- ๐ธ Screenshots and GIFs
- ๐ Sharing Cartridges
- ๐ SPLORE
- ๐ผ๏ธ Sprite Sheet / Label (.png)
- ๐ต SFX and Music (.wav)
- ๐ค MAP and CODE
- ๐พ Cartridges (.p8, .p8.png, .p8.rom)
- ๐ Web Applications (.html)
- ๐ค Binary Applications (.bin)
- ๐น๏ธ Uploading to itch.io
- ๐พ Exporting Multiple Cartridges
- ๐ฅ Running EXPORT from the host operating system