Navigation

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

    Help with sin/cosine movement

    Coding
    3
    9
    487
    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.
    • B
      Basseman last edited by

      Hi
      I'm terrible at math and i'm looking for help to incorporate som sin or cosine movement into the placement of a drawtext. (Like an old fashioned scrolltext back in the demo days).
      So the text placed on screen would move (wave) up and down or side to side in a smooth way (Think of ease in/ease out).
      Hope this make sense to you all.

      Best Regards

      // Andreas M

      1 Reply Last reply Reply Quote 0
      • N
        Nisse5 F last edited by

        sin/cos in FUZE4 uses an angle as a parameter, so you'll get a floating value between -1 and 1 if you supply values between 0-360. The cycle starts again at 360, so sin(2) will for example give the same value as sin(362).

        So, you basically have to scale both the angle parameter and the return value to your liking, to behave as your screen coordinate system.

        (sin(xcoord)+1)*180
        ...would give you y-coordinates between 0-360, meaning a "perfect" sine wave.

        1 Reply Last reply Reply Quote 0
        • M
          MikeDX last edited by MikeDX

          try this

          loop
          clear()
          x = sin(time()*1000)*500-250
          y = cos(time()*1000)*500-250
          drawtext(x,y,30,random(120),"Hello FUZE!")
          update()
          repeat
          
          B 1 Reply Last reply Reply Quote 0
          • B
            Basseman @MikeDX last edited by

            @MikeDX
            How Will i declear ”timer” ??
            Function Does not exist.

            // Andreas

            1 Reply Last reply Reply Quote 0
            • M
              MikeDX last edited by

              sorry Andreas

              i meant time() not timer() 🙃

              B 1 Reply Last reply Reply Quote 0
              • B
                Basseman @MikeDX last edited by

                @MikeDX

                I ger error on the random for the colour, wants a vector...
                And when setting a colour manualy the the Sine/Cosima is waaaaay to fast.

                1 Reply Last reply Reply Quote 0
                • M
                  MikeDX last edited by MikeDX

                  Great! so we have a start :)

                  try changing random(120) for another colour, let's say red, white, etc

                  for the speed, the time()*1000 is the key here. lets try 100

                  B 1 Reply Last reply Reply Quote 1
                  • B
                    Basseman @MikeDX last edited by

                    @MikeDX
                    Works alot better, smooth and nice :)
                    Thanks Alot

                    // Andreas

                    1 Reply Last reply Reply Quote 1
                    • M
                      MikeDX last edited by

                      Great! Now you can experiment with speed, colour range etc and you'll be a sincos master in no time

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