Navigation

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

    Coding for Fun: Controls Assistant

    Functions
    4
    4
    616
    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.
    • Chronos
      Chronos last edited by

      This one was inspired by problems I ran across in my recent game and only now made solutions for.

      Almost every time I wanted to see if a control was pressed, I had to make a variable to see if it was also released for next time. No more! The controls assistant (or ButtonHelper) is meant to replace controls(idx) by kind of wrapping it.

      It contains useful information, such as: was the button just pressed, just released, or even tapped for a short duration or held for a longer duration.

      The just pressed boolean will only be true for one frame, making it perfect for statements like:
      If "X" was just pressed, then open a menu without immediately closing the menu again (assuming that "X" would also close it).

      As a bonus, it also contains a function to get the angle between two vectors with a positive or negative direction when going from v1 to v2 (cos_angle2(v1, v2)).

      I used this to get the average angular velocity of a control stick, which I might use for an upcoming game idea, but you could use cos_angle2 for getting the amount of positive or negative rotation needed for an enemy Sprite to look at a player, assuming their rotation speed is non-instantaneous (I ran into this problem in Space Swarm with the laser turret, wish I'd figured this out a couple of days ago, atan2 is really only good for instantaneous rotation setting).

      If you would also like to be free of controller-based (or 2D rotation-based) hassles, here is the ID (probably still pending).
      ID: NLXL7MNDN5

      Jason

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

        Thanks very much for the share. Stuff related to this is a very common hiccup for new users. Nice to have something ready to use that we can point people to in future :)

        1 Reply Last reply Reply Quote 0
        • AndyG1985
          AndyG1985 last edited by

          Agreed, it still vexes me a little, although I learned a bit from Super Fuze Platformer. I will take a look :)

          1 Reply Last reply Reply Quote 0
          • Devieus
            Devieus last edited by

            This could be very useful. Having more activators is always nice.

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