/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ // QuestionButton: A tappable answer button var QuestionButton = Container.expand(function () { var self = Container.call(this); // Button background var bg = self.attachAsset('buttonBg', { width: 1400, height: 180, color: 0x222222, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Button text var txt = new Text2('', { size: 70, fill: 0xFFFFFF }); txt.anchor.set(0.5, 0.5); self.addChild(txt); self.setText = function (t) { txt.setText(t); }; self.setWidth = function (w) { bg.width = w; }; self.setY = function (y) { self.y = y; }; self.setEnabled = function (enabled) { self.interactive = enabled; bg.alpha = enabled ? 1 : 0.5; }; self.flash = function (color, duration) { tween(bg, { color: color }, { duration: duration / 2, easing: tween.easeIn, onFinish: function onFinish() { tween(bg, { color: 0x222222 }, { duration: duration / 2, easing: tween.easeOut }); } }); }; self.down = function (x, y, obj) { if (self.interactive && typeof self.onSelect === 'function') { self.onSelect(self.buttonIndex); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // No custom assets needed; LK will auto-create Text2 and shape assets as used below // Meme questions: Each has {q: question, a: [answers], c: correctIndex} var memeQuestions = [{ q: "What animal is famous for 'Doge' meme?", a: ["Shiba Inu", "Corgi", "Pug", "Bulldog"], c: 0 }, { q: "Which phrase is associated with 'Success Kid'?", a: ["Nailed it!", "I did it!", "Yes!", "Win!"], c: 3 }, { q: "What color is the background of 'Distracted Boyfriend' meme?", a: ["Blue", "City street", "Green", "Classroom"], c: 1 }, { q: "What is the catchphrase of 'Grumpy Cat'?", a: ["Nope.", "I had fun once, it was awful.", "Meh.", "Whatever."], c: 1 }, { q: "Which meme features a frog on a unicycle?", a: ["Dat Boi", "Pepe", "Kermit", "Froggo"], c: 0 }, { q: "What is 'Pepe the Frog' usually expressing?", a: ["Happiness", "Sadness", "Anger", "Excitement"], c: 1 }, { q: "What is the name of the meme with a dog in a burning room saying 'This is fine'?", a: ["Disaster Dog", "This is Fine", "Crisis Canine", "Calm Dog"], c: 1 }, { q: "Which meme is known for 'Hide the Pain'?", a: ["Harold", "Steve", "Bob", "Larry"], c: 0 }, { q: "What is the punchline of 'Woman Yelling at Cat' meme?", a: ["Why are you yelling?", "No!", "Confused Cat", "Table Cat"], c: 3 }, { q: "What is the name of the meme with a guy blinking in disbelief?", a: ["Blinking Guy", "Surprised Pikachu", "Confused Nick Young", "Roll Safe"], c: 0 }, { q: "Which meme is associated with 'Is this a pigeon?'", a: ["Anime Guy", "Butterfly Guy", "Pigeon Guy", "Confused Guy"], c: 1 }, { q: "What is the name of the meme with a man tapping his head?", a: ["Roll Safe", "Smart Guy", "Think About It", "Head Tap"], c: 0 }, { q: "Which meme is known for 'Expanding Brain'?", a: ["Galaxy Brain", "Big Brain", "Brainstorm", "Brain Blast"], c: 0 }, { q: "What is the name of the meme with a surprised yellow mouse?", a: ["Shocked Pikachu", "Surprised Pikachu", "Astonished Pikachu", "Confused Pikachu"], c: 1 }, { q: "What is the reward for answering all 15 questions?", a: ["A real million dollars", "A virtual million dollars", "A meme trophy", "A pizza"], c: 1 }]; // Shuffle questions for each game function shuffleQuestions(arr) { var out = []; var used = []; for (var i = 0; i < arr.length; i++) used[i] = false; for (var j = 0; j < arr.length; j++) { var idx; do { idx = Math.floor(Math.random() * arr.length); } while (used[idx]); used[idx] = true; out.push(arr[idx]); } return out; } // State var currentQuestionIndex = 0; var currentQuestions = []; var bestStreak = storage.bestStreak || 0; var streak = 0; var buttons = []; var questionText = null; var streakText = null; var bestText = null; var millionText = null; var canAnswer = true; // Layout var questionY = 420; var buttonStartY = 900; var buttonSpacing = 260; // GUI: Streak and best streak streakText = new Text2('Streak: 0', { size: 70, fill: "#fff" }); streakText.anchor.set(0, 0); LK.gui.top.addChild(streakText); bestText = new Text2('Best: ' + bestStreak, { size: 70, fill: "#fff" }); bestText.anchor.set(1, 0); LK.gui.topRight.addChild(bestText); // Million text (shows on win) millionText = new Text2('YOU WON $1,000,000!', { size: 120, fill: 0xFFE600 }); millionText.anchor.set(0.5, 0.5); millionText.visible = false; LK.gui.center.addChild(millionText); // Question text questionText = new Text2('', { size: 100, fill: "#fff" }); questionText.anchor.set(0.5, 0); questionText.x = 2048 / 2; questionText.y = questionY; game.addChild(questionText); // Create answer buttons for (var i = 0; i < 4; i++) { var btn = new QuestionButton(); btn.x = 2048 / 2; btn.y = buttonStartY + i * buttonSpacing; btn.setWidth(1400); btn.setEnabled(false); btn.buttonIndex = i; btn.onSelect = function (idx) { if (!canAnswer) return; handleAnswer(idx); }; game.addChild(btn); buttons.push(btn); } // Start a new game function startGame() { currentQuestions = shuffleQuestions(memeQuestions); currentQuestionIndex = 0; streak = 0; updateStreak(); millionText.visible = false; showQuestion(); } // Show current question function showQuestion() { canAnswer = true; var q = currentQuestions[currentQuestionIndex]; questionText.setText("Q" + (currentQuestionIndex + 1) + ": " + q.q); for (var i = 0; i < 4; i++) { buttons[i].setText(q.a[i]); buttons[i].setEnabled(true); } } // Handle answer selection function handleAnswer(idx) { canAnswer = false; var q = currentQuestions[currentQuestionIndex]; var correct = idx === q.c; // Disable all buttons for (var i = 0; i < 4; i++) { buttons[i].setEnabled(false); } if (correct) { buttons[idx].flash(0x4caf50, 400); streak++; updateStreak(); // Next question or win LK.setTimeout(function () { if (currentQuestionIndex === 14) { // Win millionText.visible = true; LK.effects.flashScreen(0xffe600, 800); if (streak > bestStreak) { bestStreak = streak; storage.bestStreak = bestStreak; bestText.setText('Best: ' + bestStreak); } LK.showYouWin(); } else { currentQuestionIndex++; showQuestion(); } }, 600); } else { buttons[idx].flash(0xff4444, 400); buttons[q.c].flash(0x4caf50, 400); LK.effects.flashScreen(0xff0000, 800); LK.setTimeout(function () { if (streak > bestStreak) { bestStreak = streak; storage.bestStreak = bestStreak; bestText.setText('Best: ' + bestStreak); } LK.showGameOver(); }, 900); } } // Update streak display function updateStreak() { streakText.setText('Streak: ' + streak); } // On game reset, start new game startGame(); // On game over or win, LK will reset the game and re-run this file, so no need to handle reset logic here.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
// QuestionButton: A tappable answer button
var QuestionButton = Container.expand(function () {
var self = Container.call(this);
// Button background
var bg = self.attachAsset('buttonBg', {
width: 1400,
height: 180,
color: 0x222222,
shape: 'box',
anchorX: 0.5,
anchorY: 0.5
});
// Button text
var txt = new Text2('', {
size: 70,
fill: 0xFFFFFF
});
txt.anchor.set(0.5, 0.5);
self.addChild(txt);
self.setText = function (t) {
txt.setText(t);
};
self.setWidth = function (w) {
bg.width = w;
};
self.setY = function (y) {
self.y = y;
};
self.setEnabled = function (enabled) {
self.interactive = enabled;
bg.alpha = enabled ? 1 : 0.5;
};
self.flash = function (color, duration) {
tween(bg, {
color: color
}, {
duration: duration / 2,
easing: tween.easeIn,
onFinish: function onFinish() {
tween(bg, {
color: 0x222222
}, {
duration: duration / 2,
easing: tween.easeOut
});
}
});
};
self.down = function (x, y, obj) {
if (self.interactive && typeof self.onSelect === 'function') {
self.onSelect(self.buttonIndex);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181818
});
/****
* Game Code
****/
// No custom assets needed; LK will auto-create Text2 and shape assets as used below
// Meme questions: Each has {q: question, a: [answers], c: correctIndex}
var memeQuestions = [{
q: "What animal is famous for 'Doge' meme?",
a: ["Shiba Inu", "Corgi", "Pug", "Bulldog"],
c: 0
}, {
q: "Which phrase is associated with 'Success Kid'?",
a: ["Nailed it!", "I did it!", "Yes!", "Win!"],
c: 3
}, {
q: "What color is the background of 'Distracted Boyfriend' meme?",
a: ["Blue", "City street", "Green", "Classroom"],
c: 1
}, {
q: "What is the catchphrase of 'Grumpy Cat'?",
a: ["Nope.", "I had fun once, it was awful.", "Meh.", "Whatever."],
c: 1
}, {
q: "Which meme features a frog on a unicycle?",
a: ["Dat Boi", "Pepe", "Kermit", "Froggo"],
c: 0
}, {
q: "What is 'Pepe the Frog' usually expressing?",
a: ["Happiness", "Sadness", "Anger", "Excitement"],
c: 1
}, {
q: "What is the name of the meme with a dog in a burning room saying 'This is fine'?",
a: ["Disaster Dog", "This is Fine", "Crisis Canine", "Calm Dog"],
c: 1
}, {
q: "Which meme is known for 'Hide the Pain'?",
a: ["Harold", "Steve", "Bob", "Larry"],
c: 0
}, {
q: "What is the punchline of 'Woman Yelling at Cat' meme?",
a: ["Why are you yelling?", "No!", "Confused Cat", "Table Cat"],
c: 3
}, {
q: "What is the name of the meme with a guy blinking in disbelief?",
a: ["Blinking Guy", "Surprised Pikachu", "Confused Nick Young", "Roll Safe"],
c: 0
}, {
q: "Which meme is associated with 'Is this a pigeon?'",
a: ["Anime Guy", "Butterfly Guy", "Pigeon Guy", "Confused Guy"],
c: 1
}, {
q: "What is the name of the meme with a man tapping his head?",
a: ["Roll Safe", "Smart Guy", "Think About It", "Head Tap"],
c: 0
}, {
q: "Which meme is known for 'Expanding Brain'?",
a: ["Galaxy Brain", "Big Brain", "Brainstorm", "Brain Blast"],
c: 0
}, {
q: "What is the name of the meme with a surprised yellow mouse?",
a: ["Shocked Pikachu", "Surprised Pikachu", "Astonished Pikachu", "Confused Pikachu"],
c: 1
}, {
q: "What is the reward for answering all 15 questions?",
a: ["A real million dollars", "A virtual million dollars", "A meme trophy", "A pizza"],
c: 1
}];
// Shuffle questions for each game
function shuffleQuestions(arr) {
var out = [];
var used = [];
for (var i = 0; i < arr.length; i++) used[i] = false;
for (var j = 0; j < arr.length; j++) {
var idx;
do {
idx = Math.floor(Math.random() * arr.length);
} while (used[idx]);
used[idx] = true;
out.push(arr[idx]);
}
return out;
}
// State
var currentQuestionIndex = 0;
var currentQuestions = [];
var bestStreak = storage.bestStreak || 0;
var streak = 0;
var buttons = [];
var questionText = null;
var streakText = null;
var bestText = null;
var millionText = null;
var canAnswer = true;
// Layout
var questionY = 420;
var buttonStartY = 900;
var buttonSpacing = 260;
// GUI: Streak and best streak
streakText = new Text2('Streak: 0', {
size: 70,
fill: "#fff"
});
streakText.anchor.set(0, 0);
LK.gui.top.addChild(streakText);
bestText = new Text2('Best: ' + bestStreak, {
size: 70,
fill: "#fff"
});
bestText.anchor.set(1, 0);
LK.gui.topRight.addChild(bestText);
// Million text (shows on win)
millionText = new Text2('YOU WON $1,000,000!', {
size: 120,
fill: 0xFFE600
});
millionText.anchor.set(0.5, 0.5);
millionText.visible = false;
LK.gui.center.addChild(millionText);
// Question text
questionText = new Text2('', {
size: 100,
fill: "#fff"
});
questionText.anchor.set(0.5, 0);
questionText.x = 2048 / 2;
questionText.y = questionY;
game.addChild(questionText);
// Create answer buttons
for (var i = 0; i < 4; i++) {
var btn = new QuestionButton();
btn.x = 2048 / 2;
btn.y = buttonStartY + i * buttonSpacing;
btn.setWidth(1400);
btn.setEnabled(false);
btn.buttonIndex = i;
btn.onSelect = function (idx) {
if (!canAnswer) return;
handleAnswer(idx);
};
game.addChild(btn);
buttons.push(btn);
}
// Start a new game
function startGame() {
currentQuestions = shuffleQuestions(memeQuestions);
currentQuestionIndex = 0;
streak = 0;
updateStreak();
millionText.visible = false;
showQuestion();
}
// Show current question
function showQuestion() {
canAnswer = true;
var q = currentQuestions[currentQuestionIndex];
questionText.setText("Q" + (currentQuestionIndex + 1) + ": " + q.q);
for (var i = 0; i < 4; i++) {
buttons[i].setText(q.a[i]);
buttons[i].setEnabled(true);
}
}
// Handle answer selection
function handleAnswer(idx) {
canAnswer = false;
var q = currentQuestions[currentQuestionIndex];
var correct = idx === q.c;
// Disable all buttons
for (var i = 0; i < 4; i++) {
buttons[i].setEnabled(false);
}
if (correct) {
buttons[idx].flash(0x4caf50, 400);
streak++;
updateStreak();
// Next question or win
LK.setTimeout(function () {
if (currentQuestionIndex === 14) {
// Win
millionText.visible = true;
LK.effects.flashScreen(0xffe600, 800);
if (streak > bestStreak) {
bestStreak = streak;
storage.bestStreak = bestStreak;
bestText.setText('Best: ' + bestStreak);
}
LK.showYouWin();
} else {
currentQuestionIndex++;
showQuestion();
}
}, 600);
} else {
buttons[idx].flash(0xff4444, 400);
buttons[q.c].flash(0x4caf50, 400);
LK.effects.flashScreen(0xff0000, 800);
LK.setTimeout(function () {
if (streak > bestStreak) {
bestStreak = streak;
storage.bestStreak = bestStreak;
bestText.setText('Best: ' + bestStreak);
}
LK.showGameOver();
}, 900);
}
}
// Update streak display
function updateStreak() {
streakText.setText('Streak: ' + streak);
}
// On game reset, start new game
startGame();
// On game over or win, LK will reset the game and re-run this file, so no need to handle reset logic here.