User prompt
Also add the gradient backround and answer button styling
User prompt
Make the loading screen fast
User prompt
Make the game visible
User prompt
Remove the black background
User prompt
Make the game look more cool
User prompt
Add backgrounds
User prompt
Make the game harder with multiple different questions
User prompt
Position the answer text to the centre of each answer button
User prompt
Make the answer buttons bigger to press
User prompt
Generate new questions each time they play the game
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'self.color = new Graphics();' Line Number: 11
User prompt
Add button colors
Initial prompt
GameKahoot
===================================================================
--- original.js
+++ change.js
@@ -1,88 +1,95 @@
-/****
+/****
* Classes
-****/
+****/
// Class for the Answer
var Answer = Container.expand(function () {
- var self = Container.call(this);
- self.text = new Text2('', {
- size: 80,
- fill: "#ffffff"
- });
- self.text.anchor.set(0.5, 0.5);
- self.addChild(self.text);
- self.setText = function (text) {
- self.text.setText(text);
- };
- self.correct = false;
- self.down = function (x, y, obj) {
- if (self.correct) {
- LK.setScore(LK.getScore() + 1);
- scoreTxt.setText(LK.getScore());
- } else {
- LK.effects.flashScreen(0xff0000, 1000);
- }
- nextQuestion();
- };
- return self;
+ var self = Container.call(this);
+ self.text = new Text2('', {
+ size: 80,
+ fill: "#ffffff"
+ });
+ self.color = new Graphics();
+ self.color.beginFill(0x0000ff);
+ self.color.drawRect(-200, -50, 400, 100);
+ self.color.endFill();
+ self.addChildAt(self.color, 0);
+ self.text.anchor.set(0.5, 0.5);
+ self.addChild(self.text);
+ self.setText = function (text) {
+ self.text.setText(text);
+ };
+ self.correct = false;
+ self.down = function (x, y, obj) {
+ if (self.correct) {
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ self.color.tint = 0x00ff00;
+ } else {
+ LK.effects.flashScreen(0xff0000, 1000);
+ self.color.tint = 0xff0000;
+ }
+ nextQuestion();
+ };
+ return self;
});
//<Assets used in the game will automatically appear here>
// Class for the Question
var Question = Container.expand(function () {
- var self = Container.call(this);
- self.text = new Text2('', {
- size: 100,
- fill: "#ffffff"
- });
- self.text.anchor.set(0.5, 0.5);
- self.addChild(self.text);
- self.setText = function (text) {
- self.text.setText(text);
- };
- return self;
+ var self = Container.call(this);
+ self.text = new Text2('', {
+ size: 100,
+ fill: "#ffffff"
+ });
+ self.text.anchor.set(0.5, 0.5);
+ self.addChild(self.text);
+ self.setText = function (text) {
+ self.text.setText(text);
+ };
+ return self;
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
// Questions and answers
var questions = [{
- question: "What is the capital of France?",
- answers: [{
- text: "Paris",
- correct: true
- }, {
- text: "London",
- correct: false
- }, {
- text: "Berlin",
- correct: false
- }, {
- text: "Madrid",
- correct: false
- }]
+ question: "What is the capital of France?",
+ answers: [{
+ text: "Paris",
+ correct: true
+ }, {
+ text: "London",
+ correct: false
+ }, {
+ text: "Berlin",
+ correct: false
+ }, {
+ text: "Madrid",
+ correct: false
+ }]
}, {
- question: "What is 2 + 2?",
- answers: [{
- text: "3",
- correct: false
- }, {
- text: "4",
- correct: true
- }, {
- text: "5",
- correct: false
- }, {
- text: "6",
- correct: false
- }]
+ question: "What is 2 + 2?",
+ answers: [{
+ text: "3",
+ correct: false
+ }, {
+ text: "4",
+ correct: true
+ }, {
+ text: "5",
+ correct: false
+ }, {
+ text: "6",
+ correct: false
+ }]
}
// Add more questions as needed
];
var currentQuestionIndex = 0;
@@ -91,33 +98,33 @@
questionNode.y = 2732 / 4;
game.addChild(questionNode);
var answerNodes = [];
for (var i = 0; i < 4; i++) {
- var answerNode = new Answer();
- answerNode.x = 2048 / 2;
- answerNode.y = 2732 / 2 + i * 200;
- game.addChild(answerNode);
- answerNodes.push(answerNode);
+ var answerNode = new Answer();
+ answerNode.x = 2048 / 2;
+ answerNode.y = 2732 / 2 + i * 200;
+ game.addChild(answerNode);
+ answerNodes.push(answerNode);
}
var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff"
+ size: 150,
+ fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function nextQuestion() {
- if (currentQuestionIndex >= questions.length) {
- LK.showGameOver();
- return;
- }
- var question = questions[currentQuestionIndex];
- questionNode.setText(question.question);
- for (var i = 0; i < 4; i++) {
- answerNodes[i].setText(question.answers[i].text);
- answerNodes[i].correct = question.answers[i].correct;
- }
- currentQuestionIndex++;
+ if (currentQuestionIndex >= questions.length) {
+ LK.showGameOver();
+ return;
+ }
+ var question = questions[currentQuestionIndex];
+ questionNode.setText(question.question);
+ for (var i = 0; i < 4; i++) {
+ answerNodes[i].setText(question.answers[i].text);
+ answerNodes[i].correct = question.answers[i].correct;
+ }
+ currentQuestionIndex++;
}
nextQuestion();
game.update = function () {
- // Game update logic if needed
+ // Game update logic if needed
};
\ No newline at end of file