First, let me thank you for taking the time to help me!
However I think my post was unclear. I'm not shearing first into x and then into y direction, I'm shearing into both directions at the same time. I found the source of my conversion problem, though:
If I use shear before drawing something like this:
Code: Select all
love.graphics.shear(angle, angle)
love.graphics.circle('fill', x, y, 2, 20)
The drawing position can be calculated like this
Code: Select all
local nx = x + math.sin(angle) * y
local ny = y + math.sin(angle) * x
love.graphics.circle('fill', nx, ny, 2, 20)
(The first circle get's it's body sheared as well so the two version are not exactly identical. As I'm only interested in the draw position that's fine).
Now if I want to re-convert a position on the screen to "world coordinates", it can be (in theory) easily done like this:
Code: Select all
y = ny - math.sin(angle) * x
x = nx - math.sin(angle) * y
The problem is: If I don't know x and y beforehand (that's why I want to calculate them), I can't calculate them because I'd need their values first.
Shortened example: How would I need to change the mousepressed method so that the circle is always drawn exactly where I click?:
Code: Select all
circle = { x=0, y=0}
angle = -0.3
function love.draw()
love.graphics.shear(angle, angle)
love.graphics.circle("fill", circle.x, circle.y, 2, 20)
end
function love.mousepressed(nx, ny, button)
if button == "l" then
circle.y = ny - math.sin(angle) * -- ??
circle.x = nx - math.sin(angle) * -- ??
end
end