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.

Howdy, Stranger!

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