Discord
Login
Community
DARK THEME

lua inputs

how would I implement input detection in lua?

init = function()
  x = 0
  y = 0
end

update = function()
  if keyboard.LEFT == 1 then x = x-1 end
  if keyboard.RIGHT == 1 then x = x+1 end
  if keyboard.UP == 1 then y = y+1 end
  if keyboard.DOWN == 1 then y = y-1 end
end

draw = function()
  screen:clear()
  screen:drawSprite("icon",x,y,50)
end

thanks, I found it on the documentation a day or 2 ago, I didn't see the different language tab

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community