User prompt
add a 1
User prompt
add a 0
User prompt
add all the number 1 2 3 4 5 6 7 8 9
User prompt
make a keyboard with only numbers \ to right the answer
User prompt
try to make it only with numbers
User prompt
make a text bar appear when you right
User prompt
IF YOU PRESS THE READ BUTTON IT WILL TEACH YOU HOW TO READ
User prompt
MAKE THERE A BUTTON FOR HOW TO READ
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'setTimeout(function () {' Line Number: 484
User prompt
I can not right on †he text bar
User prompt
make the text bar work
User prompt
make it written text
User prompt
make the text bar able to right one
User prompt
make the text bar usable
Code edit (1 edits merged)
Please save this source code
User prompt
Math & Write Adventure
Initial prompt
learn it is a kids game that teach you math and how to right
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var CelebrationStar = Container.expand(function () { var self = Container.call(this); var starGraphic = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.startAnimation = function () { self.alpha = 1; self.scaleX = 0.1; self.scaleY = 0.1; tween(self, { scaleX: 1.5, scaleY: 1.5 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { tween(self, { alpha: 0, scaleX: 0.5, scaleY: 0.5 }, { duration: 500, easing: tween.easeIn, onFinish: function onFinish() { self.destroy(); } }); } }); }; return self; }); var MathProblem = Container.expand(function () { var self = Container.call(this); self.num1 = 0; self.num2 = 0; self.operation = '+'; self.answer = 0; self.difficulty = 1; self.generateProblem = function () { var maxNum = Math.min(10, 5 + self.difficulty * 2); self.num1 = Math.floor(Math.random() * maxNum) + 1; self.num2 = Math.floor(Math.random() * maxNum) + 1; var operations = ['+', '-']; if (self.difficulty > 3) { operations.push('×'); } if (self.difficulty > 5) { operations.push('÷'); } self.operation = operations[Math.floor(Math.random() * operations.length)]; if (self.operation === '-' && self.num1 < self.num2) { var temp = self.num1; self.num1 = self.num2; self.num2 = temp; } if (self.operation === '÷') { self.answer = Math.floor(Math.random() * 10) + 1; self.num1 = self.answer * self.num2; } switch (self.operation) { case '+': self.answer = self.num1 + self.num2; break; case '-': self.answer = self.num1 - self.num2; break; case '×': self.answer = self.num1 * self.num2; break; case '÷': break; } }; self.getProblemText = function () { return self.num1 + ' ' + self.operation + ' ' + self.num2 + ' = ?'; }; return self; }); var WritingArea = Container.expand(function () { var self = Container.call(this); var areaBackground = self.attachAsset('writingArea', { anchorX: 0.5, anchorY: 0.5 }); self.drawingPath = []; self.isDrawing = false; self.writtenAnswer = ''; self.startDrawing = function (x, y) { self.isDrawing = true; self.drawingPath = []; var localPos = self.toLocal({ x: x, y: y }); self.drawingPath.push({ x: localPos.x, y: localPos.y }); self.addDrawingDot(localPos.x, localPos.y); }; self.continueDrawing = function (x, y) { if (self.isDrawing) { var localPos = self.toLocal({ x: x, y: y }); self.drawingPath.push({ x: localPos.x, y: localPos.y }); self.addDrawingDot(localPos.x, localPos.y); } }; self.stopDrawing = function () { self.isDrawing = false; self.recognizeNumber(); }; self.addDrawingDot = function (x, y) { var dot = self.addChild(LK.getAsset('drawingDot', { anchorX: 0.5, anchorY: 0.5 })); dot.x = x; dot.y = y; }; self.recognizeNumber = function () { if (self.drawingPath.length > 5) { var bounds = self.getDrawingBounds(); var recognizedDigit = self.simpleNumberRecognition(bounds); if (recognizedDigit !== null) { self.writtenAnswer += recognizedDigit; answerText.setText(self.writtenAnswer); } } }; self.getDrawingBounds = function () { if (self.drawingPath.length === 0) return null; var minX = self.drawingPath[0].x; var maxX = self.drawingPath[0].x; var minY = self.drawingPath[0].y; var maxY = self.drawingPath[0].y; for (var i = 1; i < self.drawingPath.length; i++) { var point = self.drawingPath[i]; minX = Math.min(minX, point.x); maxX = Math.max(maxX, point.x); minY = Math.min(minY, point.y); maxY = Math.max(maxY, point.y); } return { minX: minX, maxX: maxX, minY: minY, maxY: maxY, width: maxX - minX, height: maxY - minY }; }; self.simpleNumberRecognition = function (bounds) { if (!bounds || bounds.width < 10 || bounds.height < 10) return null; var aspectRatio = bounds.width / bounds.height; var pathLength = self.drawingPath.length; if (aspectRatio > 2) return '1'; if (aspectRatio < 0.5 && pathLength > 30) return '1'; if (aspectRatio > 0.7 && aspectRatio < 1.3 && pathLength > 25) return '0'; if (pathLength > 20 && pathLength < 40) return '2'; if (pathLength > 15 && pathLength < 35) return '3'; if (pathLength > 10 && pathLength < 30) return '4'; if (pathLength > 20 && pathLength < 45) return '5'; if (pathLength > 25 && pathLength < 50) return '6'; if (pathLength > 10 && pathLength < 25) return '7'; if (pathLength > 30 && pathLength < 60) return '8'; if (pathLength > 25 && pathLength < 55) return '9'; return Math.floor(Math.random() * 10).toString(); }; self.clearDrawing = function () { for (var i = self.children.length - 1; i >= 0; i--) { var child = self.children[i]; if (child !== areaBackground) { child.destroy(); } } self.drawingPath = []; self.writtenAnswer = ''; answerText.setText(''); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var currentProblem = new MathProblem(); var writingArea = new WritingArea(); var gameState = 'playing'; var correctAnswers = 0; var level = storage.level || 1; var celebrationStars = []; currentProblem.difficulty = level; currentProblem.generateProblem(); var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); var problemBox = game.addChild(LK.getAsset('problemBox', { anchorX: 0.5, anchorY: 0.5 })); problemBox.x = 1024; problemBox.y = 600; var problemText = new Text2(currentProblem.getProblemText(), { size: 120, fill: 0x333333 }); problemText.anchor.set(0.5, 0.5); problemText.x = 1024; problemText.y = 600; game.addChild(problemText); writingArea.x = 1024; writingArea.y = 1200; game.addChild(writingArea); var instructionText = new Text2('Write your answer below:', { size: 80, fill: 0x444444 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 950; game.addChild(instructionText); var answerText = new Text2('', { size: 150, fill: 0x000000 }); answerText.anchor.set(0.5, 0.5); answerText.x = 1024; answerText.y = 1200; game.addChild(answerText); var submitButton = game.addChild(LK.getAsset('submitButton', { anchorX: 0.5, anchorY: 0.5 })); submitButton.x = 800; submitButton.y = 1600; var submitButtonText = new Text2('Check', { size: 60, fill: 0xFFFFFF }); submitButtonText.anchor.set(0.5, 0.5); submitButtonText.x = 800; submitButtonText.y = 1600; game.addChild(submitButtonText); var clearButton = game.addChild(LK.getAsset('submitButton', { anchorX: 0.5, anchorY: 0.5 })); clearButton.x = 1248; clearButton.y = 1600; clearButton.tint = 0xFF6B6B; var clearButtonText = new Text2('Clear', { size: 60, fill: 0xFFFFFF }); clearButtonText.anchor.set(0.5, 0.5); clearButtonText.x = 1248; clearButtonText.y = 1600; game.addChild(clearButtonText); var nextButton = game.addChild(LK.getAsset('nextButton', { anchorX: 0.5, anchorY: 0.5 })); nextButton.x = 1024; nextButton.y = 1900; nextButton.alpha = 0; var nextButtonText = new Text2('Next Problem', { size: 60, fill: 0xFFFFFF }); nextButtonText.anchor.set(0.5, 0.5); nextButtonText.x = 1024; nextButtonText.y = 1900; nextButtonText.alpha = 0; game.addChild(nextButtonText); var feedbackText = new Text2('', { size: 80, fill: 0x32CD32 }); feedbackText.anchor.set(0.5, 0.5); feedbackText.x = 1024; feedbackText.y = 1750; game.addChild(feedbackText); var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var levelText = new Text2('Level: ' + level, { size: 60, fill: 0xFFFFFF }); levelText.anchor.set(1, 0); LK.gui.topRight.addChild(levelText); levelText.x = -120; function checkAnswer() { var userAnswer = parseInt(writingArea.writtenAnswer); var correctAnswer = currentProblem.answer; if (userAnswer === correctAnswer) { feedbackText.setText('Correct! Great job!'); feedbackText.tint = 0x32CD32; LK.getSound('correct').play(); correctAnswers++; LK.setScore(LK.getScore() + 10 * level); scoreText.setText('Score: ' + LK.getScore()); createCelebrationStars(); nextButton.alpha = 1; nextButtonText.alpha = 1; gameState = 'correct'; if (correctAnswers >= 5) { level++; storage.level = level; levelText.setText('Level: ' + level); currentProblem.difficulty = level; correctAnswers = 0; setTimeout(function () { feedbackText.setText('Level Up! Well done!'); LK.getSound('celebration').play(); }, 1000); } } else { feedbackText.setText('Try again! The answer is ' + correctAnswer); feedbackText.tint = 0xFF6B6B; LK.getSound('incorrect').play(); setTimeout(function () { feedbackText.setText(''); writingArea.clearDrawing(); }, 2000); } } function createCelebrationStars() { for (var i = 0; i < 5; i++) { var star = new CelebrationStar(); star.x = 1024 + (Math.random() - 0.5) * 600; star.y = 1200 + (Math.random() - 0.5) * 400; celebrationStars.push(star); game.addChild(star); setTimeout(function (starToAnimate) { return function () { starToAnimate.startAnimation(); }; }(star), i * 100); } } function nextProblem() { currentProblem.generateProblem(); problemText.setText(currentProblem.getProblemText()); writingArea.clearDrawing(); feedbackText.setText(''); nextButton.alpha = 0; nextButtonText.alpha = 0; gameState = 'playing'; } game.down = function (x, y, obj) { if (gameState === 'playing') { if (obj === writingArea || writingArea.getBounds().contains(x, y)) { writingArea.startDrawing(x, y); } } }; game.move = function (x, y, obj) { if (gameState === 'playing') { writingArea.continueDrawing(x, y); } }; game.up = function (x, y, obj) { if (gameState === 'playing') { writingArea.stopDrawing(); } }; submitButton.down = function (x, y, obj) { if (gameState === 'playing' && writingArea.writtenAnswer !== '') { checkAnswer(); } }; clearButton.down = function (x, y, obj) { if (gameState === 'playing') { writingArea.clearDrawing(); feedbackText.setText(''); } }; nextButton.down = function (x, y, obj) { if (gameState === 'correct') { nextProblem(); } }; game.update = function () { for (var i = celebrationStars.length - 1; i >= 0; i--) { var star = celebrationStars[i]; if (star.alpha <= 0) { celebrationStars.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,419 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var CelebrationStar = Container.expand(function () {
+ var self = Container.call(this);
+ var starGraphic = self.attachAsset('star', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.startAnimation = function () {
+ self.alpha = 1;
+ self.scaleX = 0.1;
+ self.scaleY = 0.1;
+ tween(self, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5
+ }, {
+ duration: 500,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ }
+ });
+ };
+ return self;
+});
+var MathProblem = Container.expand(function () {
+ var self = Container.call(this);
+ self.num1 = 0;
+ self.num2 = 0;
+ self.operation = '+';
+ self.answer = 0;
+ self.difficulty = 1;
+ self.generateProblem = function () {
+ var maxNum = Math.min(10, 5 + self.difficulty * 2);
+ self.num1 = Math.floor(Math.random() * maxNum) + 1;
+ self.num2 = Math.floor(Math.random() * maxNum) + 1;
+ var operations = ['+', '-'];
+ if (self.difficulty > 3) {
+ operations.push('×');
+ }
+ if (self.difficulty > 5) {
+ operations.push('÷');
+ }
+ self.operation = operations[Math.floor(Math.random() * operations.length)];
+ if (self.operation === '-' && self.num1 < self.num2) {
+ var temp = self.num1;
+ self.num1 = self.num2;
+ self.num2 = temp;
+ }
+ if (self.operation === '÷') {
+ self.answer = Math.floor(Math.random() * 10) + 1;
+ self.num1 = self.answer * self.num2;
+ }
+ switch (self.operation) {
+ case '+':
+ self.answer = self.num1 + self.num2;
+ break;
+ case '-':
+ self.answer = self.num1 - self.num2;
+ break;
+ case '×':
+ self.answer = self.num1 * self.num2;
+ break;
+ case '÷':
+ break;
+ }
+ };
+ self.getProblemText = function () {
+ return self.num1 + ' ' + self.operation + ' ' + self.num2 + ' = ?';
+ };
+ return self;
+});
+var WritingArea = Container.expand(function () {
+ var self = Container.call(this);
+ var areaBackground = self.attachAsset('writingArea', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.drawingPath = [];
+ self.isDrawing = false;
+ self.writtenAnswer = '';
+ self.startDrawing = function (x, y) {
+ self.isDrawing = true;
+ self.drawingPath = [];
+ var localPos = self.toLocal({
+ x: x,
+ y: y
+ });
+ self.drawingPath.push({
+ x: localPos.x,
+ y: localPos.y
+ });
+ self.addDrawingDot(localPos.x, localPos.y);
+ };
+ self.continueDrawing = function (x, y) {
+ if (self.isDrawing) {
+ var localPos = self.toLocal({
+ x: x,
+ y: y
+ });
+ self.drawingPath.push({
+ x: localPos.x,
+ y: localPos.y
+ });
+ self.addDrawingDot(localPos.x, localPos.y);
+ }
+ };
+ self.stopDrawing = function () {
+ self.isDrawing = false;
+ self.recognizeNumber();
+ };
+ self.addDrawingDot = function (x, y) {
+ var dot = self.addChild(LK.getAsset('drawingDot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ dot.x = x;
+ dot.y = y;
+ };
+ self.recognizeNumber = function () {
+ if (self.drawingPath.length > 5) {
+ var bounds = self.getDrawingBounds();
+ var recognizedDigit = self.simpleNumberRecognition(bounds);
+ if (recognizedDigit !== null) {
+ self.writtenAnswer += recognizedDigit;
+ answerText.setText(self.writtenAnswer);
+ }
+ }
+ };
+ self.getDrawingBounds = function () {
+ if (self.drawingPath.length === 0) return null;
+ var minX = self.drawingPath[0].x;
+ var maxX = self.drawingPath[0].x;
+ var minY = self.drawingPath[0].y;
+ var maxY = self.drawingPath[0].y;
+ for (var i = 1; i < self.drawingPath.length; i++) {
+ var point = self.drawingPath[i];
+ minX = Math.min(minX, point.x);
+ maxX = Math.max(maxX, point.x);
+ minY = Math.min(minY, point.y);
+ maxY = Math.max(maxY, point.y);
+ }
+ return {
+ minX: minX,
+ maxX: maxX,
+ minY: minY,
+ maxY: maxY,
+ width: maxX - minX,
+ height: maxY - minY
+ };
+ };
+ self.simpleNumberRecognition = function (bounds) {
+ if (!bounds || bounds.width < 10 || bounds.height < 10) return null;
+ var aspectRatio = bounds.width / bounds.height;
+ var pathLength = self.drawingPath.length;
+ if (aspectRatio > 2) return '1';
+ if (aspectRatio < 0.5 && pathLength > 30) return '1';
+ if (aspectRatio > 0.7 && aspectRatio < 1.3 && pathLength > 25) return '0';
+ if (pathLength > 20 && pathLength < 40) return '2';
+ if (pathLength > 15 && pathLength < 35) return '3';
+ if (pathLength > 10 && pathLength < 30) return '4';
+ if (pathLength > 20 && pathLength < 45) return '5';
+ if (pathLength > 25 && pathLength < 50) return '6';
+ if (pathLength > 10 && pathLength < 25) return '7';
+ if (pathLength > 30 && pathLength < 60) return '8';
+ if (pathLength > 25 && pathLength < 55) return '9';
+ return Math.floor(Math.random() * 10).toString();
+ };
+ self.clearDrawing = function () {
+ for (var i = self.children.length - 1; i >= 0; i--) {
+ var child = self.children[i];
+ if (child !== areaBackground) {
+ child.destroy();
+ }
+ }
+ self.drawingPath = [];
+ self.writtenAnswer = '';
+ answerText.setText('');
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var currentProblem = new MathProblem();
+var writingArea = new WritingArea();
+var gameState = 'playing';
+var correctAnswers = 0;
+var level = storage.level || 1;
+var celebrationStars = [];
+currentProblem.difficulty = level;
+currentProblem.generateProblem();
+var background = game.addChild(LK.getAsset('background', {
+ anchorX: 0,
+ anchorY: 0
+}));
+var problemBox = game.addChild(LK.getAsset('problemBox', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+problemBox.x = 1024;
+problemBox.y = 600;
+var problemText = new Text2(currentProblem.getProblemText(), {
+ size: 120,
+ fill: 0x333333
+});
+problemText.anchor.set(0.5, 0.5);
+problemText.x = 1024;
+problemText.y = 600;
+game.addChild(problemText);
+writingArea.x = 1024;
+writingArea.y = 1200;
+game.addChild(writingArea);
+var instructionText = new Text2('Write your answer below:', {
+ size: 80,
+ fill: 0x444444
+});
+instructionText.anchor.set(0.5, 0.5);
+instructionText.x = 1024;
+instructionText.y = 950;
+game.addChild(instructionText);
+var answerText = new Text2('', {
+ size: 150,
+ fill: 0x000000
+});
+answerText.anchor.set(0.5, 0.5);
+answerText.x = 1024;
+answerText.y = 1200;
+game.addChild(answerText);
+var submitButton = game.addChild(LK.getAsset('submitButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+submitButton.x = 800;
+submitButton.y = 1600;
+var submitButtonText = new Text2('Check', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+submitButtonText.anchor.set(0.5, 0.5);
+submitButtonText.x = 800;
+submitButtonText.y = 1600;
+game.addChild(submitButtonText);
+var clearButton = game.addChild(LK.getAsset('submitButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+clearButton.x = 1248;
+clearButton.y = 1600;
+clearButton.tint = 0xFF6B6B;
+var clearButtonText = new Text2('Clear', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+clearButtonText.anchor.set(0.5, 0.5);
+clearButtonText.x = 1248;
+clearButtonText.y = 1600;
+game.addChild(clearButtonText);
+var nextButton = game.addChild(LK.getAsset('nextButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+}));
+nextButton.x = 1024;
+nextButton.y = 1900;
+nextButton.alpha = 0;
+var nextButtonText = new Text2('Next Problem', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+nextButtonText.anchor.set(0.5, 0.5);
+nextButtonText.x = 1024;
+nextButtonText.y = 1900;
+nextButtonText.alpha = 0;
+game.addChild(nextButtonText);
+var feedbackText = new Text2('', {
+ size: 80,
+ fill: 0x32CD32
+});
+feedbackText.anchor.set(0.5, 0.5);
+feedbackText.x = 1024;
+feedbackText.y = 1750;
+game.addChild(feedbackText);
+var scoreText = new Text2('Score: 0', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreText);
+var levelText = new Text2('Level: ' + level, {
+ size: 60,
+ fill: 0xFFFFFF
+});
+levelText.anchor.set(1, 0);
+LK.gui.topRight.addChild(levelText);
+levelText.x = -120;
+function checkAnswer() {
+ var userAnswer = parseInt(writingArea.writtenAnswer);
+ var correctAnswer = currentProblem.answer;
+ if (userAnswer === correctAnswer) {
+ feedbackText.setText('Correct! Great job!');
+ feedbackText.tint = 0x32CD32;
+ LK.getSound('correct').play();
+ correctAnswers++;
+ LK.setScore(LK.getScore() + 10 * level);
+ scoreText.setText('Score: ' + LK.getScore());
+ createCelebrationStars();
+ nextButton.alpha = 1;
+ nextButtonText.alpha = 1;
+ gameState = 'correct';
+ if (correctAnswers >= 5) {
+ level++;
+ storage.level = level;
+ levelText.setText('Level: ' + level);
+ currentProblem.difficulty = level;
+ correctAnswers = 0;
+ setTimeout(function () {
+ feedbackText.setText('Level Up! Well done!');
+ LK.getSound('celebration').play();
+ }, 1000);
+ }
+ } else {
+ feedbackText.setText('Try again! The answer is ' + correctAnswer);
+ feedbackText.tint = 0xFF6B6B;
+ LK.getSound('incorrect').play();
+ setTimeout(function () {
+ feedbackText.setText('');
+ writingArea.clearDrawing();
+ }, 2000);
+ }
+}
+function createCelebrationStars() {
+ for (var i = 0; i < 5; i++) {
+ var star = new CelebrationStar();
+ star.x = 1024 + (Math.random() - 0.5) * 600;
+ star.y = 1200 + (Math.random() - 0.5) * 400;
+ celebrationStars.push(star);
+ game.addChild(star);
+ setTimeout(function (starToAnimate) {
+ return function () {
+ starToAnimate.startAnimation();
+ };
+ }(star), i * 100);
+ }
+}
+function nextProblem() {
+ currentProblem.generateProblem();
+ problemText.setText(currentProblem.getProblemText());
+ writingArea.clearDrawing();
+ feedbackText.setText('');
+ nextButton.alpha = 0;
+ nextButtonText.alpha = 0;
+ gameState = 'playing';
+}
+game.down = function (x, y, obj) {
+ if (gameState === 'playing') {
+ if (obj === writingArea || writingArea.getBounds().contains(x, y)) {
+ writingArea.startDrawing(x, y);
+ }
+ }
+};
+game.move = function (x, y, obj) {
+ if (gameState === 'playing') {
+ writingArea.continueDrawing(x, y);
+ }
+};
+game.up = function (x, y, obj) {
+ if (gameState === 'playing') {
+ writingArea.stopDrawing();
+ }
+};
+submitButton.down = function (x, y, obj) {
+ if (gameState === 'playing' && writingArea.writtenAnswer !== '') {
+ checkAnswer();
+ }
+};
+clearButton.down = function (x, y, obj) {
+ if (gameState === 'playing') {
+ writingArea.clearDrawing();
+ feedbackText.setText('');
+ }
+};
+nextButton.down = function (x, y, obj) {
+ if (gameState === 'correct') {
+ nextProblem();
+ }
+};
+game.update = function () {
+ for (var i = celebrationStars.length - 1; i >= 0; i--) {
+ var star = celebrationStars[i];
+ if (star.alpha <= 0) {
+ celebrationStars.splice(i, 1);
+ }
+ }
+};
\ No newline at end of file