[plt-scheme] world.ss - combination of keys

From: jeeve (jvjulien at free.fr)
Date: Fri Oct 31 05:37:29 EDT 2008

hello,

by using the world.ss library, I would wish to create a little game.
I do not know how to detect a combination of keys to the keyboard…

in following example I would wish to detect simultaneous keys " a" + "
up" and " q" + " down". (play multiplayer…)

(define (changer-direction j key)
(let ((y1 (send (jeu-mobile-gauche j) getY))
(y2 (send (jeu-mobile-droit j) getY)))
(case key
((#\a) (begin (send (jeu-mobile-gauche j) setY (- y1 10)) j))
((#\q) (begin (send (jeu-mobile-gauche j) setY (+ y1 10)) j))
((up) (begin (send (jeu-mobile-droit j) setY (- y2 10)) j))
((down) (begin (send (jeu-mobile-droit j) setY (+ y2 10)) j))
(else j))))

if you have an idea…

thanks


Posted on the users mailing list.