I should have been clear. I'm already doing what you suggest. However, when I press the key and let go the first player is moving (left for example) the game is switching state and the next player is moving left. So the two robots are essentially following each other around because it is happening too fast.
How can I make sure that the button is released before a new input button is allowed is what I'm really asking or what I really need, right?
I'm not sure how best to approach this or even how to get started. I have two player objects. And they are both drawn on the board. When I press the arrow keys one player moves.
However, I want to do two things:
1. Limit input to only 'one move' at time. What I mean by that is sometimes I can't get off the key press fast enough the the player jumps more than one space in whatever direction I'm pushing down the arrow key in.
2. This is probably pretty easy depending on what the above looks like, but I'd like to switch players after receiving the first key input to the other player. Maybe creating an 'active_player' to receive the method call on.
Any thoughts on how best to approach this or how to do it?
I'm working through the learn game programming book by pragmatic programmers and I can't even manage to get the sample code running. I've dowloaded and when I try to run it, I see the following....
❯ ruby WhackARuby/WhackARuby_1/whack_a_ruby.rb
initialize': Cannot open file ruby.png (RuntimeError)initialize'
This is the offending line: @image = Gosu::Image.new('ruby.png')
And I tried changing it to @image = Gosu::Image.new('./ruby.png') but that didn't help. Any thought son what might be causing this?
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill