-
-
Notifications
You must be signed in to change notification settings - Fork 488
btnp
btnp [[id: 0..31], [hold], [period] ] -> pressed (but wasn't pressed in previous frame)
- id : The id of the key we need to interrogate, see the key map for reference
- hold : The time (in ticks) the key must be pressed to call period.
- period : Within the amount of time (in ticks) after that, this function will return true again.
This function allow to read the status of one of the buttons attached to TIC.
The function return true value only in the moment the key is depressed.
You can also argument the hold and period parameters that allows to return true keeping the key pressed. After the hold time is elapsed the function return true every time period is passed.
Time is expressed in ticks; at 60 fps it means you need to use 120 to wait 2 seconds.
-- btnp demo: move the rectangle in 10 pixels step,
-- every time one direction keys is pressed.
-- Keep the key pressed for more than 1 second to have
-- the rectangle move every tenth of seconds.
x=120
y=80
cls(12)
function TIC()
if btnp(0,60,6) then y=y-10 end
if btnp(1,60,6) then y=y+10 end
if btnp(2,60,6) then x=x-10 end
if btnp(3,60,6) then x=x+10 end
rect(x,y,10,10,8)
end
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
Platform
RAM & VRAM | Display | Palette | Bits per Pixel (BPP) |
.tic
Format | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
- BDR (0.90)
- BOOT (1.0)
- MENU
- OVR (deprecated)
- SCN (deprecated)
- TIC
- btn & btnp
- circ & circb
- clip
- cls
- elli & ellib (0.90)
- exit
- fget & fset (0.80)
- font
- key & keyp
- line
- map
- memcpy & memset
- mget & mset
- mouse
- music
- peek, peek4
- peek1, peek2 (1.0)
- pix
- pmem
- poke, poke4
- poke1, poke2 (1.0)
- rect & rectb
- reset
- sfx
- spr
- sync
- ttri (1.0)
- time
- trace
- tri & trib (0.90)
- tstamp (0.80)
- vbank (1.0)