Player Movement Ascii RPG game
-
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. -
I get it. This seems like a fun idea! So you want the value to change when you hold a button but stop?
-
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.
-
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
-
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.
-
I'll give these a whirl. You guys rock! :D
-
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 -
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.