Files
PICO-8/maths-attacks.p8

73 lines
2.1 KiB
Lua
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pico-8 cartridge // http://www.pico-8.com
version 37
__lua__
-- maths attacks --
-- by djib --
function _init()
init_btn_status()
end
function _update()
update_btn_status()
update_btn_status(🅾)
end
function _draw()
cls()
print("❎ - pressed:"..tostr(btn_pressed()).." - held:"..tostr(btn_held()),1,1)
print("🅾️ - pressed:"..tostr(btn_pressed(🅾)).." - held:"..tostr(btn_held(🅾)),1,10)
end
-->8
-- buttons --
function init_btn_status()
-- no repeating delay for keyboard
poke(0x5f5d,255)
-- true when pressed
btn_down_status={}
-- true when quickly released
btn_up_status={}
-- true when held
btn_held_status={}
end
function update_btn_status(button)
-- button was already pressed --
if btn_down_status[button] then
-- button was held
if btnp(button) then
btn_held_status[button]=true
btn_down_status[button]=false
end
-- button no longer pressed
if not btn(button) then
btn_up_status[button]=true
btn_down_status[button]=false
end
else
if btnp(button) then
btn_down_status[button]=true
end
if not btn(button) then
btn_held_status[button]=false
btn_down_status[button]=false
btn_up_status[button]=false
end
end
end
function btn_held(button)
return btn_held_status[button]
end
function btn_pressed(button)
return btn_up_status[button]
end
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000