Snake: Added scoring and display.
This commit is contained in:
@@ -59,6 +59,7 @@ var loadLevel = function(levelSetName, levelNum) {
|
||||
// TODO: Show start overlay UI
|
||||
|
||||
// Initialize the board using the level data.
|
||||
$scoreValue.text("0");
|
||||
Snake.initialize(levelData);
|
||||
|
||||
};
|
||||
@@ -66,9 +67,9 @@ var loadLevel = function(levelSetName, levelNum) {
|
||||
var nextLevel = function() { };
|
||||
|
||||
var updateScore = function(ev) {
|
||||
var curScore = parseInt($scoreValue.textContent);
|
||||
curScore += ev.detail.bodyLength;
|
||||
curScore.textContent = curScore;
|
||||
var evDetail = ev.originalEvent.detail;
|
||||
var curScore = parseInt($scoreValue.text());
|
||||
$scoreValue.text(curScore + (evDetail.bodyLength * evDetail.fps));
|
||||
|
||||
if (evDetail.score == Snake.currentLevel.targetScore)
|
||||
nextLevel(); };
|
||||
|
||||
Reference in New Issue
Block a user