Navigation

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

    Player Movement Ascii RPG game

    Beginners
    5
    8
    407
    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.
    • H
      Hangoin last edited by

      Hey everybody, I hope you're all doing well.
      I'm working on a simple grid based ascii character game, and I'm stuck on player movement.
      I'm trying to figure out how to make a value change by one increment and stop while a button is held down. Right now all I can figure out how to do is make a value keep changing while a button is held down.
      For better clarification, I'm trying to get the same kind of player movement you would see in a turn based ascii roguelike game.
      I hope I did a good job explaining this, and I appreciate anyone who reads this.

      1 Reply Last reply Reply Quote 3
      • JMM161437
        JMM161437 F last edited by

        I get it. This seems like a fun idea! So you want the value to change when you hold a button but stop?

        1 Reply Last reply Reply Quote 1
        • H
          Hangoin last edited by

          Right! But I think I might have figured it out. I've added sleep(0.25) at the top of my main loop to slow the program down. This will give the player ample time to let go of what button is being pushed.

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

            This thread should have what you’re looking for, I think https://fuzearena.com/forum/topic/1195/use-of-flags-with-button-presses/7?_=1620588530289

            1 Reply Last reply Reply Quote 2
            • L
              LucasJG25 last edited by LucasJG25

              You could have a loop that will end when the button is no long pressed.

              c = controls(0)
              if c.left then
                movement += 1
                while c.left loop 
                  c = controls(0) 
                  update()
                repeat
              endif
              

              If you're looking for it to increment once per button press.

              1 Reply Last reply Reply Quote 1
              • H
                Hangoin last edited by

                I'll give these a whirl. You guys rock! :D

                1 Reply Last reply Reply Quote 3
                • CasualTie5
                  CasualTie5 F last edited by

                  always cool when people start new projects, have fun!
                  regarding the sleep function, I would personally recommend replacing it with the timer function... because sleep stops the entire program for its runtime, and thus prevents you from making calculations etc. in the background. Timer is a bit more complicated to implement as you'll need a seperare variable, but I think it's usually worth it

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

                    I’ve also used time to stop button presses from repeating, and it worked pretty well. I had a ‘time last pressed’ and a ‘delay time’. It was set so that it wouldn’t fire again if time last pressed + delay time was less than current time. It worked pretty well. I hope I remembered that all right.

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