Rotate

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.
Miawwe
Prole
Posts: 3
Joined: Mon Apr 10, 2017 6:52 pm

Rotate

Post by Miawwe »

Hello,
Could anyone please explain to me how this damn thing work? I'm used to objects. And this rotate function is rotating everything, i just want it to rotate the "Zeme".. the blue planet. Image
Thanks.
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Rotate

Post by yetneverdone »

Wrap your code with the push and pop functions.

Heres the pseudo code:
lg = love.graphics
lg.push()
lg.translate()
lg.rorate()
--draw blue planet
lg.translate()
lg.pop()

--Draw the rest
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Rotate

Post by raidho36 »

Graphical transformations affect all subsequent rendering, it's pretty simple. The aforementioned "pop" and "push" functions can be used to load and save current transform state, respectively.
Miawwe
Prole
Posts: 3
Joined: Mon Apr 10, 2017 6:52 pm

Re: Rotate

Post by Miawwe »

I'm really sorry but i still don't understand how it works
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Rotate

Post by raidho36 »

Well I suppose you can imagine it as a stretchy painting canvas. You can stretch and twist and rotate it then draw things on it, then twist and stretch again and draw some more, etc. Then in the end you put the canvas back as it was, and everything you drew as normal would be accordingly twosted and stretched.
User avatar
yetneverdone
Party member
Posts: 446
Joined: Sat Sep 24, 2016 11:20 am
Contact:

Re: Rotate

Post by yetneverdone »

Miawwe wrote: Wed Apr 12, 2017 5:33 pm I'm really sorry but i still don't understand how it works
As raidho said, use the push and pop functions. Similar to what ive posted before
Lucyy
Citizen
Posts: 51
Joined: Thu Oct 15, 2015 6:57 am
Contact:

Re: Rotate

Post by Lucyy »

Miawwe wrote: Wed Apr 12, 2017 5:33 pm I'm really sorry but i still don't understand how it works
The love.graphics.push() function stores any transformations as they are now, and the love.graphics.pop() function reverts transformations back to how they were when you called the push function.

E.g. you call love.graphics.push(), apply your transformations, draw your things and then call pop() and draw the things you want to be drawn normally.

Here's a small example (might contains typos, typed this out of my head)

Code: Select all


-- anything drawn here will be drawn normally

-- store current transformations
love.graphics.push()

-- apply your transformations
love.graphics.translate(.5, .5)
love.graphics.rotate(90)

-- anything drawn here will have the transformations applied to them

-- reset transformations
love.graphics.pop()

-- anything drawn here will be drawn normally

For more information on the push and pop functions plus some examples you could check out the wiki ;o
love.graphics.pop
love.graphics.push
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Rotate

Post by Ref »

If you're not comfortable with push/pop, don't use it.
Attachments
popless.love
Simple example
(555 Bytes) Downloaded 101 times
Lucyy
Citizen
Posts: 51
Joined: Thu Oct 15, 2015 6:57 am
Contact:

Re: Rotate

Post by Lucyy »

Ref wrote: Thu Apr 13, 2017 5:53 pm If you're not comfortable with push/pop, don't use it.
You indeed could do this without push and pop.

Would you be so kind as to explain exactly how you did this without push / pop?
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Rotate

Post by zorg »

Lucyy wrote: Thu Apr 13, 2017 6:47 pm Would you be so kind as to explain exactly how you did this without push / pop?
Probably the same way with them, except you need to reset the state you modified... if you only used coordinate transform stuff, then there's a neat little love.graphics.origin function for that.
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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 185 guests