-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9bf6d0
commit 4e0af3b
Showing
3 changed files
with
69 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
define([], function() { | ||
"use strict"; | ||
|
||
var points = 0; | ||
var maxPoints = 0; | ||
|
||
var game; | ||
|
||
function init(theGame) { | ||
game = theGame; | ||
} | ||
|
||
function draw(ctx) { | ||
var pos = {x:20, y:20}; | ||
|
||
var strPoints = points.toString(); | ||
strPoints.split('').forEach(function(c,i) { | ||
game.drawImage("number_score_0"+c, pos.x+i*15, pos.y, ctx); | ||
}); | ||
|
||
var strMaxPoints = maxPoints.toString(); | ||
strMaxPoints.split('').forEach(function(c,i) { | ||
game.drawImage("number_context_0"+c, pos.x+5+i*13, pos.y+25, ctx); | ||
}); | ||
} | ||
|
||
function resetPoints() { | ||
points = 0; | ||
} | ||
|
||
function addPoint() { | ||
points += 1; | ||
maxPoints = Math.max(points, maxPoints); | ||
} | ||
|
||
return { | ||
init: init, | ||
draw: draw, | ||
resetPoints: resetPoints, | ||
addPoint: addPoint | ||
}; | ||
|
||
}); |