Think it like in love update you are ready to calculate something BUT u need user input; then you need to callYolwoocle wrote: ↑Sat Feb 26, 2022 6:34 pm Hi.
I come from a background of making games on PICO-8, and its API has two functions, called "btn" and "btnp", which respectively return whether a button is down or if it's just been pressed (i.e. for the first frame). I have used myself to think about input in terms of checking it in the "update" function. However, LÖVE seems to have a "love.keypressed" function, which is, as far as I know, the only way to check if a button has been just been pressed (as opposed to checking if it's down continuously).
Imagine I have a game with different weapons, some of which are automatic, where you have to hold the "fire" button to fire, while others are manual, where you have to press on this button repeatedly to fire.
What is a helpful way to think about this? Use "love.keyboard.isDown" in my player's update method, and have separate code for "love.keypressed"? Seems weird to me that the same action should be put in different places in the code.
Thanks
Code: Select all
love.keyboard.isDown("keys to check")
Code: Select all
function love.keypressed(key, ...)
if key == "esc" then
love.event.quit()
end
end
Code: Select all
function love.keyreleased(key)
--ur stuff
end