Page 1 of 1

topdown rotations

Posted: Sun Oct 13, 2019 5:22 am
by Crossing
Hey guys so im kinda stuck on a problem with getting a topdown image to rotate the right way.
Heres my image.
The attachment AlienShip1.png is no longer available
I'm trying to get the image to rotate towards the middle of the screen no matter where it comes from.
AlienShip1.png
AlienShip1.png (600 Bytes) Viewed 2447 times
I already have the ships moving towards the earth and calculate the angle from whatever coords they spawn at using

Code: Select all

local angle = math.atan2((Earth.Y + Earth.Height / 2)- (RaidGroup[i][4] + 32 / 2), (Earth.X + Earth.Width / 2)- (RaidGroup[i][3] + 32 / 2))
32 being height and width of the image.
I then plug that into

Code: Select all

love.graphics.draw()
as such

Code: Select all

for i = 1,#RaidGroup do
	love.graphics.draw(Aliens.FrigateImages[1], RaidGroup[i][3], RaidGroup[i][4], RaidGroup[i][8], 1, 1, 32/2, 32/2)
end

However, without adding

Code: Select all

angle = angle + math.rad(136)
i cannot get the ship to face the direction its going.

Re: topdown rotations

Posted: Sun Oct 13, 2019 5:50 am
by zorg
Your image faces a specific angle instead of to the right, which necessitates adding 180-45=135! Degrees to the angle. (Rotating by a half circle counterclockwise and by an eight clockwise from what would be a 0 degree offset)

Re: topdown rotations

Posted: Sun Oct 13, 2019 6:16 am
by Crossing
zorg wrote: Sun Oct 13, 2019 5:50 am Your image faces a specific angle instead of to the right, which necessitates adding 180-45=135! Degrees to the angle. (Rotating by a half circle counterclockwise and by an eight clockwise from what would be a 0 degree offset)
Got it wasn't sure what orientation the image should be to work without a offset. Thanks!