Game Development Community

Sprite stops responding to keyboard

by Eric Preston · in Torque Game Builder · 09/03/2005 (4:56 pm) · 3 replies

I control sprite movement with keyboard commands. I have an intermittent problem that I don't understand. Always on launch, the sprite responds to key commands as it should. Sometimes, after a while, the sprites just stops responding to the key presses. It doesn't happen every time I use the game, but often enough to be a problem. I know that occasionally I hit an unprogrammed key by mistake. I was wondering if that could turn off the sprite responses.

Anyone know anything about this? Anyone else have this happen?

Any help appreciated.

Eric

#1
09/03/2005 (6:39 pm)
Does this happen with the spacescroller demo for you?
#2
09/03/2005 (6:54 pm)
In my experience, this sort of thing is usually the result of a typo somewhere in your code. Time to go through with a fine-toothed comb and make sure all of your braces and semi-colons are in the right place.

There's also a couple coding practices that can help narrow down where problems are coming from... I like to comment liberally, explaining back to myself what a given function is doing, so I can check back over and make sure it's doing what I think it is. Every now and again I'll find something I forgot to change or delete when making an edit, and it usually results in unpredictable behavior.

I also like to have a function echo back key variables and what-not while I'm debugging it. That way I can scan my console while it's running to see what's funked up.

Last, try to be specific about when a problem occurs. Right now, you know it happens "after a while", but that's not really specific. The key to fixing it is repeatability. Is it specifically after some time? Wait without hitting keys, then check. Is it after a specific set of moves? Hit your movement keys in different combinations until it happens. Once you can reproduce the steps that cause the problem, fixing it becomes infinitely easier.

Anyway, I'm really quite amateur with this stuff still. If the problem persists, you might want to consider posting your code so some of these smart folks can take a look. Another set of eyes never hurts. :)
#3
09/04/2005 (1:32 pm)
On further diagnosis, the effect seems to be caused by inadvertently (or on purpose) hitting the Tab key. This seems to disable all keyboard commands. Does that make sense to anyone? In the Space Scroller Demo, hitting Tab key does not disable keyboard. So, I've got to figure out what is different.

Thanks,

Eric