diff options
author | Roshan Karki <roshan@olenepal.org> | 2009-09-11 07:40:24 (GMT) |
---|---|---|
committer | Roshan Karki <roshan@olenepal.org> | 2009-09-11 07:40:24 (GMT) |
commit | 4ef87de7ef6630928597f7935f0d0e1902277fb7 (patch) | |
tree | 1d2c66d395398fa2c946f5b3e253e7b762ea89ff | |
parent | 114b1d183d3e5e7fdccd1805ec4431996e41993b (diff) | |
parent | 832f74505610cbb02bbfe0b9797ef2f4b13d7b9c (diff) |
Merge branch 'master' of gitorious@git.sugarlabs.org:karma/mainline
26 files changed, 85 insertions, 375 deletions
diff --git a/docs/index.html~ b/docs/index.html~ deleted file mode 100755 index c6c86fb..0000000 --- a/docs/index.html~ +++ /dev/null @@ -1,61 +0,0 @@ -<html lang="en"> - -<head> -<title>Karma - Adding Up to 10</title> -<meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal"> -<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - -<link rel="icon" type="image/ico" href="favicon.ico" /> - -<link rel="stylesheet" type="text/css" href="css/karma.css" /> -<link rel="stylesheet" type="text/css" href="css/jquery.jgrowl.css" /> -<link rel="stylesheet" type="text/css" href="css/adding_up_to_10.css" /> - -<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script> -<script type="text/javascript" src="js/jquery.ui.all.js"></script> -<script type="text/javascript" src="js/jquery.jgrowl_minimized.js"></script> -<script type="text/javascript" src="js/jquery.localisation.min.js"></script> -<script type="text/javascript" src="js/Gettext.js"></script> -<script type="text/javascript" src="js/adding_up_to_10.js"></script> - -<link rel="gettext" type="application/x-po" href="po/en-US.po"> -<link rel="gettext" type="application/x-po" href="po/es-MX.po"> -<link rel="gettext" type="application/x-po" href="po/ne-NE.po"> -<link rel="gettext" type="application/x-po" href="po/he-IL.po"> - -</head> - -<body> - - <noscript> - Man, you need to enable JavaScript. - </noscript> - - - <div id="karma"> - <canvas id="canvas" width="1200" height="800"></canvas> - <canvas id="canvasDrawing" width="1200" height="800"></canvas> - </div> - - - <div id="test"> - Change to another language: - <form name=langSelector > - - <!-- <input type="radio" name="lang" value="def" checked> Default: English - United States <br/> --> - <input type="radio" id="langid" name="lang" value="en-US" /> English - United States <br/> - <input type="radio" id="langid" name="lang" value="es-MX" /> Spanish - Mexico <br/> - <input type="radio" id="langid" name="lang" value="ne-NE" /> Nepalli - Nepal <br/> - <input type="radio" id="langid" name="lang" value="he-IL" /> Hebrew - Israel <br/> - </form> - </div> - <div id="debug"> - </div> - -</body> -</html> - - - - - diff --git a/examples/adding_up_to_10/assets/en/sounds/en_correct.ogg b/examples/adding_up_to_10/assets/en/sounds/en_correct.ogg Binary files differindex c89ce57..a0d9e3a 100755 --- a/examples/adding_up_to_10/assets/en/sounds/en_correct.ogg +++ b/examples/adding_up_to_10/assets/en/sounds/en_correct.ogg diff --git a/examples/adding_up_to_10/assets/en/sounds/en_incorrect.ogg b/examples/adding_up_to_10/assets/en/sounds/en_incorrect.ogg Binary files differindex 2306562..4805e55 100755 --- a/examples/adding_up_to_10/assets/en/sounds/en_incorrect.ogg +++ b/examples/adding_up_to_10/assets/en/sounds/en_incorrect.ogg diff --git a/examples/adding_up_to_10/assets/en/sounds/en_trigger.ogg b/examples/adding_up_to_10/assets/en/sounds/en_trigger.ogg Binary files differdeleted file mode 100755 index f22512a..0000000 --- a/examples/adding_up_to_10/assets/en/sounds/en_trigger.ogg +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/balloon.png b/examples/adding_up_to_10/assets/generic/images/balloon.png Binary files differdeleted file mode 100755 index 6c17c31..0000000 --- a/examples/adding_up_to_10/assets/generic/images/balloon.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/bamboo_pattern.png b/examples/adding_up_to_10/assets/generic/images/bamboo_pattern.png Binary files differdeleted file mode 100755 index 2ee8cfd..0000000 --- a/examples/adding_up_to_10/assets/generic/images/bamboo_pattern.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/banana.png b/examples/adding_up_to_10/assets/generic/images/banana.png Binary files differdeleted file mode 100755 index 7600af1..0000000 --- a/examples/adding_up_to_10/assets/generic/images/banana.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/bg.png b/examples/adding_up_to_10/assets/generic/images/bg.png Binary files differdeleted file mode 100755 index 84f6aaa..0000000 --- a/examples/adding_up_to_10/assets/generic/images/bg.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/bg.png.bak b/examples/adding_up_to_10/assets/generic/images/bg.png.bak Binary files differdeleted file mode 100755 index 84f6aaa..0000000 --- a/examples/adding_up_to_10/assets/generic/images/bg.png.bak +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/fish.png b/examples/adding_up_to_10/assets/generic/images/fish.png Binary files differdeleted file mode 100755 index 89a5619..0000000 --- a/examples/adding_up_to_10/assets/generic/images/fish.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/flower.png b/examples/adding_up_to_10/assets/generic/images/flower.png Binary files differdeleted file mode 100755 index 6f3035e..0000000 --- a/examples/adding_up_to_10/assets/generic/images/flower.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png Binary files differdeleted file mode 100755 index 1103ac4..0000000 --- a/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/logo_w_name.png b/examples/adding_up_to_10/assets/generic/images/logo_w_name.png Binary files differdeleted file mode 100755 index 8943803..0000000 --- a/examples/adding_up_to_10/assets/generic/images/logo_w_name.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png Binary files differdeleted file mode 100755 index 59cdf68..0000000 --- a/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/old.png b/examples/adding_up_to_10/assets/generic/images/old.png Binary files differdeleted file mode 100755 index 522fb66..0000000 --- a/examples/adding_up_to_10/assets/generic/images/old.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png Binary files differdeleted file mode 100755 index 7dc2d37..0000000 --- a/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/solid_box.png b/examples/adding_up_to_10/assets/generic/images/solid_box.png Binary files differdeleted file mode 100755 index a3cad30..0000000 --- a/examples/adding_up_to_10/assets/generic/images/solid_box.png +++ /dev/null diff --git a/examples/adding_up_to_10/assets/generic/images/striped_box.png b/examples/adding_up_to_10/assets/generic/images/striped_box.png Binary files differdeleted file mode 100755 index fb9c720..0000000 --- a/examples/adding_up_to_10/assets/generic/images/striped_box.png +++ /dev/null diff --git a/examples/adding_up_to_10/css/lesson.css b/examples/adding_up_to_10/css/lesson.css index 4b86d07..5147cfa 100755 --- a/examples/adding_up_to_10/css/lesson.css +++ b/examples/adding_up_to_10/css/lesson.css @@ -166,9 +166,8 @@ left:25px; } -#reset { +#buttons { position:absolute; top:80%; -left:20%; } diff --git a/examples/adding_up_to_10/css/lesson1.css b/examples/adding_up_to_10/css/lesson1.css deleted file mode 100755 index 9556043..0000000 --- a/examples/adding_up_to_10/css/lesson1.css +++ /dev/null @@ -1,26 +0,0 @@ -#karma-main { - position: relative; - background-repeat: no-repeat; - width: 400px; - height: 400px; - border: 2px solid black; -} - -#canvas0 { - position: relative; - border: 2px solid black; - width: 395px; - height: 395px; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; - z-index: 1; -} - -#canvas0 #canvas1 { - position: relative; - border: 10px solid black; - width: 390px; - height: 350px; - z-index: 2; -} - diff --git a/examples/adding_up_to_10/css/lesson_multiple.css b/examples/adding_up_to_10/css/lesson_multiple.css deleted file mode 100755 index acce1f7..0000000 --- a/examples/adding_up_to_10/css/lesson_multiple.css +++ /dev/null @@ -1,15 +0,0 @@ -#karma-main { - /*position: relative; - background-image: url('../assets/generic/images/bg.png'); - width: 1200px; - height: 800px; - */ -} -canvas { - border: 2px solid #cccccc; - image-rendering: optimizeSpeed; - -moz-border-radius: 8px; - -webkit-border-radius: 8px; -} - - diff --git a/examples/adding_up_to_10/css/mytest.css b/examples/adding_up_to_10/css/mytest.css deleted file mode 100755 index db60f36..0000000 --- a/examples/adding_up_to_10/css/mytest.css +++ /dev/null @@ -1,182 +0,0 @@ - -#main { -width:800px; -height:600px; -position:absolute; -} -#action { -float:left; -position:relative; -width: 650px; -height: 600px; - -} -#sidebar { -background-image: url(../assets/generic/images/sidebar.png); --moz-background-clip:border; --moz-background-inline-policy:continuous; --moz-background-origin:padding; -background:none none repeat scroll 0 0; -float:left; -height:600px; -position:relative; -width:150px; -} -#actionTop { -width: 650px; -height: 300px; -position:relative; -} -#bottom { -clear:both; -float:left; -width: 650px; -height: 300px; -position:relative; -} -#topLt { -float:left; -width: 300px; -height: 300px; -position:relative; -} -#topMd { --moz-background-clip:border; --moz-background-inline-policy:continuous; --moz-background-origin:padding; -background:none none repeat scroll 0 0; -float:left; -width: 50px; -height: 300px; -position:relative; -} -#topRt { -float:left; -width: 300px; -height:300px; -position:relative; -} -#topLtBox { --moz-background-clip:border; --moz-background-inline-policy:continuous; --moz-background-origin:padding; -background:none none repeat scroll 0 0; -width: 200px; -height: 200px; -left: 75px; -position:absolute; -top:50px; -} -#topLtCanvas { --moz-background-clip:border; --moz-background-inline-policy:continuous; --moz-background-origin:padding; -background:none none repeat scroll 0 0; -position:absolute; -top: 50px; -left: 75px; -} -#plussign { -display: block; -margin-left: auto; -margin-right: auto; -margin-top: 150px; -} -#topRtBox { -background: none none repeat scroll 0 0; -width: 200px; -height: 200px; -position:absolute; -right: 50px; -top: 50px; -} -#topRtCanvas { -background:none none repeat scroll 0 0; -position:absolute; -right:50px; -top:50px; -} - -.bottom { --moz-background-clip:border; --moz-background-inline-policy:continuous; --moz-background-origin:padding; -background:none none repeat scroll 0 0; -float:left; -width: 216.5px; -height: 300px; -position:relative; -} - -.bottomBox { - left:25px; - position:absolute; - width: 200px; - height: 200px; - top: 20px; -} - -.sidebarItem { - clear:both; - float:left; - width:150px; - height: 200px; - position: relative; -} - -#timer { -position:absolute; -width:100px; -height:150px; -top:10px; -left:25px; -} - -#timerCanvas { -position:absolute; -width:100px; -height:150px; -top:10px; -left:25px; -} - -#scorebox { -position:absolute; -width:100px; -height:150px; -top:10px; -left:25px; -} - -#scoreboxCanvas { -position:absolute; -width:100px; -height:150px; -top:10px; -left:25px; -} - - -#chimpCanvas { -position:absolute; -width:120px; -height:160px; -top:10px; -left:25px; - -} - -#resetButton { -position:absolute; -top:20%; -} - -#banana { -height:0px; -width:0px; -} -#ball { -height:0px; -width:0px; -} -
\ No newline at end of file diff --git a/examples/adding_up_to_10/index.html b/examples/adding_up_to_10/index.html index ac27b7d..ea752d9 100755 --- a/examples/adding_up_to_10/index.html +++ b/examples/adding_up_to_10/index.html @@ -65,7 +65,11 @@ </div> <div class="sidebarItem"> <canvas id="chimpCanvas" width="120px" height="125px"> </canvas> - <button id="reset">Start Over</button> + <div id="buttons"> + <button id="start">Start</button> + <button id="stop">Stop</button> + <button id="reset">Restart</button> + </div> </div> diff --git a/examples/adding_up_to_10/js/lesson.js b/examples/adding_up_to_10/js/lesson.js index c67dbb1..7ae5881 100755 --- a/examples/adding_up_to_10/js/lesson.js +++ b/examples/adding_up_to_10/js/lesson.js @@ -1,5 +1,6 @@ $(document).ready(function(){ + var k = $.karma ({container: "#karma-main", lang: "en"}); k.init({ @@ -18,7 +19,7 @@ $(document).ready(function(){ sounds: [ {id: "correct", file: "correct.ogg"}, {id: "incorrect", file: "incorrect.ogg"}, - {id: "trigger", file: "trigger.ogg"} + {id: "trigger", file: "trigger.ogg", localized: false} ], surfaces: [ @@ -36,23 +37,21 @@ $(document).ready(function(){ k.main(function() { - var actionContexts = [ k.surfaces["topLt"].ctx, k.surfaces["topRt"].ctx, - k.surfaces["bottomLt"].ctx, k.surfaces["bottomMd"].ctx, - k.surfaces["bottomRt"].ctx]; - - var imgNames = ["ball", "banana", "balloon","chilli", "fish", "flower"]; - //game logic - var total, level=0, time, n0, n1, correct; - var maskd=200; - var d=160; - var choices=[]; - var score = 0; + //game logic + 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 = 20; - var timerId; + var startTimerY = 10; + var endTimerY = 100; + var offsetTimerY = 5; + var timerId; var timerFn = function () { k.surfaces['timer'].clear(); @@ -166,8 +165,8 @@ k.main(function() { if ( correct === false) { //answer was incorrect or took too long - startTimerY = 10; score = score - 1; + playerCorrect = playerCorrect - 1; writeScore(); if (tooSlow === true) { k.library.sounds[ "trigger" ].play(); @@ -178,17 +177,24 @@ k.main(function() { animateChimp(false); } else { - startTimerY = 10; score = score + 1; + playerCorrect = playerCorrect + 1; writeScore(); k.library.sounds[ "correct" ].play(); animateChimp(true); - level = (level+1)% imgNames.length; + if (playerCorrect === 5){ + level = (level+1)% imgNames.length; + speed = speed - 300; + playerCorrect = 0; + } } + changeTimer('start'); + }; var animateChimp = function (answer) { + var timerChimp; k.surfaces["chimp"].clear(); if( answer === true){ k.library.images["happyChimp"].draw(k.surfaces["chimp"], 0, 0); @@ -201,12 +207,23 @@ k.main(function() { k.library.images["normalChimp"].draw(k.surfaces["chimp"], 0, 0); }; - timerId = setTimeout(restoreChimp, 800); + timerChimp = setTimeout(restoreChimp, 800); }; + + var changeTimer = function (status){ + startTimerY = 10; + k.surfaces["timer"].clear(); + clearInterval(timerId); - var reset = function () { + if (status === 'start'){ + timerId = setInterval(timerFn, speed); + } + + }; + + var startStop = function (start) { score = level = 0; startTimerY = 10; $.each(k.surfaces, function () { @@ -214,13 +231,28 @@ k.main(function() { this.clear(); } }); - + + changeTimer('start'); game(); + }; - document.getElementById('reset'). - addEventListener('click', reset, true); + var start = function () { + startStop(true); + }; + + + var stop = function () { + changeTimer('stop'); + }; + + var reset = function () { + startStop(true); + }; + + + //put the buttons @@ -233,13 +265,29 @@ k.main(function() { item.surface.canvas.addEventListener('click', function( ev ) { if ( choices[ item.id ] === total){ answer(true); - }else { answer(false); } - game(); - }, true); + game(); + }else { + answer(false); + game(); + } + + }, false); }); - timerId = setInterval (timerFn, 2000); + + document.getElementById('start'). + addEventListener('click', start, false); + + + document.getElementById('stop'). + addEventListener('click', stop, false); + + document.getElementById('reset'). + addEventListener('click', reset, false); + k.library.images["normalChimp"].draw(k.surfaces["chimp"], 0, 0); - game(); + + + //end of Karma.main }); //end of ready diff --git a/examples/adding_up_to_10/js/lesson_multiple.js b/examples/adding_up_to_10/js/lesson_multiple.js deleted file mode 100755 index b3aa652..0000000 --- a/examples/adding_up_to_10/js/lesson_multiple.js +++ /dev/null @@ -1,57 +0,0 @@ -$(document).ready(function(){ -var k = $.karma ({container: "#karma-main", lang:"es-MX"}); -k.init({ - images: [ - {id: "ball", file: "ball37px.png", localized : false }, - {id: "balloon", file: "balloon.png", localized : false }, - {id: "banana", file: "banana.png", localized : false }, - {id: "chilli", file: "chilli.png", localized : false }, - {id: "fish" , file: "fish.png", localized : false }, - {id: "flower", file: "flower.png", localized : false }, - {id: "plussign", file: "plussign.png", localized : false }, - {id: "happyMonkey", file: "happyMonkey.jpg", localized : false }, - {id: "scorebox", file: "scorebox.png", localized : false } - ], - sounds: [ - {id: "correct", file: "correct.ogg", localized:false}, - {id: "incorrect", file: "incorrect.ogg"}, - {id: "trigger", file: "trigger1.ogg", localized:false} - - ], - surfaces: [ - {id: "card1", width:250, height:250}, - {id: "card2", width:250, height:250}, - {id: "card3", width:250, height:250}, - {id: "inline1", canvas:"inlineCanvas1"}, - {id: "inline2", canvas:"inlineCanvas2"} - ] -}); - -k.main(function() { - - - var library = k.library; - var surfaces = k.surfaces; - var sounds = library.sounds; - - sounds["trigger"].play(); - library.images["ball"].draw( surfaces["card1"].ctx ); - library.images["balloon"].draw( surfaces["card2"].ctx ); - library.images["banana"].draw( surfaces["card3"].ctx ); - library.images["ball"].draw( surfaces["inline1"].ctx ); - library.images["fish"].draw( surfaces["inline2"].ctx ); - - //surfaces["inline1"].ctx.drawWindow(window, 0, 0, 100, 200, "rgb(0,0,0)"); - - surfaces["inline2"].addEventListener( - "click", - function(){surfaces["inline2"].clear();} - ); - surfaces["inline1"].fillStyle("#006699").fillRect(0, 0, 150, 150); - /* - surfaces["inline1"].ctx.fillStyle = "#00f"; - surfaces["inline1"].ctx.fillRect(0, 0, 150, 150); - surfaces["card1"].ctx.fillStyle = "#000"; - surfaces["card1"].ctx.fillRect(0, 0, 150, 150);*/ -}); -});
\ No newline at end of file diff --git a/examples/adding_up_to_10/resources.html b/examples/adding_up_to_10/resources.html index bb4c85a..0e93455 100755 --- a/examples/adding_up_to_10/resources.html +++ b/examples/adding_up_to_10/resources.html @@ -1,10 +1,10 @@ <!DOCTYPE html> -<html lang="en"> +<html> <head> <title>Karma - Adding Up to 10</title> <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" /> <link type="text/css" rel="stylesheet" href="css/lesson.css" /> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link type="image/ico" rel="icon" href="../../assets/default/images/favicon.ico" /> <script type="text/javascript" src="../../js/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="../../js/karma.Gettext.js"></script> |