https://www.youtube.com/watch?v=ukkbNKTgf5U
None the less - I pick through the demo code he provides here:
https://github.com/OneLoneCoder/olcPix ... cTiles.cpp
and I think I've done okay translating the C into LUA:
Code: Select all
function ConvertGraphicsToGridXY(x,y)
-- Converts a screen co-ordinate (origin top-left corner) into an isometric grid co-ordinate
local tilewidth = 32
local tileheight = 21
-- Work out active cell. This means the 'normal' left/right aligned grid
local cellx = x / tilewidth
local celly = y / tileheight
-- Work out mouse offset into cell. Will be used later to determine if x,y is in one of the corners of the cell
local offsetx = x / tilewidth
local offsety = y / tileheight
isox = cf.round(celly + (cellx),1) -- cf.round is just a rounding function from one of my personal libraries
isoy = cf.round(celly - cellx,1)
return isox,isoy
end
I have two problems:
a) is my code conversion actually correct (I think it is)
b) in the tutorial, he uses some sort of colour mask thingy to detect corner clicks. Anyone familiar with the subject might have seen this before:
Other languages can check which colour was clicked and thereby know what corner was clicked. Is there a similar way in lua/love2d?
Here is my tiled map for reference:
Finally, I'm happy to use some module or engine or something with this but things like STI and tileclick either don't do isometric or don't do forever expanding random maps (i.e you have to handcraft each map).
This is just day 2 on this project and I'm pretty chuffed with the progress already. With so many isometric dungeon-crawlers out there I'm hoping this is an easy problem to fix. Thanks.