Page 1 of 2

Turning an image

Posted: Fri Apr 08, 2011 8:03 pm
by Anxiety
Title says it all. How can i turn an image?

PS: I just realised this is the 666th thread :o

Re: Turning an image

Posted: Fri Apr 08, 2011 8:46 pm
by nevon
The fourth argument in love.graphics.draw is rotation, where the unit used is radians.

Re: Turning an image

Posted: Fri Apr 08, 2011 9:09 pm
by Robin
In case you don't know how radians work: 0 = normal, math.pi/2 = 90°, math.pi = 180°, etc.

Re: Turning an image

Posted: Sat Apr 09, 2011 9:16 am
by BlackBulletIV
Robin wrote:In case you don't know how radians work: 0 = normal, math.pi/2 = 90°, math.pi = 180°, etc.
You could also do this:

Code: Select all

math.tau = math.pi * 2
math.tau -- 360 deg
math.tau / 2 -- 180 deg
math.tau / 4 -- 90 deg
Much easier to remember for me. (By the way, I'm using Tau from here: http://tauday.com)

Re: Turning an image

Posted: Sat Apr 09, 2011 9:42 am
by nevon
BlackBulletIV wrote:
Robin wrote:In case you don't know how radians work: 0 = normal, math.pi/2 = 90°, math.pi = 180°, etc.
You could also do this:

Code: Select all

math.tau = math.pi * 2
math.tau -- 360 deg
math.tau / 2 -- 180 deg
math.tau / 4 -- 90 deg
Much easier to remember for me. (By the way, I'm using Tau from here: http://tauday.com)
You could also do this:

Code: Select all

math.rad(90) -- 90 deg
Much easier to remember for me. (Granted, your ways are much faster, but w/e)

Re: Turning an image

Posted: Sat Apr 09, 2011 12:52 pm
by Anxiety
Oh thanks. Now just one thing yet, how can i toggle image visibility?

Re: Turning an image

Posted: Sat Apr 09, 2011 1:19 pm
by thelinx
Just don't draw it.

Re: Turning an image

Posted: Sat Apr 09, 2011 3:43 pm
by Anxiety
But if it already is in the screen and i want to get rid of it?

Re: Turning an image

Posted: Sat Apr 09, 2011 4:14 pm
by nevon
Anxiety wrote:But if it already is in the screen and i want to get rid of it?
The screen is cleared and drawn each frame.

Re: Turning an image

Posted: Sat Apr 09, 2011 8:15 pm
by BlackBulletIV
Here's an example of how to toggle the image:

Code: Select all

display = true

function love.draw()
  if display then
      love.graphics.draw(...)
  end
end
And in love.update you change the status of display to false on certain conditions, or something like that.
nevon wrote:
BlackBulletIV wrote:
Robin wrote:In case you don't know how radians work: 0 = normal, math.pi/2 = 90°, math.pi = 180°, etc.
You could also do this:

Code: Select all

math.tau = math.pi * 2
math.tau -- 360 deg
math.tau / 2 -- 180 deg
math.tau / 4 -- 90 deg
Much easier to remember for me. (By the way, I'm using Tau from here: http://tauday.com)
You could also do this:

Code: Select all

math.rad(90) -- 90 deg
Much easier to remember for me. (Granted, your ways are much faster, but w/e)
I find Tau easier in some ways because if you replace the math.tau bit with 1, that's the fraction of the circle you get with the angle. But anyway, each to their own. :)