diff options
Diffstat (limited to 'demos/declarative/snake/content/snake.js')
-rw-r--r-- | demos/declarative/snake/content/snake.js | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/demos/declarative/snake/content/snake.js b/demos/declarative/snake/content/snake.js index fab7834..2a99aa8 100644 --- a/demos/declarative/snake/content/snake.js +++ b/demos/declarative/snake/content/snake.js @@ -22,20 +22,26 @@ function rand(n) function scheduleDirection(dir) { - direction = dir; - if(scheduledDirections[scheduledDirections.length-1]!=direction) - scheduledDirections.push(direction); + if (state == "starting") { + direction = dir; + headDirection = direction; + head.rotation = headDirection; + } else if (state == "running"){ + direction = dir; + if(scheduledDirections[scheduledDirections.length-1]!=direction) + scheduledDirections.push(direction); + } } function startNewGame() { - if (state == "starting") + if (state == "starting") { return; + } if (heartbeat.running) { endGame(); startNewGameTimer.running = true; - state = "starting"; return; } |