Discord
Login
Community
DARK THEME

HELP ME

Hello everyone and thanks in advance for those who will help me. I am new and I don't know how to do it. Here's the problem: I created a sprite that would be the player and I would like it to be in a precise position at the beginning of the game but if I put the coordinates later I can't move the sprite with the keyboard. Please help me.

P.S I wrote this with the translator so there will definitely be errors

Try setting the position in the init function :)

Is this any useful?

You can copy paste on a new project and test it.

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

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

draw = function()
  screen.clear()
  screen.drawSprite("icon",x,y,32)
  screen.drawLine(0,0,x,y,"#FFF")
end

Thanks so much for the advice

it works!

Post a reply

Progress

Status

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