Rotation?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Rotation?

Post by Findo777 »

The wiki did not give a straight answer, and I was somewhat confused.
Let say I made a image move along the screen if a key isDown, but I wanted it to rotate on turns


How would I rotate the image?
My guess;


love.graphics.setRotation()-- angle here?

If this is not correct, please correct it for me.
Thank you!
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Rotation?

Post by davisdude »

If you have a picture...

Code: Select all

love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy, kx, ky )
With r being the rotation, in radians.
Otherwise, do this:

Code: Select all

function love.draw()
     love.graphics.push()
          love.graphics.rotate( r ) -- Being the same thing as before. 
          -- Draw stuff. 
          -- Note you don't have to indent, just personal preference. 
     love.graphics.pop()
end
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Findo777
Prole
Posts: 36
Joined: Tue Feb 25, 2014 4:09 am

Re: Rotation?

Post by Findo777 »

What does this mean?


x, y, r, sx, sy, ox, oy, kx, ky )




I know what the r is, but what does the rest mean?
Also, do you need the code above to have all of those letters or can it be anything of your choice?
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Rotation?

Post by szensk »

number x (default: 0)
The position to draw the object (x-axis).
number y (default: 0)
The position to draw the object (y-axis).
number r (default: 0)
Orientation (radians).
number sx (default: 1)
Scale factor (x-axis).
number sy (default: sx)
Scale factor (y-axis).
number ox (default: 0)
Origin offset (x-axis).
number oy (default: 0)
Origin offset (y-axis).
number kx (default: 0)
Shearing factor (x-axis).
number ky (default: 0)
Shearing factor (y-axis).
from https://www.love2d.org/wiki/love.graphics.draw
User avatar
Jeeper
Party member
Posts: 611
Joined: Tue Mar 12, 2013 7:11 pm
Contact:

Re: Rotation?

Post by Jeeper »

Findo777 wrote:What does this mean?


x, y, r, sx, sy, ox, oy, kx, ky )




I know what the r is, but what does the rest mean?
Also, do you need the code above to have all of those letters or can it be anything of your choice?
If you only need X and Y then you dont need to type the rest. But if you need ox then you cant skip anything that is BEFORE ox, but you can still skip everything that is AFTER. You obviously replace the letters with the approprate thing.

So you dont type (x,y,r) but rather (200, 132, math.pi / 2)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 7 guests