Discord
Login
Community
DARK THEME

I need help with my game!!!!!!

I need help with my game and I can show you my code init = function() end

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

draw = function() screen.fillRect(0,0,400,400,"#000") screen.drawSprite( "icon", x, y, 16, 16 ) end

I can invde you to my game. What is your username and that will help me get you in my game and help me with the code

Can you clarify what error is happend to you? Thanks

Oh wait. I've see the problem You don't have initialize the x and y var!. Use this code:

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


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

draw = function() 
  screen.fillRect(0,0,400,400,"#000") 
  screen.drawSprite( "icon", x, y, 16, 16 ) 
end
init = function()
  x = 0
  y = 0
end


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

draw = function() 
  //add a clear
  screen.clear()
  screen.fillRect(0,0,400,400,"#000") 
  screen.drawSprite( "icon", x, y, 16, 16 ) 
end
init = function()
  x = 0
  y = 0
end


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

draw = function() 
  //Now put the color code inside the clear func and you're good to go!
  screen.clear("#000") 
  screen.drawSprite( "icon", x, y, 16, 16 ) 
end

Use this code

Post a reply

Progress

Status

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