Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Suggestion for rotateShapeByOrigin()

    Bug Reporting (FUZE 4 Nintendo Switch)
    2
    3
    216
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • spikey
      spikey F last edited by

      Shapes, especially how those are handled in FUZE4 seem to me an excellent way to get into programming graphics: a few lines with a quick viewable result. I really hope you can add some more advanced functions (like those for sprites) to simplify the coding.

      What about adding this function? Its really fun to use it along with joinShape() and create custom shapes and rotate them:

      The following code will rotate any shape around the given origin:

      function rotateShapeByOrigin(shape, origin, angle)
         p_rot = {}
         p = getShapeLocation(shape) - origin
         p_rot.x = p.x * cos(angle) - p.y * sin(angle)
         p_rot.y = p.y * cos(angle) + p.x * sin(angle)
         p_rot += origin
         rotateShape(shape, angle)
         setShapeLocation(shape, p_rot)
      return shape
      
      

      Example:

      box = createBox(800, 500)
      rotation_center = {400,400}
      angle_diff = 2
      
      loop
         clear(lightgrey)
         drawShape(box)
         rotateShapeByOrigin(box, rotation_center, angle_diff)
         update()
      repeat
      

      (for the implementation in FUZE: maybe modify it to become a setShapeOrigin() function, so it looks like the analog setSpriteOrigin() function, and adapt the rotateShape() afterwards to support it, see our discussion).

      1 Reply Last reply Reply Quote 4
      • spikey
        spikey F last edited by

        Shared the code on SW-4464-9632-0709.

        1 Reply Last reply Reply Quote 0
        • Willpowered
          Willpowered Fuze Team last edited by Willpowered

          @spikey Thanks for the suggestion, I've made a note to bring it up for internal discussion. I agree, it would make sense for shapes to have an origin like sprites!

          (And sorry it took so long to get back to you!)

          1 Reply Last reply Reply Quote 2
          • First post
            Last post