Discord
Login
Community
DARK THEME

code still not working

why is this code not working.

init = function() x = 0 y = 25 flyY = 40 flyX = 40 end

fly_ai = function() if flyX > x then while flyX >= x do flyX = flyX - 10 end end if flyX < x then while flyX <= x do flyX = flyX + 10 end end end

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

draw = function() screen.fillRect(0, 0, 400, 400, "rgb(140,198,440)") screen.drawSprite("guy", x, y, 30) screen.drawMap("map2", 0, 0, 300, 200) screen.drawSprite("fly_guy", flyX, flyY, 20) end

init = function() 
  x = 0 
  y = 25 
  flyY = 40 
  flyX = 40
end

fly_ai = function() 
  if flyX > x then 
    while flyX >= x 
      flyX = flyX - 10 
    end 
  end
  if flyX < x then 
    while flyX <= x 
      flyX = flyX + 10 
    end
  end
end

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

draw = function() 
  screen.fillRect(0, 0, 400, 400, "rgb(140,198,440)")
  screen.drawSprite("guy", x, y, 30) 
  screen.drawMap("map2", 0, 0, 300, 200)
  screen.drawSprite("fly_guy", flyX, flyY, 20) 
end

Post a reply

Progress

Status

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