topdown rotations

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Crossing
Prole
Posts: 42
Joined: Sat Mar 21, 2015 3:37 pm

topdown rotations

Post by Crossing » Sun Oct 13, 2019 5:22 am

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 479 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.
Attachments
Untitled.png
Untitled.png (19.56 KiB) Viewed 478 times

User avatar
zorg
Party member
Posts: 2722
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: topdown rotations

Post by zorg » 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)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
Crossing
Prole
Posts: 42
Joined: Sat Mar 21, 2015 3:37 pm

Re: topdown rotations

Post by Crossing » Sun Oct 13, 2019 6:16 am

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!

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests