Turning an image

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Anxiety
Prole
Posts: 49
Joined: Sat Apr 02, 2011 9:36 am
Location: Finland

Turning an image

Post by Anxiety »

Title says it all. How can i turn an image?

PS: I just realised this is the 666th thread :o
I can't come up with a good signature!
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Turning an image

Post by nevon »

The fourth argument in love.graphics.draw is rotation, where the unit used is radians.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Turning an image

Post by Robin »

In case you don't know how radians work: 0 = normal, math.pi/2 = 90°, math.pi = 180°, etc.
Help us help you: attach a .love.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Turning an image

Post 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)
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Turning an image

Post 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)
User avatar
Anxiety
Prole
Posts: 49
Joined: Sat Apr 02, 2011 9:36 am
Location: Finland

Re: Turning an image

Post by Anxiety »

Oh thanks. Now just one thing yet, how can i toggle image visibility?
I can't come up with a good signature!
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Turning an image

Post by thelinx »

Just don't draw it.
User avatar
Anxiety
Prole
Posts: 49
Joined: Sat Apr 02, 2011 9:36 am
Location: Finland

Re: Turning an image

Post by Anxiety »

But if it already is in the screen and i want to get rid of it?
I can't come up with a good signature!
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Turning an image

Post 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.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Turning an image

Post 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. :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests