var triviaQuestions = [{ question: 'What is the capital city of Australia?', answers: ['Sydney', 'Canberra', 'Melbourne'], correct: 1 }, { question: 'Who wrote the novel "1984"?', answers: ['George Orwell', 'J.K. Rowling', 'Ernest Hemingway'], correct: 0 }, { question: 'What is the largest mammal in the world?', answers: ['Elephant', 'Blue Whale', 'Giraffe'], correct: 1 }, { question: 'In which year did the Titanic sink?', answers: ['1912', '1923', '1905'], correct: 0 }, { question: 'Which planet is known as the Red Planet?', answers: ['Jupiter', 'Mars', 'Venus'], correct: 1 }, { question: 'Who painted the famous artwork "Starry Night"?', answers: ['Claude Monet', 'Vincent van Gogh', 'Pablo Picasso'], correct: 1 }, { question: 'What is the square root of 64?', answers: ['6', '8', '10'], correct: 1 }, { question: 'What is the main ingredient in guacamole?', answers: ['Tomato', 'Avocado', 'Onion'], correct: 1 }, { question: 'In which country would you find the Great Barrier Reef?', answers: ['Mexico', 'Australia', 'Brazil'], correct: 1 }, { question: 'The Pacific Garbage Patch is an accumulation of marine debris in which ocean?', answers: ['Atlantic Ocean', 'Indian Ocean', 'Pacific Ocean'], correct: 2 }, { question: 'What is the primary greenhouse gas responsible for climate change?', answers: ['Oxygen', 'Methane', 'Nitrogen'], correct: 1 }, { question: 'What is the chemical symbol for Gold?', answers: ['Au', 'Ag', 'Pt'], correct: 0 }, { question: 'How many Styrofoam cups do Americans throw away every year?', answers: ['15 trillion', '25 trillion', '35 trillion'], correct: 1 }, { question: 'Which renewable energy source generates electricity through the movement of wind?', answers: ['Solar', 'Wind', 'Hydro'], correct: 1 }, { question: 'What is the term for the gradual increase in Earth\'s average temperature?', answers: ['Global cooling', 'Global warming', 'Climate stability'], correct: 1 }, { question: 'Which international agreement aims to combat climate change by reducing greenhouse gas emissions?', answers: ['Kyoto Protocol', 'Paris Agreement', 'Copenhagen Accord'], correct: 1 }, { question: 'What is the major human activity contributing to deforestation and climate change?', answers: ['Fishing', 'Logging', 'Mining'], correct: 1 }, { question: 'Which gas is released when trees are cut down and burned?', answers: ['Oxygen', 'Carbon dioxide', 'Hydrogen'], correct: 1 }]; var SanityMeterBackground = Container.expand(function () { var self = Container.call(this); self.gameInstance = self.parent; LK.on('added', function () { self.gameInstance = self.parent; LK.on('added', function () { if (self.parent && self.parent.sanityIcons) { backgroundGraphics.height = 100 * self.parent.sanityIcons.length; } }); }); LK.on('added', function () { if (self.parent && self.parent.sanityIcons) { backgroundGraphics.height = 100 * self.parent.sanityIcons.length; } }); }); var SanityPoint = Container.expand(function () { var self = Container.call(this); var pointGraphics = self.createAsset('sanityIcon', 'Sanity Point Icon', 0, 0); self.addChild(pointGraphics); }); var AnswerButton = Container.expand(function (text, index, callback) { var self = Container.call(this); self.index = index; self.updateText = function (newText) { buttonText.setText(newText); }; var buttonText = new Text2(text, { size: 58.14, fill: '#000000', font: 'Times New Roman' }); buttonText.anchor.set(0.5, 0.5); var buttonGraphics = self.createAsset('button', 'Answer Button', 0.5, 0.5); self.addChild(buttonGraphics); self.addChild(buttonText); self.on('down', function () { callback(index); }); }); var Ghost = Container.expand(function () { var self = Container.call(this); var ghostGraphics = self.createAsset('ghost', 'Ghost character', .5, .5); self.spawnX = 2048 / 2; self.spawnY = 2732 - ghostGraphics.height * self.sizeMultiplier / 2 - 500; self.getGraphics = function () { return ghostGraphics; }; self.sizeMultiplier = 1; self.checkSize = function () { if (self.sizeMultiplier >= 7) { LK.showGameOver(); } }; self.move = function () {}; self.attack = function () {}; self.update = function () { self.sizeMultiplier += 0.005; ghostGraphics.scale.set(self.sizeMultiplier); self.checkSize(); }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5); self.move = function () {}; self.attack = function () {}; self.update = function () {}; }); var Puzzle = Container.expand(function () { var self = Container.call(this); self.updateQuestionAndAnswers = function () { self.answerButtons.forEach(function (button) { LK.gui.topCenter.removeChild(button); button.destroy(); }); self.answerButtons = []; LK.gui.topCenter.removeChild(self.questionText); this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)]; var buttonHeight = 100; var startY = self.initialButtonY || 2732 / 3 + 550 + self.questionText.height + 100 - 400; self.initialButtonY = startY; var positions = []; for (var i = 0; i < this.chosenQuestion.answers.length; i++) { positions.push(startY + i * (buttonHeight + 50)); } self.questionText = new Text2(this.chosenQuestion.question, { size: 68, fill: '#000000', wordWrap: true, wordWrapWidth: 600, font: 'Times New Roman' }); self.questionText.anchor.set(0.5, 0.5); self.questionText.x = 2048 / 4 - 800; self.questionText.y = 2732 / 3 + 550; LK.gui.topCenter.addChild(self.questionText); var buttonHeight = 100; var positions = []; for (var i = 0; i < this.chosenQuestion.answers.length; i++) { positions.push(startY + i * (buttonHeight + 50)); } for (var i = 0; i < this.chosenQuestion.answers.length; i++) { (function (index) { var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) { if (buttonIndex === self.chosenQuestion.correct) { LK.effects.flashScreen(0xffffff, 500); self.parent.ghost.sizeMultiplier = 1; self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier); self.parent.ghost.x = 2048 / 2; self.parent.ghost.y = 2732 - self.parent.ghost.getGraphics().height * self.parent.ghost.sizeMultiplier / 2 - 500; self.parent.score += 1; self.parent.wrongAnswers = 0; self.parent.updateQuestionAndAnswers(); } else { self.parent.wrongAnswers += 1; if (self.parent.wrongAnswers >= 3) { self.parent.removeSanityIcon(); self.parent.wrongAnswers = 0; } LK.effects.flashScreen(0xff0000, 500); } }); answerButton.x = 2048 / 2 - 700; answerButton.y = positions[index]; self.answerButtons.push(answerButton); LK.gui.topCenter.addChild(answerButton); })(i); } }; this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)]; self.answerButtons = []; for (var i = 0; i < this.chosenQuestion.answers.length; i++) { self.answerButtons.push(new AnswerButton('', i, function () {})); } self.questionText = new Text2(this.chosenQuestion.question, { size: 68, fill: '#000000', wordWrap: true, wordWrapWidth: 600, font: 'Times New Roman' }); self.questionText.anchor.set(0.5, 0.5); self.questionText.x = 2048 / 4 - 800; self.questionText.y = 2732 / 3 + 550; LK.gui.topCenter.addChild(self.questionText); var buttonHeight = 100; var startY = 2732 / 3 + 550 + self.questionText.height + 100 - 400; var positions = []; for (var i = 0; i < self.chosenQuestion.answers.length; i++) { positions.push(startY + i * (buttonHeight + 50)); } for (var i = 0; i < self.chosenQuestion.answers.length; i++) { (function (index) { var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) { if (index === self.chosenQuestion.correct) { LK.effects.flashScreen(0xffffff, 500); self.parent.ghost.sizeMultiplier = 1; self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier); self.parent.ghost.x = 2048 / 2; self.parent.ghost.y = 2732 - self.parent.ghost.getGraphics().height * self.parent.ghost.sizeMultiplier / 2 - 500; self.parent.score += 1; self.parent.wrongAnswers = 0; self.updateQuestionAndAnswers(); } else { LK.effects.flashScreen(0xff0000, 500); } }); answerButton.x = 2048 / 2 - 700; answerButton.y = positions[index]; self.answerButtons.push(answerButton); LK.gui.topCenter.addChild(answerButton); })(i); } self.puzzleGraphics = self.createAsset('puzzle', 'Puzzle element', .5, .5); self.solve = function (ghost) { self.removeChild(self.questionText); self.answerButtons.forEach(function (button) { button.destroy(); }); self.answerButtons = []; this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)]; self.questionText = new Text2(this.chosenQuestion.question, { size: 68, fill: '#000000', wordWrap: true, wordWrapWidth: 600, font: 'Times New Roman' }); self.questionText.anchor.set(0.5, 0.5); self.questionText.x = 2048 / 4 - 800; self.questionText.y = 2732 / 3 + 550; LK.gui.topCenter.addChild(self.questionText); var buttonHeight = 100; var startY = self.questionText.y + self.questionText.height - 350 - 400; var positions = []; for (var i = 0; i < self.chosenQuestion.answers.length; i++) { positions.push(startY + i * (buttonHeight + 50)); } for (var i = 0; i < self.chosenQuestion.answers.length; i++) { (function (index) { var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) { if (index === self.chosenQuestion.correct) { LK.effects.flashScreen(0xffffff, 500); self.parent.ghost.sizeMultiplier = 1; self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier); self.parent.ghost.x = 2048 / 2; } self.answerButtons.forEach(function (button) { button.destroy(); }); self.answerButtons = []; self.solve(ghost); }); answerButton.x = 2048 / 2 - 700; answerButton.y = positions[index]; self.answerButtons.push(answerButton); LK.gui.topCenter.addChild(answerButton); })(i); } }; self.update = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); self.removeSanityIcon = function () { if (self.sanityIcons.length > 0) { var iconToRemove = self.sanityIcons.pop(); iconToRemove.destroy(); } else { var sanityBreakGraphic = self.createAsset('sanityBreak', 'Sanity Break Graphic', 0.5, 0.5); sanityBreakGraphic.x = 2048 / 2; sanityBreakGraphic.y = 2732 / 2; LK.gui.topCenter.addChild(sanityBreakGraphic); LK.setTimeout(function () { sanityBreakGraphic.destroy(); }, 3000); } }; self.sanityIcons = []; var sanityMeterBackground = new SanityMeterBackground(); sanityMeterBackground.x = 10; sanityMeterBackground.y = 60; LK.gui.topLeft.addChild(sanityMeterBackground); for (var i = 0; i < 3; i++) { var point = new SanityPoint(); point.x = sanityMeterBackground.x + i * point.width + 10; point.y = sanityMeterBackground.y + (sanityMeterBackground.height - point.height) / 2 + 30; self.sanityIcons.push(point); LK.gui.topLeft.addChild(point); } LK.on('tick', function () { for (var i = 0; i < self.sanityIcons.length; i++) { self.sanityIcons[i].visible = i < self.sanityPoints; } }); self.score = 0; self.updateQuestionAndAnswers = function () { var puzzle = self.puzzles[0]; puzzle.updateQuestionAndAnswers(); }; var background = self.createAsset('background', 'Game background', 0, 0); background.width = 2048; background.height = 2732; self.addChildAt(background, 0); self.ghost = self.addChild(new Ghost()); self.ghost.x = 2048 / 2; self.ghost.y = 2732 / 4 + 500; hero = self.addChild(new Hero()); self.puzzles = []; var puzzle = self.addChild(new Puzzle()); puzzle.x = 2048 / 2; puzzle.y = 2732 - puzzle.height / 2 + 800; self.puzzles.push(puzzle); var wrongAnswers = 0; self.wrongAnswers = wrongAnswers; var sanityPoints = 3; self.sanityPoints = sanityPoints; var isGameOver = false; var hero; LK.on('tick', function () { hero.update(); self.ghost.update(); self.puzzles.forEach(function (puzzle) { puzzle.update(); if (puzzle.isSolved) { puzzle.solve(ghost); } }); if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
var triviaQuestions = [{
question: 'What is the capital city of Australia?',
answers: ['Sydney', 'Canberra', 'Melbourne'],
correct: 1
}, {
question: 'Who wrote the novel "1984"?',
answers: ['George Orwell', 'J.K. Rowling', 'Ernest Hemingway'],
correct: 0
}, {
question: 'What is the largest mammal in the world?',
answers: ['Elephant', 'Blue Whale', 'Giraffe'],
correct: 1
}, {
question: 'In which year did the Titanic sink?',
answers: ['1912', '1923', '1905'],
correct: 0
}, {
question: 'Which planet is known as the Red Planet?',
answers: ['Jupiter', 'Mars', 'Venus'],
correct: 1
}, {
question: 'Who painted the famous artwork "Starry Night"?',
answers: ['Claude Monet', 'Vincent van Gogh', 'Pablo Picasso'],
correct: 1
}, {
question: 'What is the square root of 64?',
answers: ['6', '8', '10'],
correct: 1
}, {
question: 'What is the main ingredient in guacamole?',
answers: ['Tomato', 'Avocado', 'Onion'],
correct: 1
}, {
question: 'In which country would you find the Great Barrier Reef?',
answers: ['Mexico', 'Australia', 'Brazil'],
correct: 1
}, {
question: 'The Pacific Garbage Patch is an accumulation of marine debris in which ocean?',
answers: ['Atlantic Ocean', 'Indian Ocean', 'Pacific Ocean'],
correct: 2
}, {
question: 'What is the primary greenhouse gas responsible for climate change?',
answers: ['Oxygen', 'Methane', 'Nitrogen'],
correct: 1
}, {
question: 'What is the chemical symbol for Gold?',
answers: ['Au', 'Ag', 'Pt'],
correct: 0
}, {
question: 'How many Styrofoam cups do Americans throw away every year?',
answers: ['15 trillion', '25 trillion', '35 trillion'],
correct: 1
}, {
question: 'Which renewable energy source generates electricity through the movement of wind?',
answers: ['Solar', 'Wind', 'Hydro'],
correct: 1
}, {
question: 'What is the term for the gradual increase in Earth\'s average temperature?',
answers: ['Global cooling', 'Global warming', 'Climate stability'],
correct: 1
}, {
question: 'Which international agreement aims to combat climate change by reducing greenhouse gas emissions?',
answers: ['Kyoto Protocol', 'Paris Agreement', 'Copenhagen Accord'],
correct: 1
}, {
question: 'What is the major human activity contributing to deforestation and climate change?',
answers: ['Fishing', 'Logging', 'Mining'],
correct: 1
}, {
question: 'Which gas is released when trees are cut down and burned?',
answers: ['Oxygen', 'Carbon dioxide', 'Hydrogen'],
correct: 1
}];
var SanityMeterBackground = Container.expand(function () {
var self = Container.call(this);
self.gameInstance = self.parent;
LK.on('added', function () {
self.gameInstance = self.parent;
LK.on('added', function () {
if (self.parent && self.parent.sanityIcons) {
backgroundGraphics.height = 100 * self.parent.sanityIcons.length;
}
});
});
LK.on('added', function () {
if (self.parent && self.parent.sanityIcons) {
backgroundGraphics.height = 100 * self.parent.sanityIcons.length;
}
});
});
var SanityPoint = Container.expand(function () {
var self = Container.call(this);
var pointGraphics = self.createAsset('sanityIcon', 'Sanity Point Icon', 0, 0);
self.addChild(pointGraphics);
});
var AnswerButton = Container.expand(function (text, index, callback) {
var self = Container.call(this);
self.index = index;
self.updateText = function (newText) {
buttonText.setText(newText);
};
var buttonText = new Text2(text, {
size: 58.14,
fill: '#000000',
font: 'Times New Roman'
});
buttonText.anchor.set(0.5, 0.5);
var buttonGraphics = self.createAsset('button', 'Answer Button', 0.5, 0.5);
self.addChild(buttonGraphics);
self.addChild(buttonText);
self.on('down', function () {
callback(index);
});
});
var Ghost = Container.expand(function () {
var self = Container.call(this);
var ghostGraphics = self.createAsset('ghost', 'Ghost character', .5, .5);
self.spawnX = 2048 / 2;
self.spawnY = 2732 - ghostGraphics.height * self.sizeMultiplier / 2 - 500;
self.getGraphics = function () {
return ghostGraphics;
};
self.sizeMultiplier = 1;
self.checkSize = function () {
if (self.sizeMultiplier >= 7) {
LK.showGameOver();
}
};
self.move = function () {};
self.attack = function () {};
self.update = function () {
self.sizeMultiplier += 0.005;
ghostGraphics.scale.set(self.sizeMultiplier);
self.checkSize();
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5);
self.move = function () {};
self.attack = function () {};
self.update = function () {};
});
var Puzzle = Container.expand(function () {
var self = Container.call(this);
self.updateQuestionAndAnswers = function () {
self.answerButtons.forEach(function (button) {
LK.gui.topCenter.removeChild(button);
button.destroy();
});
self.answerButtons = [];
LK.gui.topCenter.removeChild(self.questionText);
this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)];
var buttonHeight = 100;
var startY = self.initialButtonY || 2732 / 3 + 550 + self.questionText.height + 100 - 400;
self.initialButtonY = startY;
var positions = [];
for (var i = 0; i < this.chosenQuestion.answers.length; i++) {
positions.push(startY + i * (buttonHeight + 50));
}
self.questionText = new Text2(this.chosenQuestion.question, {
size: 68,
fill: '#000000',
wordWrap: true,
wordWrapWidth: 600,
font: 'Times New Roman'
});
self.questionText.anchor.set(0.5, 0.5);
self.questionText.x = 2048 / 4 - 800;
self.questionText.y = 2732 / 3 + 550;
LK.gui.topCenter.addChild(self.questionText);
var buttonHeight = 100;
var positions = [];
for (var i = 0; i < this.chosenQuestion.answers.length; i++) {
positions.push(startY + i * (buttonHeight + 50));
}
for (var i = 0; i < this.chosenQuestion.answers.length; i++) {
(function (index) {
var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) {
if (buttonIndex === self.chosenQuestion.correct) {
LK.effects.flashScreen(0xffffff, 500);
self.parent.ghost.sizeMultiplier = 1;
self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier);
self.parent.ghost.x = 2048 / 2;
self.parent.ghost.y = 2732 - self.parent.ghost.getGraphics().height * self.parent.ghost.sizeMultiplier / 2 - 500;
self.parent.score += 1;
self.parent.wrongAnswers = 0;
self.parent.updateQuestionAndAnswers();
} else {
self.parent.wrongAnswers += 1;
if (self.parent.wrongAnswers >= 3) {
self.parent.removeSanityIcon();
self.parent.wrongAnswers = 0;
}
LK.effects.flashScreen(0xff0000, 500);
}
});
answerButton.x = 2048 / 2 - 700;
answerButton.y = positions[index];
self.answerButtons.push(answerButton);
LK.gui.topCenter.addChild(answerButton);
})(i);
}
};
this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)];
self.answerButtons = [];
for (var i = 0; i < this.chosenQuestion.answers.length; i++) {
self.answerButtons.push(new AnswerButton('', i, function () {}));
}
self.questionText = new Text2(this.chosenQuestion.question, {
size: 68,
fill: '#000000',
wordWrap: true,
wordWrapWidth: 600,
font: 'Times New Roman'
});
self.questionText.anchor.set(0.5, 0.5);
self.questionText.x = 2048 / 4 - 800;
self.questionText.y = 2732 / 3 + 550;
LK.gui.topCenter.addChild(self.questionText);
var buttonHeight = 100;
var startY = 2732 / 3 + 550 + self.questionText.height + 100 - 400;
var positions = [];
for (var i = 0; i < self.chosenQuestion.answers.length; i++) {
positions.push(startY + i * (buttonHeight + 50));
}
for (var i = 0; i < self.chosenQuestion.answers.length; i++) {
(function (index) {
var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) {
if (index === self.chosenQuestion.correct) {
LK.effects.flashScreen(0xffffff, 500);
self.parent.ghost.sizeMultiplier = 1;
self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier);
self.parent.ghost.x = 2048 / 2;
self.parent.ghost.y = 2732 - self.parent.ghost.getGraphics().height * self.parent.ghost.sizeMultiplier / 2 - 500;
self.parent.score += 1;
self.parent.wrongAnswers = 0;
self.updateQuestionAndAnswers();
} else {
LK.effects.flashScreen(0xff0000, 500);
}
});
answerButton.x = 2048 / 2 - 700;
answerButton.y = positions[index];
self.answerButtons.push(answerButton);
LK.gui.topCenter.addChild(answerButton);
})(i);
}
self.puzzleGraphics = self.createAsset('puzzle', 'Puzzle element', .5, .5);
self.solve = function (ghost) {
self.removeChild(self.questionText);
self.answerButtons.forEach(function (button) {
button.destroy();
});
self.answerButtons = [];
this.chosenQuestion = triviaQuestions[Math.floor(Math.random() * triviaQuestions.length)];
self.questionText = new Text2(this.chosenQuestion.question, {
size: 68,
fill: '#000000',
wordWrap: true,
wordWrapWidth: 600,
font: 'Times New Roman'
});
self.questionText.anchor.set(0.5, 0.5);
self.questionText.x = 2048 / 4 - 800;
self.questionText.y = 2732 / 3 + 550;
LK.gui.topCenter.addChild(self.questionText);
var buttonHeight = 100;
var startY = self.questionText.y + self.questionText.height - 350 - 400;
var positions = [];
for (var i = 0; i < self.chosenQuestion.answers.length; i++) {
positions.push(startY + i * (buttonHeight + 50));
}
for (var i = 0; i < self.chosenQuestion.answers.length; i++) {
(function (index) {
var answerButton = new AnswerButton(self.chosenQuestion.answers[index], index, function (buttonIndex) {
if (index === self.chosenQuestion.correct) {
LK.effects.flashScreen(0xffffff, 500);
self.parent.ghost.sizeMultiplier = 1;
self.parent.ghost.getGraphics().scale.set(self.parent.ghost.sizeMultiplier);
self.parent.ghost.x = 2048 / 2;
}
self.answerButtons.forEach(function (button) {
button.destroy();
});
self.answerButtons = [];
self.solve(ghost);
});
answerButton.x = 2048 / 2 - 700;
answerButton.y = positions[index];
self.answerButtons.push(answerButton);
LK.gui.topCenter.addChild(answerButton);
})(i);
}
};
self.update = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.removeSanityIcon = function () {
if (self.sanityIcons.length > 0) {
var iconToRemove = self.sanityIcons.pop();
iconToRemove.destroy();
} else {
var sanityBreakGraphic = self.createAsset('sanityBreak', 'Sanity Break Graphic', 0.5, 0.5);
sanityBreakGraphic.x = 2048 / 2;
sanityBreakGraphic.y = 2732 / 2;
LK.gui.topCenter.addChild(sanityBreakGraphic);
LK.setTimeout(function () {
sanityBreakGraphic.destroy();
}, 3000);
}
};
self.sanityIcons = [];
var sanityMeterBackground = new SanityMeterBackground();
sanityMeterBackground.x = 10;
sanityMeterBackground.y = 60;
LK.gui.topLeft.addChild(sanityMeterBackground);
for (var i = 0; i < 3; i++) {
var point = new SanityPoint();
point.x = sanityMeterBackground.x + i * point.width + 10;
point.y = sanityMeterBackground.y + (sanityMeterBackground.height - point.height) / 2 + 30;
self.sanityIcons.push(point);
LK.gui.topLeft.addChild(point);
}
LK.on('tick', function () {
for (var i = 0; i < self.sanityIcons.length; i++) {
self.sanityIcons[i].visible = i < self.sanityPoints;
}
});
self.score = 0;
self.updateQuestionAndAnswers = function () {
var puzzle = self.puzzles[0];
puzzle.updateQuestionAndAnswers();
};
var background = self.createAsset('background', 'Game background', 0, 0);
background.width = 2048;
background.height = 2732;
self.addChildAt(background, 0);
self.ghost = self.addChild(new Ghost());
self.ghost.x = 2048 / 2;
self.ghost.y = 2732 / 4 + 500;
hero = self.addChild(new Hero());
self.puzzles = [];
var puzzle = self.addChild(new Puzzle());
puzzle.x = 2048 / 2;
puzzle.y = 2732 - puzzle.height / 2 + 800;
self.puzzles.push(puzzle);
var wrongAnswers = 0;
self.wrongAnswers = wrongAnswers;
var sanityPoints = 3;
self.sanityPoints = sanityPoints;
var isGameOver = false;
var hero;
LK.on('tick', function () {
hero.update();
self.ghost.update();
self.puzzles.forEach(function (puzzle) {
puzzle.update();
if (puzzle.isSolved) {
puzzle.solve(ghost);
}
});
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
});
});
Book pages, blank, open book, no text, front facing Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Scrap of paper, horizontal, blank, torn edge Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rfireball blue magic Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Ghost girl, scary, horror movie, full body, Japanese ghost, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Spooky abandoned house interior Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White rectangle, game UI, blank, flat 2D Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Horror game UI sign, "SANITY BREAK" Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Fear icon, horror game Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.