Add method to check if any key is pressed

This commit is contained in:
Alex Clink 2022-01-23 16:20:14 -05:00
parent 829ee59c54
commit acff191dab

View file

@ -68,6 +68,11 @@ module PF
# ===============
def any_pressed?
@keysdown.any? { |name, state| state & PRESSED > 0 }
end
# Returns true the first time called if a button has been pressed
def pressed?(name)
return false if @keysdown[name] & READ != 0
return false unless @keysdown[name] & PRESSED != 0
@ -75,12 +80,14 @@ module PF
true
end
def action?(name)
@keysdown[name] & PRESSED > 0
end
# Returns true if a registered button is being held
def held?(name)
@keysdown[name] & PRESSED > 0
end
# ditto
def action?(name)
@keysdown[name] & PRESSED > 0
end
end
end