Keyboard Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Keyboard Help

I have a script which uses the keyboard to move through a maze which is stored in a mysql database accessed through php pages. It works out if a move is possible based on the map.
It works fine most of the time however if you hold down a direction button and move towards a wall that is not adjacent (ie you have a run up) then it will let you run through walls, how many wall squares it lets you run through is random.

This is achieved through the following code:

var watching:Boolean = true;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
watching = false;
if (Key.getCode() == Key.LEFT) {
else if (Key.getCode() == Key.RIGHT) {
else if (Key.getCode() == Key.UP) {
else if (Key.getCode() == Key.DOWN) {
watching = true;

The moveUp,moveDown etc functions check to see if a square is accesable and moves if it is. Using the watching variable as a guard seems to make no difference so I'm rather confused. If anyone has any ideas where the problem might be then please let me know.
Sign In or Register to comment.