Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Rotating a Rectangle

in Questions Posts: 8

I’m having trouble using rotate(). I want to draw a rotated rectangle on the map I have created. Everything on the map is relative to a vec2 called mapCenter that changes as the character moves around - so he stays in the center of the screen and the map moves around him. If I draw a rotated retangle like this...

rotate(45)
rect(mapCenter.x, mapCenter.y, 200, 100)
rotate(0)

...then it looks like it rotates any changes to mapCenter by 45 degrees as well because the rectangle meanders derpily when the character walks around, rather than staying stationary relative to the map. The documentation in Codea says the rotate applies to functions as well, but I didn’t think that applied here and would still use the values of whatever mapCenter was, despite how those values changed.

Is there any way to easily solve this or have I doomed myself by not taking this into account sooner?

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 6,828

    @n0ogit Have you looked at pushStyle and popStyle, pushMatrix and popMatrix.

  • Posts: 8

    I'm familiar with pushStyle and popStyle, but not pushMatrix and popMatrix. It does sound like that's what I need though. Thank you!

Sign In or Register to comment.