PDA

View Full Version : Beginning Game Programmer, Question about GetKeys()


Why37
2002.07.21, 03:58 PM
I have a question regarding GetKeys();
When I use it to move a sprite back and forth across the screen, the keys that I press for control (4 for left, 6 for right), are also typed into my CodeWarrior editor window wherever the cursor is. For instance:

GetKeys(theKeyboard);46664646446646

Right now it is no more than an annoyance, but I want to know if it could cause some problems when more than one program is open in the final game, and if it is possible to fix this. Thanks!

inio
2002.07.21, 05:47 PM
It sounds like you need to call FlushEvents() (http://developer.apple.com/techpubs/mac/Toolbox/Toolbox-56.html) before your app exits. Usually keyDown+keyUp+mouseDown+mouseUp is a good event mask to use.

edit:
Beat you! Neener Neener Neener Neener.

codemattic
2002.07.21, 05:47 PM
Since you are using getkeys - you are not actually pulling events off of the event queue - so all those key down events are still there for whatever app comes front next. Try adding

FlushEvents( everyEvent, 0 );

before your app quits.

hth,
Codemattic