From 441f538b4ac4ef05105f59357a32a122602d4aae Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Mon, 02 Nov 2009 20:14:41 +0000 Subject: now have both svg and canvas versions of adding_up --- diff --git a/examples/adding_up_to_10_canvas/assets/en/sounds/en_correct.ogg b/examples/adding_up_to_10_canvas/assets/en/sounds/en_correct.ogg new file mode 100755 index 0000000..a0d9e3a --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/en/sounds/en_correct.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/en/sounds/en_incorrect.ogg b/examples/adding_up_to_10_canvas/assets/en/sounds/en_incorrect.ogg new file mode 100755 index 0000000..4805e55 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/en/sounds/en_incorrect.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_correct.ogg b/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_correct.ogg new file mode 100755 index 0000000..a54f738 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_correct.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_incorrect.ogg b/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_incorrect.ogg new file mode 100755 index 0000000..0474b93 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/es-MX/sounds/es-MX_incorrect.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/ball37px.png b/examples/adding_up_to_10_canvas/assets/generic/images/ball37px.png new file mode 100755 index 0000000..4388283 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/ball37px.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/balloon37px.png b/examples/adding_up_to_10_canvas/assets/generic/images/balloon37px.png new file mode 100755 index 0000000..8f47d6a --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/balloon37px.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/banana37px.png b/examples/adding_up_to_10_canvas/assets/generic/images/banana37px.png new file mode 100755 index 0000000..90728e6 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/banana37px.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/chilli.png b/examples/adding_up_to_10_canvas/assets/generic/images/chilli.png new file mode 100755 index 0000000..5f8b64d --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/chilli.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/fish64px.png b/examples/adding_up_to_10_canvas/assets/generic/images/fish64px.png new file mode 100755 index 0000000..a29f12c --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/fish64px.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/flower37px.png b/examples/adding_up_to_10_canvas/assets/generic/images/flower37px.png new file mode 100755 index 0000000..224e707 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/flower37px.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/happyChimp_120x125.png b/examples/adding_up_to_10_canvas/assets/generic/images/happyChimp_120x125.png new file mode 100755 index 0000000..5e721c9 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/happyChimp_120x125.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/happyMonkey.jpg b/examples/adding_up_to_10_canvas/assets/generic/images/happyMonkey.jpg new file mode 100755 index 0000000..bfe0d38 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/happyMonkey.jpg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/normalChimp_120x125.png b/examples/adding_up_to_10_canvas/assets/generic/images/normalChimp_120x125.png new file mode 100755 index 0000000..a731df4 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/normalChimp_120x125.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/plussign.png b/examples/adding_up_to_10_canvas/assets/generic/images/plussign.png new file mode 100755 index 0000000..915c5aa --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/plussign.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/sadChimp_120x125.png b/examples/adding_up_to_10_canvas/assets/generic/images/sadChimp_120x125.png new file mode 100755 index 0000000..1dec5f0 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/sadChimp_120x125.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/scorebox.png b/examples/adding_up_to_10_canvas/assets/generic/images/scorebox.png new file mode 100755 index 0000000..424b60b --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/scorebox.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/sidebar.png b/examples/adding_up_to_10_canvas/assets/generic/images/sidebar.png new file mode 100755 index 0000000..9632788 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/sidebar.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/images/yellowBox.png b/examples/adding_up_to_10_canvas/assets/generic/images/yellowBox.png new file mode 100755 index 0000000..f7a72ca --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/images/yellowBox.png Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/sounds/correct.ogg b/examples/adding_up_to_10_canvas/assets/generic/sounds/correct.ogg new file mode 100755 index 0000000..c89ce57 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/sounds/correct.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/sounds/incorrect.ogg b/examples/adding_up_to_10_canvas/assets/generic/sounds/incorrect.ogg new file mode 100755 index 0000000..2306562 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/sounds/incorrect.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/generic/sounds/trigger.ogg b/examples/adding_up_to_10_canvas/assets/generic/sounds/trigger.ogg new file mode 100755 index 0000000..f22512a --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/generic/sounds/trigger.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/he/sounds/he_correct.ogg b/examples/adding_up_to_10_canvas/assets/he/sounds/he_correct.ogg new file mode 100755 index 0000000..4e12c65 --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/he/sounds/he_correct.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/he/sounds/he_incorrect.ogg b/examples/adding_up_to_10_canvas/assets/he/sounds/he_incorrect.ogg new file mode 100755 index 0000000..9e314bb --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/he/sounds/he_incorrect.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_correct.ogg b/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_correct.ogg new file mode 100755 index 0000000..8ced3cd --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_correct.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_incorrect.ogg b/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_incorrect.ogg new file mode 100755 index 0000000..106fe0f --- /dev/null +++ b/examples/adding_up_to_10_canvas/assets/ne/sounds/ne_incorrect.ogg Binary files differ diff --git a/examples/adding_up_to_10_canvas/exercise.html b/examples/adding_up_to_10_canvas/exercise.html index a99ec93..eaf3d63 100755 --- a/examples/adding_up_to_10_canvas/exercise.html +++ b/examples/adding_up_to_10_canvas/exercise.html @@ -10,23 +10,23 @@ - + - +
+ +
@@ -72,15 +72,11 @@
- +
-
- - - -
+
diff --git a/examples/adding_up_to_10_canvas/js/lesson.js b/examples/adding_up_to_10_canvas/js/lesson.js index ef878d3..852bd3f 100755 --- a/examples/adding_up_to_10_canvas/js/lesson.js +++ b/examples/adding_up_to_10_canvas/js/lesson.js @@ -1,9 +1,7 @@ -/* jslint browser: true -*/ $(document).ready(function(){ - var k = $.karma({container: "#karma-main", lang: "en"}); + var k = $.karma ({container: "#karma-main", lang: "en"}); k.init({ images: [ @@ -13,357 +11,289 @@ $(document).ready(function(){ {name: "chilli", file: "chilli.png", localized : false }, {name: "fish" , file: "fish64px.png", localized : false }, {name: "flower", file: "flower37px.png", localized : false }, - {name: "normalChimp", file: "normalChimp_120x125.png", - localized : false}, - {name: "happyChimp", file: "happyChimp_120x125.png", - localized: false}, - {name: "sadChimp", file: "sadChimp_120x125.png", - localized : false}], + {name: "normalChimp", file: "normalChimp_120x125.png", localized : false}, + {name: "happyChimp", file: "happyChimp_120x125.png", localized: false}, + {name: "sadChimp", file: "sadChimp_120x125.png", localized : false} + + ] + , sounds: [ + {name: "correct", file: "correct.ogg"}, {name: "incorrect", file: "incorrect.ogg"}, {name: "trigger", file: "trigger.ogg", localized: false} - ] - + + ], + surfaces: [ + {name:"topLt", canvas:"topLtCanvas"}, + {name:"topRt", canvas:"topRtCanvas"}, + {name:"bottomLt", canvas:"bottomLtCanvas"}, + {name:"bottomMd", canvas:"bottomMdCanvas"}, + {name:"bottomRt", canvas:"bottomRtCanvas"}, + {name:"timer", canvas:"timerCanvas"}, + {name:"scorebox", canvas:"scoreboxCanvas"}, + {name:"chimp", canvas:"chimpCanvas"} + +] }); k.main(function() { - var imageNames = ["ball", "banana", "balloon","chilli", "fish", "flower"]; + var imgNames = ["ball", "banana", "balloon","chilli", "fish", "flower"]; //game logic - var cards; - var totalCorrect = 0, n0 = 0, n1 = 0, correctCard = 0, - level = 0, score = 0, numCorrectAnswers = 0; - var DRAW_MAX_X = 170, DRAW_MAX_Y = 170; - var choices=[0, 0, 0]; - var timerSpeed = 12000; - var START_TIMER_Y = 25, END_TIMER_Y = 125; - var timerPaper, chimpPaper; - var timerRect; - var normalChimpImage, sadChimpImage, happyChimpImage; - var overlayCard, topLeftCard, topRightCard, bottomLeftCard, - bottomMiddleCard, bottomRightCard; - - var buttons=[]; - var isTimerRunning = false; - var dispatchChoice; - - var createCard = function (paperName, width, height) { - var set; - var paper; - - if(!width || !height){ - paper = Raphael(paperName+"Paper", 200, 200); - } + var total, level=0, time, n0, n1, correct; + var maskd=200; + var d=160; + var choices=[]; + var score = 0; + var correct; + var speed = 2000; + var playerCorrect = 0; + var endTimerX = 80; + var startTimerY = 10; + var endTimerY = 100; + var offsetTimerY = 5; + var timerId; + + var timerFn = function () { + k.surfaces['timer'].clear(); + + if ( startTimerY >= endTimerY ){ + //you didn't answer in time + k.library.sounds["trigger"].play(); + answer(false, true); + game(); + } else { - paper = Raphael(paperName+"Paper", width, height); + k.surfaces['timer'].clear(); + startTimerY = startTimerY + offsetTimerY; + k.surfaces['timer'].ctx.fillStyle = "#fff"; + k.surfaces['timer'].ctx.fillRect(10, startTimerY, endTimerX, 20); } - set = paper.set(); - return { "paper": paper, "prefix": paperName, "set": set}; }; - - overlayCard = createCard("overlay", 800, 600); - topLeftCard = createCard("topLeft"); - topRightCard = createCard("topRight"); - bottomLeftCard = createCard("bottomLeft"); - bottomMiddleCard = createCard("bottomMiddle"); - bottomRightCard = createCard("bottomRight"); - - - cards = [ topLeftCard, topRightCard, bottomLeftCard, - bottomMiddleCard, bottomRightCard]; - - sets = [topLeftCard.set, topRightCard.set, bottomLeftCard.set, - bottomMiddleCard.set, bottomRightCard.set]; - - - function drawCards () { - var imageId = imageNames[ level ]; - //reinitialize choices to zero - choices = [0, 0, 0]; - - cards.forEach(function (box) { - box.set.remove(); - }); - totalCorrect = k.math.rand( 2, 5 + level ); //the totalCorrect - n0 = totalCorrect - k.math.rand(1, totalCorrect - 1 ); //first number - n1 = totalCorrect - n0; //second number - - //chose one option (the correct option) - //and then put the correct value into it - correctCard = k.math.rand( 0, 2 ); - choices[ correctCard ] = totalCorrect; - - var computeUniqueChoice = function(choice){ - var newChoice = 0; - if (choice === totalCorrect) { - return choice; - } else { - newChoice = k.math.rand( 1, 10 ); - if (newChoice === totalCorrect){ - return computeUniqueChoice(choice); + function game () { + $.each(k.surfaces, function () { + if (this.name != "chimp"){ + this.clear(); + } + }); + + + writeScore(); + total = k.math.rand( 2, 10 ); //the total + n0 = total - k.math.rand(1, total - 1 ); //first number + n1 = total - n0; //second number + + //chose one option (the correct option) + //and then put the correct value into it + correct = k.math.rand( 0, 2 ); + choices[ correct ] = total; + + for (var i=0; i<3; i++) { + //generate the two other options + if ( choices[i] === total) { + continue; } else { - return newChoice; + // generate the other options + choices[ i ] = k.math.rand( 2, 10 ); + for (var j = 0; j < i; j++){ + if (choices[i] === choices[j]) { + choices[ i ] = k.math.rand( 2, 10 ); + } + } } } - }; - - choices = choices.map(computeUniqueChoice); - - var drawCard = function (card, n) { - var positions = []; - var x = 0, y = 0; - var isOverlapping = false; - var imageVarNames = {}; - var varPrefix = card.prefix; - imageVarNames[varPrefix] = []; - card.set = card.paper.set(); - for (var i=0; i\n" +"Language-Team: karma \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: English\n" +"X-Poedit-Country: United States\n" +"X-Poedit-SourceCharset: utf-8\n" + + +msgid "choose an option" +msgstr "choose an optionxxxxxxx" + +msgid "Time" +msgstr "Time1" + +msgid "Level" +msgstr "Level1" + +msgid "Restart" +msgstr "Restart1" + diff --git a/examples/adding_up_to_10_canvas/po/es-MX.po b/examples/adding_up_to_10_canvas/po/es-MX.po new file mode 100755 index 0000000..ca1e61c --- /dev/null +++ b/examples/adding_up_to_10_canvas/po/es-MX.po @@ -0,0 +1,29 @@ +# Spanish translations for PACKAGE package. +msgid "" +msgstr "" +"Project-Id-Version: adding up to 10 v1\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2009-07-07 04:46-0600\n" +"Last-Translator: Felipe López Toledo \n" +"Language-Team: karma \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Spanish\n" +"X-Poedit-Country: MEXICO\n" +"X-Poedit-SourceCharset: utf-8\n" + + +msgid "choose an option" +msgstr "escoge una opción" + +msgid "Time" +msgstr "Tiempo" + +msgid "Level" +msgstr "Nivel" + +msgid "Restart" +msgstr "Reinicia" + + diff --git a/examples/adding_up_to_10_canvas/po/es.po b/examples/adding_up_to_10_canvas/po/es.po new file mode 100755 index 0000000..b665366 --- /dev/null +++ b/examples/adding_up_to_10_canvas/po/es.po @@ -0,0 +1,29 @@ +# Spanish translations for PACKAGE package. +msgid "" +msgstr "" +"Project-Id-Version: adding up to 10 v1\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2009-07-07 04:46-0600\n" +"Last-Translator: Felipe López Toledo \n" +"Language-Team: karma \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Spanish\n" +"X-Poedit-Country: MEXICO\n" +"X-Poedit-SourceCharset: utf-8\n" + + +msgid "choose an option" +msgstr "escoge una opciónXXX" + +msgid "Time" +msgstr "Tiempo" + +msgid "Level" +msgstr "Nivel" + +msgid "Restart" +msgstr "Reinicia" + + diff --git a/examples/adding_up_to_10_canvas/po/he-IL.po b/examples/adding_up_to_10_canvas/po/he-IL.po new file mode 100755 index 0000000..f681aca --- /dev/null +++ b/examples/adding_up_to_10_canvas/po/he-IL.po @@ -0,0 +1,28 @@ +# Hebrew translations for PACKAGE package. +msgid "" +msgstr "" +"Project-Id-Version: adding up to 10 v1\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: 2009-07-07 04:46-0600\n" +"Last-Translator: Felipe López Toledo \n" +"Language-Team: karma \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Hebrew\n" +"X-Poedit-Country: Israel\n" +"X-Poedit-SourceCharset: utf-8\n" + + +msgid "choose an option" +msgstr "בחר באפשרות" + +msgid "Time" +msgstr "שעה" + +msgid "Level" +msgstr "רמת" + +msgid "Restart" +msgstr "הפעל מחדש" + diff --git a/examples/adding_up_to_10_canvas/resources.html b/examples/adding_up_to_10_canvas/resources.html new file mode 100755 index 0000000..0e93455 --- /dev/null +++ b/examples/adding_up_to_10_canvas/resources.html @@ -0,0 +1,37 @@ + + + + Karma - Adding Up to 10 + + + + + + + + + + + + + + + + + + -- cgit v0.9.1