Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / button_down? too fast
- By ? Date 2009-08-14 09:38
Hi everyone!

Im trying to make a title menu for my "game" (is more like a template) and the menu have 3 options selectables with the keyboard arrows, the problem is that if I use button_down? to move the index, it move too fast and is imposible to choose the 2ยบ option, is like:

-New Game

the problem is that you cant select continue due at index speed (which is moved by button_down?), i tried using a variable @pause to detect the keys only certain time, but have bad responde.

Gosu dont have different type of buttons detection?

I worked with other library (RGSS) and it have 3:

Press is what button_down? make in gosu, trigger only return the first frame pressed and repeat alternates returning true and false.
is hard to implement this to the library?
thanks :3
- By jlnr (dev) Date 2009-08-14 12:22
It's all there, just overload the "button_down" method of Window (no question mark), just like in the tutorial game :)

button_down is the callback that you use for one-time events, button_down? is the check that you use in your logic for holding keys down. You can also combine both, i.e. shoot on the first button_down and then count the ticks from then on, repeating the fire after every 10, etc.
- By ? Date 2009-08-14 12:33
cool, my problem now is this(another one wee):

My "game" is divided in scenes (like the rest of RPGs), and the update is in the actual scene, the window update only have a $scene.update
and the method button_down/button_up is from and only for the Window class, so i cant use it or overwrite it in the sub-updates.
Im using a miserly method to try to remedy it (a case in window class, to know what scene is and lock button_down in that mode) but Im looking for a better solution ;o;

Cant add a module or something for input? leaving away the Window class :S
- By ippa Date 2009-08-14 16:18
If I understand your last problem correctly...

Either just:

Game < Gosu::Window
  def button_up(id)

  def button_down(id)

Then you can use button_down/up the same way in a scene as in the main window.

What you want is probably a full game state system.

Actually over the summer I've worked on framework for ruby gosu (called Chingu) which includes stack-based (push/pop) game states among other things. You could check it out @ if you want, it's starting get in usable shape.

Here's an example of how Chingu adds easy handling of game states and inputs:
- By Dahrkael Date 2009-08-14 16:47
i love you :3

the game states are not a problem, im already using a sub-loops systems and works fine, only needs fades between scenes, but that can wait.

One of these days ill post the project, maybe someone want a RPG template "easy" to use ^^
- By lobo_tuerto Date 2009-08-15 01:11
Ahh! nice code there!

I'm working on something very similar (about routing the inputs and stuff to a "state" of sorts), and your app will help me to flesh out some stuff! :D
Up Topic Gosu / Gosu Exchange / button_down? too fast

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill