[racket] Key-event test problem
On May 3, 2012, at 8:24 AM, Laurine Harbulot wrote:
> Hello all,
> We're students and we're working on a space invaders project.
>
> Our game runs very well but we've got a problem:
> We would like to give the opportunity to players to press two keyboards buttons at the same time but for now,our program tests only one event at the same time.
> Is there a solution for that ?
It depends on several factors.
(A) If you are using the racket/gui library, the answer is "yes in many ways."
(B) The way you asked this question, however, makes me think that you are using 2htdp/universe, in which case it depends on what you mean by "simultaneously".
If you mean something like "a player hits control and a simultaneously", then the answer is "no".
If you mean "two players use one keyboard to play against each other", I recommend that you check up on "on-pad" a relatively new way of dealing with keyboard events.
More generally, 2htdp/universe is a student library, mostly intended for beginners even at young ages (14 years, say) and as such makes a compromise between simplicity and expressiveness. "Simultaneous" in the first sense was one of the features I sacrificed for this design.
Now it is possible that you have a different sense of "simultaneous" in mind, in which case I recommend you ask again, ideally with a code snippet or a scenario description that spells out the details.
-- Matthias