blockSize = 8; gameHeight = 70; gameWidth = 50; TRON_BLOCK = 1; keyListener = new Object(); keyListener.onKeyDown = function() { var keyCode = Key.getCode(); if (keyCode > 36 && keyCode < 41) { if (game.onEnterFrame != undefined) { if (keyCode-37 != turnQueue[0]) { turnQueue.unshift(keyCode-37); } } } else if (keyCode == 32) { if (!gameRunning) { startGame(); } } }; Key.addListener(keyListener); Mouse.addListener(mouseListener); function startGame() { x = int(gameWidth/2); y = gameHeight-2; xVelocity = [-1, 0, 1, 0]; yVelocity = [0, -1, 0, 1]; map = new Array(); for (var n=0;n 0) { var dir = turnQueue.pop(); if (dir % 2 != currentDirection % 2) { currentDirection = dir; } } x += xVelocity[currentDirection]; y += yVelocity[currentDirection]; if (map[x][y] != TRON_BLOCK && x > -1 && x < gameWidth && y > -1 && y < gameHeight) { game.s.attachMovie("tronMC", tronBlockCounter, tronBlockCounter, {_x: x*blockSize, _y: y*blockSize}); tronBlockCounter++; map[x][y] = TRON_BLOCK; } else { gameOver(); } }