Page 1 of 2
Rotate
Posted: Mon Apr 10, 2017 6:56 pm
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.
Thanks.
Re: Rotate
Posted: Tue Apr 11, 2017 3:03 am
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
Re: Rotate
Posted: Tue Apr 11, 2017 5:36 am
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.
Re: Rotate
Posted: Wed Apr 12, 2017 5:33 pm
by Miawwe
I'm really sorry but i still don't understand how it works
Re: Rotate
Posted: Wed Apr 12, 2017 6:55 pm
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.
Re: Rotate
Posted: Thu Apr 13, 2017 3:13 am
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
Re: Rotate
Posted: Thu Apr 13, 2017 6:07 am
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
Re: Rotate
Posted: Thu Apr 13, 2017 5:53 pm
by Ref
If you're not comfortable with push/pop, don't use it.
Re: Rotate
Posted: Thu Apr 13, 2017 6:47 pm
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?
Re: Rotate
Posted: Thu Apr 13, 2017 7:52 pm
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.