Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhitman <bryan@olenepal.org>2009-09-30 07:10:03 (GMT)
committer hitman <bryan@olenepal.org>2009-09-30 07:10:03 (GMT)
commit08005f801b1ba123e9152eff8f55f8cf4af3de43 (patch)
treeeb1397d13f39b654954be18d8e34e8e607d3bbf0
parentf346b6c8d1a0042b187f6c84e524ccfb6c842849 (diff)
You now get a congratulations message if you complete all 6 stages
-rwxr-xr-xexamples/adding_up_to_10/css/lesson.css3
-rwxr-xr-xexamples/adding_up_to_10/index.html2
-rwxr-xr-xexamples/adding_up_to_10/js/lesson.js69
3 files changed, 56 insertions, 18 deletions
diff --git a/examples/adding_up_to_10/css/lesson.css b/examples/adding_up_to_10/css/lesson.css
index ec5bfc6..f96d0ba 100755
--- a/examples/adding_up_to_10/css/lesson.css
+++ b/examples/adding_up_to_10/css/lesson.css
@@ -1,8 +1,9 @@
-#main {
+#karma-main {
width:800px;
height:600px;
position:absolute;
+opacity: 1;
}
#action {
float:left;
diff --git a/examples/adding_up_to_10/index.html b/examples/adding_up_to_10/index.html
index 464d6fb..69dcfc7 100755
--- a/examples/adding_up_to_10/index.html
+++ b/examples/adding_up_to_10/index.html
@@ -76,7 +76,7 @@
</div>
-
+ <div id="overlayPaper"></div>
</div>
diff --git a/examples/adding_up_to_10/js/lesson.js b/examples/adding_up_to_10/js/lesson.js
index 8e2c84d..e2870c0 100755
--- a/examples/adding_up_to_10/js/lesson.js
+++ b/examples/adding_up_to_10/js/lesson.js
@@ -32,29 +32,37 @@ k.main(function() {
//game logic
var total, time, n0, n1, correct;
var level = 0, d=160;
- var choices=[], score = 0, speed = 4000;
+ var choices=[], score = 0, speed = 12000;
var playerCorrect = 0, endTimerX = 80, startTimerY = 25,
endTimerY = 100, offsetTimerY = 5;
- var timerPaper, timerRect,
+ var overlayPaper, timerPaper, timerRect,
chimpPaper, normalChimp, sadChimp, happyChimp,
- topLtBox, topRtBox, bottomLtBox, bottomMdBox, bottomRtBox;
+ overlayBox, topLtBox, topRtBox, bottomLtBox, bottomMdBox, bottomRtBox;
var buttons=[];
var stopTimer = false;
var chooseMe;
- var createBox = function (paperName) {
+ var createBox = function (paperName, width, height) {
var set, paper, box;
- paper = Raphael(paperName+"Paper", 200, 200);
+ if(!width || !height){
+ paper = Raphael(paperName+"Paper", 200, 200);
+ }
+ else {
+ paper = Raphael(paperName+"Paper", width, height);
+ }
set = paper.set();
return { "paper": paper, "prefix": paperName, "set": set};
};
+
+ overlayBox = createBox("overlay", 800, 600);
topLtBox = createBox("topLt");
topRtBox = createBox("topRt");
bottomLtBox = createBox("bottomLt");
bottomMdBox = createBox("bottomMd");
bottomRtBox = createBox("bottomRt");
+
boxes = [ topLtBox, topRtBox, bottomLtBox,
bottomMdBox, bottomRtBox];
@@ -67,7 +75,7 @@ k.main(function() {
box.set.remove();
});
- total = k.math.rand( 2, 10 ); //the total
+ total = k.math.rand( 2, 5 + level ); //the total
n0 = total - k.math.rand(1, total - 1 ); //first number
n1 = total - n0; //second number
@@ -109,7 +117,7 @@ k.main(function() {
y = k.math.rand( 0, d );
for ( var j=0; j<pos.length; j++) {
if ( k.geometry.distance2( pos[j],
- {"x": x, "y": y} ) < 120 ) {
+ {"x": x, "y": y} ) < 135 ) {
flag = true;
break;
}
@@ -117,7 +125,7 @@ k.main(function() {
}while ( flag === true );
pos.push( { "x":x, "y": y } );
- imgVarNames[prefix][i] = box["paper"].image(k.library.images[imgId].src, x , y, 40, 40);
+ imgVarNames[prefix][i] = box["paper"].image(k.library.images[imgId].src, x , y, 35, 35);
box["set"].push(imgVarNames[prefix][i]);
}
@@ -155,10 +163,15 @@ k.main(function() {
var choose = function(buttonNum) {
if ( choices[buttonNum] === total){
- answer(true, false);
- resetTimer();
- animateTimer();
- game();
+ //If the player has completed all the levels
+ if (playerCorrect === 4 && level === 5) {
+ congrats();
+ } else {
+ answer(true, false);
+ resetTimer();
+ animateTimer();
+ game();
+ }
}else {
answer(false, false);
resetTimer();
@@ -195,11 +208,12 @@ k.main(function() {
writeScore(score);
k.library.sounds[ "correct" ].play();
animateChimp(true);
- if (playerCorrect === 5){
- level = (level+1)% imgNames.length;
- speed = speed - 300;
+ if (playerCorrect == 5){
+ level = level + 1;
+ speed = speed - 1000;
playerCorrect = 0;
- }
+ }
+
}
@@ -278,6 +292,27 @@ k.main(function() {
normalChimp.show();}, 800);
};
+
+ var congrats = function () {
+ var congratsText;
+ stop();
+
+ $('#overlayPaper').css({"position": "absolute",
+ "background": "white", "opacity": "0.8",
+ "z-index": "100"});
+ congratsChimp = overlayBox.paper.image(
+ k.library.images["happyChimp"].src, 200, 100, 300, 400);
+ congratsChimp.attr({"fill-opacity": "1", "opacity": "1"});
+ congratsText = overlayBox.paper.text(400, 550, "Great Job!");
+ congratsText.attr({"font-size": 80});
+ overlayBox.set.push(congratsChimp, congratsText);
+
+ congratsChimp.node.addEventListener('click', function(){
+ $('#overlayPaper').css({"opacity": 0});
+ overlayBox.set.remove();
+ }, false);
+
+ };
document.getElementById('start').
addEventListener('click', start, false);
@@ -306,6 +341,8 @@ k.main(function() {
happyChimp.hide();
sadChimp.hide();
+
+
//end of Karma.main
});