Posts

Showing posts with the label lua

Having an issue with grid-based movement in Love2D/Lua

Image
Clash Royale CLAN TAG #URR8PPP Having an issue with grid-based movement in Love2D/Lua Using the Love2D Lua framework, I am trying to program a very basic game much like Nintendo-era RPGs where the heroes' and NPCs' movement was restricted to a tiled grid. So far I've found my past any problems, until I hit this tricky error where the player movement isn't functioning correctly. function love.load() love.graphics.setDefaultFilter('nearest', 'nearest', 1) love.keyboard.setKeyRepeat(true) font = love.graphics.newFont(14) -- the number denotes the font size win_size = 6 love.window.setMode(160 * win_size, 144 * win_size) true_sfc = love.graphics.newCanvas(160,144) view_sfc = love.graphics.newCanvas(160 * win_size, 144 * win_size) player = { grid_x = 3, grid_y = 3, act_x = 48, act_y = 48, transit = false, direction = {0, 0} } end function love.update(dt) if player.transit ...