Discord
Login
Community
DARK THEME

Movement not working no matter what I do

here is the entire code I'm using:

init = function() player = object end end

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

draw = function() screen.drawMap( "map", 0, 0, 300, 200 ) screen.drawSprite( "player", x=0, y=0, 32, 32 ) end

I've tried every variation of "if keyboard ______" and it hasn't worked I even tried copy and pasting straight from the tutorial for movement and it didn't work (it didn't even work in the tutorial)

anything you guys can do to help my conundrum?

here:

init = function()
  player = object
  player.x = 0
  player.y = 0
end

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

draw = function()
  screen.drawMap( "map", 0, 0, 300, 200 )
  // Use player.x and player.y for the sprite's position
  screen.drawSprite( "player", x=player.x, y=player.y, 32, 32 )
end

I used that code but there's "Expected '=', in file MAIN at line 3, column 9" that wont go away despite there very clearly being a = there

Oops sorry here is the updated version:

init = function()
  player = object end
  player.x = 0
  player.y = 0
end

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

draw = function()
  screen.drawMap( "map", 0, 0, 300, 200 )
  // Use player.x and player.y for the sprite's position
  screen.drawSprite( "player", x=player.x, y=player.y, 32, 32 )
end

ITS NOW WORKING! thank you so much :3

Post a reply

Progress

Status

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