User prompt
Rire Express: Jokes & Riddles
Initial prompt
fait ce jeu : # Prompt pour recréer le jeu "Rire Express" Créez une application interactive de blagues et devinettes appelée "Rire Express" qui offre une expérience amusante et engageante. Voici les spécifications détaillées : ## Concept général Développez un jeu qui permet aux utilisateurs de découvrir des blagues et des devinettes organisées par catégories. Les utilisateurs peuvent naviguer entre différentes catégories, sauvegarder leurs favoris, et gagner des points en découvrant de nouveaux contenus. ## Interface principale - Titre "Rire Express" en haut de l'écran - Sous-titre descriptif : "Découvrez des blagues et devinettes - gagnez des points et sauvegardez vos favoris!" - Deux modes principaux : "JOKES" et "RIDDLES" avec des boutons interactifs pour basculer entre eux - Un indicateur de points avec une étoile dans le coin supérieur droit - Un bouton de favoris avec un cœur dans le coin supérieur gauche ## Navigation et contenu - Système de catégories dynamique qui change en fonction du mode sélectionné : * Pour les blagues : "All", "Wordplay", "Short Jokes", "Funny Stories" * Pour les devinettes : "All", "Classic Riddles", "Brain Teasers", "Word Riddles" - Les contenus sont affichés sur des cartes visuellement attrayantes - Chaque carte contient : * Le texte de la blague ou de la devinette * Une étiquette de catégorie * Un bouton "Suivant" pour passer au contenu suivant * Un bouton "Favori" pour sauvegarder le contenu * Un bouton "Audio" (visible uniquement pour les devinettes) qui simule la lecture du contenu à haute voix ## Fonctionnalités interactives - Animation lors de la navigation entre les catégories - Effet visuel lorsqu'un bouton est pressé (mise à l'échelle) - Les cartes s'adaptent automatiquement au contenu (taille de texte variable selon la longueur) - Un système de points qui récompense la découverte : +5 points pour chaque nouveau contenu découvert - Gestion des favoris avec un compteur qui s'actualise - Vue dédiée pour consulter tous les favoris sauvegardés ## Base de données de contenu - Au moins 20 blagues réparties en 3 catégories - Au moins 15 devinettes réparties en 3 catégories - Chaque élément a un identifiant unique, un texte, et une catégorie - Les devinettes ont également une réponse associée ## Stockage et persistance - Les points gagnés sont sauvegardés entre les sessions - Les favoris sont conservés pour permettre à l'utilisateur de retrouver son contenu préféré - Le système garde une trace des contenus déjà vus pour ne pas attribuer de points en double ## Interface sonore - Effets sonores lors des clics sur les boutons - Simulation d'une fonctionnalité de lecture audio pour les devinettes (affichage d'un message temporaire) ## Design visuel - Palette de couleurs attrayante avec fond clair (0xF5F5F5) - Cartes personnalisées pour les blagues et devinettes - Typographie optimisée pour la lisibilité avec différentes tailles selon le contenu - Boutons avec effets visuels d'interaction - Transitions fluides entre les différentes vues Ce jeu est conçu pour être accessible, engageant et offrir une expérience utilisateur fluide sur appareils mobiles.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { points: 0, favorites: {}, viewedContent: {}, mode: "jokes" }); /**** * Classes ****/ var CategoryButton = Container.expand(function (category, index) { var self = Container.call(this); self.category = category; var button = self.attachAsset('categoryButton', { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2(category, { size: 50, fill: 0x000000 }); label.anchor.set(0.5, 0.5); self.addChild(label); self.setSelected = function (selected) { button.tint = selected ? 0x2E5B9E : 0x4A90E2; }; self.down = function () { button.tint = 0x2E5B9E; LK.getSound('point').play(); }; self.up = function () { if (typeof self.onSelect === 'function') { self.onSelect(self.category); } }; return self; }); var ContentCard = Container.expand(function (content) { var self = Container.call(this); self.content = content; var card = self.attachAsset('card', { anchorX: 0.5, anchorY: 0.5 }); card.alpha = 0.9; var category = new Text2(content.category, { size: 50, fill: 0x000000 }); category.anchor.set(0.5, 0); category.y = -400; self.addChild(category); // Function to add line breaks every 5 words function addLineBreaksEvery5Words(text) { var words = text.split(' '); var result = ''; for (var i = 0; i < words.length; i++) { result += words[i]; if ((i + 1) % 5 === 0 && i < words.length - 1) { result += '\n'; } else if (i < words.length - 1) { result += ' '; } } return result; } // Apply line breaks to content text var formattedText = addLineBreaksEvery5Words(content.text); var contentText = new Text2(formattedText, { size: 90, fill: 0x000000 }); contentText.anchor.set(0.5, 0.5); contentText.y = 0; // Handle long text by adjusting font size if (content.text.length > 150) { contentText.setText(contentText.text, { size: 70, fill: 0x000000 }); } if (content.text.length > 300) { contentText.setText(contentText.text, { size: 60, fill: 0x000000 }); } self.addChild(contentText); var punchline = null; if (content.punchline) { punchline = new Text2("Tap to reveal punchline", { size: 60, fill: 0x000000 }); punchline.anchor.set(0.5, 0); punchline.y = 150; self.addChild(punchline); } // Star asset removed self.setFavorite = function (isFavorite) { // Favorites functionality removed }; self.revealPunchline = function () { if (content.punchline && punchline) { // Format punchline with line breaks every 5 words var formattedPunchline = "**" + addLineBreaksEvery5Words(content.punchline) + "**"; // Set the punchline text with dark color and proper size punchline.setText(formattedPunchline, { fill: 0x000000, size: 80 }); // Mark as viewed in storage var contentKey = content.id || content.text.substring(0, 20) + content.category; if (!storage.viewedContent[contentKey]) { storage.viewedContent[contentKey] = true; storage.points += 1; if (typeof self.onPointEarned === 'function') { self.onPointEarned(); } LK.getSound('point').play(); } } }; // Favorites functionality removed // Initialize favorite state var contentKey = content.id || content.text.substring(0, 20) + content.category; self.setFavorite(storage.favorites[contentKey] || false); self.down = function (x, y, obj) { var localPos = self.toLocal({ x: x, y: y }); // Only handle punchline reveal now if (content.punchline && punchline) { self.revealPunchline(); } }; return self; }); var ToggleSwitch = Container.expand(function (leftText, rightText) { var self = Container.call(this); var background = self.attachAsset('toggleBackground', { anchorX: 0.5, anchorY: 0.5 }); var button = self.attachAsset('toggleButton', { anchorX: 0.5, anchorY: 0.5, x: -75 }); var leftLabel = new Text2(leftText, { size: 40, fill: 0x000000 }); leftLabel.anchor.set(0.5, 0.5); leftLabel.x = -75; leftLabel.y = -70; self.addChild(leftLabel); var rightLabel = new Text2(rightText, { size: 40, fill: 0x000000 }); rightLabel.anchor.set(0.5, 0.5); rightLabel.x = 75; rightLabel.y = -70; self.addChild(rightLabel); self.state = false; self.setState = function (state) { self.state = state; var targetX = state ? 75 : -75; tween(button, { x: targetX }, { duration: 300, easing: tween.easeOut }); }; self.toggle = function () { self.setState(!self.state); if (typeof self.onToggle === 'function') { self.onToggle(self.state); } }; self.down = function () { LK.getSound('point').play(); self.toggle(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xF0F0F0 }); /**** * Game Code ****/ // Favorite sound removed // Star asset removed // Constants and game data var CATEGORIES = { jokes: ['Wordplay', 'Short Jokes', 'Funny Stories', 'Dad Jokes'], riddles: ['Classic Riddles', 'Brain Teasers', 'Word Riddles'] }; var CONTENT = { jokes: { 'Wordplay': [{ text: "Why don't scientists trust atoms?", punchline: "Because they make up everything!", id: "j1" }, { text: "Did you hear about the mathematician who's afraid of negative numbers?", punchline: "He'll stop at nothing to avoid them!", id: "j2" }, { text: "I told my wife she was drawing her eyebrows too high.", punchline: "She looked surprised!", id: "j3" }, { text: "What do you call a deer with no eyes?", punchline: "No idea (no eye deer)!", id: "j10" }, { text: "What's the best thing about Switzerland?", punchline: "I don't know, but the flag is a big plus!", id: "j11" }, { text: "I'm reading a book about anti-gravity.", punchline: "It's impossible to put down!", id: "j12" }, { text: "I used to be a baker, but I couldn't make enough dough.", punchline: "Now I'm just loafing around.", id: "j13" }, { text: "What's orange and sounds like a parrot?", punchline: "A carrot!", id: "j14" }, { text: "Why can't you hear a pterodactyl in the bathroom?", punchline: "Because the P is silent!", id: "j15" }, { text: "How do you organize a space party?", punchline: "You planet!", id: "j16" }, { text: "Why did the scarecrow win an award?", punchline: "Because he was outstanding in his field!", id: "j17" }], 'Short Jokes': [{ text: "What do you call a fake noodle?", punchline: "An impasta!", id: "j4" }, { text: "Why don't eggs tell jokes?", punchline: "They'd crack each other up!", id: "j5" }, { text: "How do you organize a space party?", punchline: "You planet!", id: "j6" }, { text: "Did you hear about the claustrophobic astronaut?", punchline: "He just needed a little space.", id: "j18" }, { text: "Why don't scientists trust atoms?", punchline: "Because they make up everything!", id: "j19" }, { text: "What did the ocean say to the beach?", punchline: "Nothing, it just waved!", id: "j20" }, { text: "I only know 25 letters of the alphabet.", punchline: "I don't know y.", id: "j21" }, { text: "What do you call a bear with no teeth?", punchline: "A gummy bear!", id: "j22" }, { text: "What's the best time to go to the dentist?", punchline: "Tooth-hurty!", id: "j23" }, { text: "I'm on a seafood diet.", punchline: "I see food and I eat it!", id: "j24" }, { text: "Why was six scared of seven?", punchline: "Because seven eight nine!", id: "j25" }, { text: "What do you call a fish with no eyes?", punchline: "Fsh!", id: "j26" }], 'Funny Stories': [{ text: "My friend says to me: 'What rhymes with orange?' I said: 'No it doesn't'", id: "j7" }, { text: "I told my doctor that I broke my arm in two places. He told me to stop going to those places.", id: "j8" }, { text: "I asked the gym instructor if he could teach me to do the splits. He replied, 'How flexible are you?' I said, 'I can't make Tuesdays.'", id: "j9" }, { text: "I told my wife she should embrace her mistakes. She gave me a hug.", id: "j27" }, { text: "My wife told me to stop acting like a flamingo, so I had to put my foot down.", id: "j28" }, { text: "I was wondering why the ball kept getting bigger and bigger, and then it hit me.", id: "j29" }, { text: "I have a fear of speed bumps, but I'm slowly getting over it.", id: "j30" }, { text: "Parallel lines have so much in common. It's a shame they'll never meet.", id: "j31" }, { text: "I saw an ad for burial plots, and thought to myself this is the last thing I need.", id: "j32" }, { text: "I didn't want to believe that my dad was stealing from his job as a road worker. But when I got home, all the signs were there.", id: "j33" }, { text: "My friend keeps saying 'cheer up, things could be worse, you could be stuck underground in a hole full of water.' I know he means well.", id: "j34" }, { text: "When my wife said she wanted a cat, I told her I'm allergic. So we compromised and got a cat.", id: "j35" }, { text: "A guy walks into a bar with a newt on his shoulder. The bartender asks, 'What's his name?' The guy says, 'Tiny.' The bartender asks, 'Why?' The guy replies, 'Because he's my newt!'", id: "j36" }, { text: "Someone stole my mood ring. I don't know how I feel about that.", id: "j37" }], 'Dad Jokes': [{ text: "I don't trust stairs. They're always up to something.", id: "j38" }, { text: "Why don't scientists trust atoms? Because they make up everything!", id: "j39" }, { text: "What do you call a fake noodle? An impasta!", id: "j40" }, { text: "What do you call cheese that isn't yours? Nacho cheese!", id: "j41" }, { text: "How do you organize a space party? You planet!", id: "j42" }, { text: "I'm reading a book on anti-gravity. It's impossible to put down!", id: "j43" }, { text: "Did you hear about the restaurant on the moon? Great food, no atmosphere!", id: "j44" }, { text: "Why did the scarecrow win an award? Because he was outstanding in his field!", id: "j45" }, { text: "I used to be a baker, but I couldn't make enough dough.", id: "j46" }, { text: "I told my wife she was drawing her eyebrows too high. She looked surprised!", id: "j47" }, { text: "What did the buffalo say when his son left for college? Bison!", id: "j48" }, { text: "Why do fathers take an extra pair of socks when they go golfing? In case they get a hole in one!", id: "j49" }, { text: "How do you get a squirrel to like you? Act like a nut!", id: "j50" }, { text: "Why don't eggs tell jokes? They'd crack each other up!", id: "j51" }] }, riddles: { 'Classic Riddles': [{ text: "I'm tall when I'm young, and I'm short when I'm old. What am I?", punchline: "A candle", id: "r1" }, { text: "What has a head and a tail but no body?", punchline: "A coin", id: "r2" }, { text: "What has to be broken before you can use it?", punchline: "An egg", id: "r3" }, { text: "What gets wetter as it dries?", punchline: "A towel", id: "r10" }, { text: "What has a thumb and four fingers, but is not alive?", punchline: "A glove", id: "r11" }, { text: "The more you take, the more you leave behind. What am I?", punchline: "Footsteps", id: "r12" }, { text: "What has many keys but can't open a single lock?", punchline: "A piano", id: "r13" }, { text: "What has a neck but no head?", punchline: "A bottle", id: "r14" }, { text: "What comes once in a minute, twice in a moment, but never in a thousand years?", punchline: "The letter 'M'", id: "r15" }, { text: "What can travel around the world while staying in a corner?", punchline: "A stamp", id: "r16" }, { text: "What has 13 hearts but no other organs?", punchline: "A deck of cards", id: "r17" }, { text: "What runs but never walks, has a mouth but never talks?", punchline: "A river", id: "r18" }], 'Brain Teasers': [{ text: "A man walks into a bar and asks for a glass of water. The bartender pulls out a gun and points it at him. The man says 'Thank you' and walks out. Why?", punchline: "The man had hiccups. The bartender scared them away.", id: "r4" }, { text: "Forward I am heavy, but backward I am not. What am I?", punchline: "The word 'ton'", id: "r5" }, { text: "If you have me, you want to share me. If you share me, you haven't got me. What am I?", punchline: "A secret", id: "r6" }, { text: "I have cities, but no houses. I have mountains, but no trees. I have water, but no fish. What am I?", punchline: "A map", id: "r19" }, { text: "What is always in front of you but can't be seen?", punchline: "The future", id: "r20" }, { text: "The person who makes it doesn't want it. The person who buys it doesn't use it. The person who uses it doesn't know it. What is it?", punchline: "A coffin", id: "r21" }, { text: "I speak without a mouth and hear without ears. I have no body, but I come alive with wind. What am I?", punchline: "An echo", id: "r22" }, { text: "You see a boat filled with people. It has not sunk, but when you look again you don't see a single person on the boat. Why?", punchline: "All the people were married", id: "r23" }, { text: "What is so fragile that saying its name breaks it?", punchline: "Silence", id: "r24" }, { text: "A father's child, a mother's child, yet no one's son. Who am I?", punchline: "A daughter", id: "r25" }, { text: "How can a woman in New York, legally marry 20 men, without getting divorced or widowed even once?", punchline: "She's a minister/wedding officiant", id: "r26" }, { text: "What can you keep after giving it to someone else?", punchline: "Your word", id: "r27" }, { text: "Turn me on my side and I am everything. Cut me in half and I am nothing. What am I?", punchline: "The number 8", id: "r28" }], 'Word Riddles': [{ text: "What word is spelled incorrectly in every single dictionary?", punchline: "Incorrectly", id: "r7" }, { text: "What has 4 letters, sometimes 9 letters, but never has 5 letters?", punchline: "The words 'what', 'sometimes', and 'never'", id: "r8" }, { text: "What starts with an E, ends with an E, but only contains one letter?", punchline: "An envelope", id: "r9" }, { text: "What five-letter word becomes shorter when you add two letters to it?", punchline: "Short (add -er to make 'shorter')", id: "r29" }, { text: "Which word in the dictionary is spelled incorrectly?", punchline: "Incorrectly", id: "r30" }, { text: "What word is pronounced the same if you take away four of its five letters?", punchline: "Queue (Q)", id: "r31" }, { text: "I am a word that begins with the letter 'i.' If you add the letter 'a' to me, I become a different word with a different meaning, but that sounds exactly the same. What word am I?", punchline: "Isle (add 'a' to make 'aisle')", id: "r32" }, { text: "What English word has three consecutive double letters?", punchline: "Bookkeeper", id: "r33" }, { text: "What is the only word in the English language that ends with the letters 'mt'?", punchline: "Dreamt", id: "r34" }, { text: "What 8-letter word can have a letter taken away and still make a word? Take another letter away and it still makes a word. Keep doing that until you have one letter left. What is the word?", punchline: "Starting (starting, staring, string, sting, sing, sin, in, I)", id: "r35" }, { text: "What's black when you get it, red when you use it, and white when you're all through with it?", punchline: "Charcoal", id: "r36" }, { text: "What common English word is nine letters long and each time you remove a letter from it, it still remains an English word - from nine letters all the way down to a single letter?", punchline: "Startling (startling, starting, staring, string, sting, sing, sin, in, I)", id: "r37" }, { text: "I am a word of letters three; add two and fewer there will be. What word am I?", punchline: "Few (add 'er' to make 'fewer')", id: "r38" }, { text: "What begins with T, ends with T, and has T in it?", punchline: "A teapot", id: "r39" }, { text: "What four-letter word can be written forward, backward, or upside down, and can still be read from left to right?", punchline: "NOON", id: "r40" }] } }; // Game variables var currentMode = storage.mode || 'jokes'; var currentCategory = CATEGORIES[currentMode][0]; var currentCardIndex = 0; var categoryButtons = []; var contentCards = []; var currentContentList = []; // Create title var titleText = new Text2("Jokes Express", { size: 100, fill: 0x000000 }); titleText.anchor.set(0.5, 0); titleText.y = 50; LK.gui.top.addChild(titleText); // Create points display var pointsText = new Text2("Points: " + storage.points, { size: 60, fill: 0x000000 }); pointsText.anchor.set(1, 0); pointsText.x = 1950; pointsText.y = 70; LK.gui.topRight.addChild(pointsText); // Create toggle switch for jokes/riddles var modeToggle = new ToggleSwitch("Jokes", "Riddles"); modeToggle.x = 1024; modeToggle.y = 700; // Moved higher up (from 900 to 700) game.addChild(modeToggle); modeToggle.setState(currentMode === 'riddles'); modeToggle.onToggle = function (state) { currentMode = state ? 'riddles' : 'jokes'; storage.mode = currentMode; refreshCategories(); refreshContent(); }; // Favorites button removed // Create category container var categoryContainer = new Container(); categoryContainer.x = 1024; categoryContainer.y = 400; game.addChild(categoryContainer); // Create content card container var cardContainer = new Container(); cardContainer.x = 1024; cardContainer.y = 1300; game.addChild(cardContainer); // Create navigation buttons var prevButton = new Text2("< Prev", { size: 70, fill: 0x000000 }); prevButton.anchor.set(0.5, 0.5); prevButton.x = 700; prevButton.y = 1800; game.addChild(prevButton); var nextButton = new Text2("Next >", { size: 70, fill: 0x000000 }); nextButton.anchor.set(0.5, 0.5); nextButton.x = 1350; nextButton.y = 1800; game.addChild(nextButton); // Initialize categories function refreshCategories() { // Clear existing buttons categoryContainer.removeChildren(); categoryButtons = []; // Create category buttons var categories = CATEGORIES[currentMode]; var totalWidth = categories.length * 350; var startX = -totalWidth / 2 + 175; categories.forEach(function (category, index) { var button = new CategoryButton(category, index); button.x = startX + index * 350; button.y = 0; button.onSelect = function (category) { selectCategory(category); }; categoryContainer.addChild(button); categoryButtons.push(button); }); selectCategory(categories[0]); } // Select category function selectCategory(category) { currentCategory = category; currentCardIndex = 0; refreshContent(); // Update visual selection categoryButtons.forEach(function (button) { button.setSelected(button.category === category); }); } // Get content without favorites filter function getFilteredContent() { return CONTENT[currentMode][currentCategory]; } // Refresh content cards function refreshContent() { // Clear existing cards cardContainer.removeChildren(); contentCards = []; // Get filtered content currentContentList = getFilteredContent(); if (currentContentList.length === 0) { var noContentText = new Text2("No favorites in this category", { size: 70, fill: 0x000000 }); noContentText.anchor.set(0.5, 0.5); cardContainer.addChild(noContentText); // Disable navigation buttons prevButton.alpha = 0.5; nextButton.alpha = 0.5; return; } // Create content card var content = currentContentList[currentCardIndex]; var card = new ContentCard(content); card.onPointEarned = function () { pointsText.setText("Points: " + storage.points); }; card.onFavoriteToggled = function () { if (showingFavoritesOnly) { refreshContent(); } }; cardContainer.addChild(card); contentCards.push(card); // Update navigation buttons prevButton.alpha = currentCardIndex > 0 ? 1 : 0.5; nextButton.alpha = currentCardIndex < currentContentList.length - 1 ? 1 : 0.5; LK.getSound('cardFlip').play(); } // Favorites button handler removed prevButton.interactive = true; prevButton.down = function () { LK.getSound('point').play(); if (currentCardIndex > 0) { currentCardIndex--; refreshContent(); } }; nextButton.interactive = true; nextButton.down = function () { LK.getSound('point').play(); if (currentCardIndex < currentContentList.length - 1) { currentCardIndex++; refreshContent(); } }; // Initialize the game refreshCategories(); // Play background music on loop LK.playMusic('bgmusic'); ;
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
points: 0,
favorites: {},
viewedContent: {},
mode: "jokes"
});
/****
* Classes
****/
var CategoryButton = Container.expand(function (category, index) {
var self = Container.call(this);
self.category = category;
var button = self.attachAsset('categoryButton', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2(category, {
size: 50,
fill: 0x000000
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.setSelected = function (selected) {
button.tint = selected ? 0x2E5B9E : 0x4A90E2;
};
self.down = function () {
button.tint = 0x2E5B9E;
LK.getSound('point').play();
};
self.up = function () {
if (typeof self.onSelect === 'function') {
self.onSelect(self.category);
}
};
return self;
});
var ContentCard = Container.expand(function (content) {
var self = Container.call(this);
self.content = content;
var card = self.attachAsset('card', {
anchorX: 0.5,
anchorY: 0.5
});
card.alpha = 0.9;
var category = new Text2(content.category, {
size: 50,
fill: 0x000000
});
category.anchor.set(0.5, 0);
category.y = -400;
self.addChild(category);
// Function to add line breaks every 5 words
function addLineBreaksEvery5Words(text) {
var words = text.split(' ');
var result = '';
for (var i = 0; i < words.length; i++) {
result += words[i];
if ((i + 1) % 5 === 0 && i < words.length - 1) {
result += '\n';
} else if (i < words.length - 1) {
result += ' ';
}
}
return result;
}
// Apply line breaks to content text
var formattedText = addLineBreaksEvery5Words(content.text);
var contentText = new Text2(formattedText, {
size: 90,
fill: 0x000000
});
contentText.anchor.set(0.5, 0.5);
contentText.y = 0;
// Handle long text by adjusting font size
if (content.text.length > 150) {
contentText.setText(contentText.text, {
size: 70,
fill: 0x000000
});
}
if (content.text.length > 300) {
contentText.setText(contentText.text, {
size: 60,
fill: 0x000000
});
}
self.addChild(contentText);
var punchline = null;
if (content.punchline) {
punchline = new Text2("Tap to reveal punchline", {
size: 60,
fill: 0x000000
});
punchline.anchor.set(0.5, 0);
punchline.y = 150;
self.addChild(punchline);
}
// Star asset removed
self.setFavorite = function (isFavorite) {
// Favorites functionality removed
};
self.revealPunchline = function () {
if (content.punchline && punchline) {
// Format punchline with line breaks every 5 words
var formattedPunchline = "**" + addLineBreaksEvery5Words(content.punchline) + "**";
// Set the punchline text with dark color and proper size
punchline.setText(formattedPunchline, {
fill: 0x000000,
size: 80
});
// Mark as viewed in storage
var contentKey = content.id || content.text.substring(0, 20) + content.category;
if (!storage.viewedContent[contentKey]) {
storage.viewedContent[contentKey] = true;
storage.points += 1;
if (typeof self.onPointEarned === 'function') {
self.onPointEarned();
}
LK.getSound('point').play();
}
}
};
// Favorites functionality removed
// Initialize favorite state
var contentKey = content.id || content.text.substring(0, 20) + content.category;
self.setFavorite(storage.favorites[contentKey] || false);
self.down = function (x, y, obj) {
var localPos = self.toLocal({
x: x,
y: y
});
// Only handle punchline reveal now
if (content.punchline && punchline) {
self.revealPunchline();
}
};
return self;
});
var ToggleSwitch = Container.expand(function (leftText, rightText) {
var self = Container.call(this);
var background = self.attachAsset('toggleBackground', {
anchorX: 0.5,
anchorY: 0.5
});
var button = self.attachAsset('toggleButton', {
anchorX: 0.5,
anchorY: 0.5,
x: -75
});
var leftLabel = new Text2(leftText, {
size: 40,
fill: 0x000000
});
leftLabel.anchor.set(0.5, 0.5);
leftLabel.x = -75;
leftLabel.y = -70;
self.addChild(leftLabel);
var rightLabel = new Text2(rightText, {
size: 40,
fill: 0x000000
});
rightLabel.anchor.set(0.5, 0.5);
rightLabel.x = 75;
rightLabel.y = -70;
self.addChild(rightLabel);
self.state = false;
self.setState = function (state) {
self.state = state;
var targetX = state ? 75 : -75;
tween(button, {
x: targetX
}, {
duration: 300,
easing: tween.easeOut
});
};
self.toggle = function () {
self.setState(!self.state);
if (typeof self.onToggle === 'function') {
self.onToggle(self.state);
}
};
self.down = function () {
LK.getSound('point').play();
self.toggle();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF0F0F0
});
/****
* Game Code
****/
// Favorite sound removed
// Star asset removed
// Constants and game data
var CATEGORIES = {
jokes: ['Wordplay', 'Short Jokes', 'Funny Stories', 'Dad Jokes'],
riddles: ['Classic Riddles', 'Brain Teasers', 'Word Riddles']
};
var CONTENT = {
jokes: {
'Wordplay': [{
text: "Why don't scientists trust atoms?",
punchline: "Because they make up everything!",
id: "j1"
}, {
text: "Did you hear about the mathematician who's afraid of negative numbers?",
punchline: "He'll stop at nothing to avoid them!",
id: "j2"
}, {
text: "I told my wife she was drawing her eyebrows too high.",
punchline: "She looked surprised!",
id: "j3"
}, {
text: "What do you call a deer with no eyes?",
punchline: "No idea (no eye deer)!",
id: "j10"
}, {
text: "What's the best thing about Switzerland?",
punchline: "I don't know, but the flag is a big plus!",
id: "j11"
}, {
text: "I'm reading a book about anti-gravity.",
punchline: "It's impossible to put down!",
id: "j12"
}, {
text: "I used to be a baker, but I couldn't make enough dough.",
punchline: "Now I'm just loafing around.",
id: "j13"
}, {
text: "What's orange and sounds like a parrot?",
punchline: "A carrot!",
id: "j14"
}, {
text: "Why can't you hear a pterodactyl in the bathroom?",
punchline: "Because the P is silent!",
id: "j15"
}, {
text: "How do you organize a space party?",
punchline: "You planet!",
id: "j16"
}, {
text: "Why did the scarecrow win an award?",
punchline: "Because he was outstanding in his field!",
id: "j17"
}],
'Short Jokes': [{
text: "What do you call a fake noodle?",
punchline: "An impasta!",
id: "j4"
}, {
text: "Why don't eggs tell jokes?",
punchline: "They'd crack each other up!",
id: "j5"
}, {
text: "How do you organize a space party?",
punchline: "You planet!",
id: "j6"
}, {
text: "Did you hear about the claustrophobic astronaut?",
punchline: "He just needed a little space.",
id: "j18"
}, {
text: "Why don't scientists trust atoms?",
punchline: "Because they make up everything!",
id: "j19"
}, {
text: "What did the ocean say to the beach?",
punchline: "Nothing, it just waved!",
id: "j20"
}, {
text: "I only know 25 letters of the alphabet.",
punchline: "I don't know y.",
id: "j21"
}, {
text: "What do you call a bear with no teeth?",
punchline: "A gummy bear!",
id: "j22"
}, {
text: "What's the best time to go to the dentist?",
punchline: "Tooth-hurty!",
id: "j23"
}, {
text: "I'm on a seafood diet.",
punchline: "I see food and I eat it!",
id: "j24"
}, {
text: "Why was six scared of seven?",
punchline: "Because seven eight nine!",
id: "j25"
}, {
text: "What do you call a fish with no eyes?",
punchline: "Fsh!",
id: "j26"
}],
'Funny Stories': [{
text: "My friend says to me: 'What rhymes with orange?' I said: 'No it doesn't'",
id: "j7"
}, {
text: "I told my doctor that I broke my arm in two places. He told me to stop going to those places.",
id: "j8"
}, {
text: "I asked the gym instructor if he could teach me to do the splits. He replied, 'How flexible are you?' I said, 'I can't make Tuesdays.'",
id: "j9"
}, {
text: "I told my wife she should embrace her mistakes. She gave me a hug.",
id: "j27"
}, {
text: "My wife told me to stop acting like a flamingo, so I had to put my foot down.",
id: "j28"
}, {
text: "I was wondering why the ball kept getting bigger and bigger, and then it hit me.",
id: "j29"
}, {
text: "I have a fear of speed bumps, but I'm slowly getting over it.",
id: "j30"
}, {
text: "Parallel lines have so much in common. It's a shame they'll never meet.",
id: "j31"
}, {
text: "I saw an ad for burial plots, and thought to myself this is the last thing I need.",
id: "j32"
}, {
text: "I didn't want to believe that my dad was stealing from his job as a road worker. But when I got home, all the signs were there.",
id: "j33"
}, {
text: "My friend keeps saying 'cheer up, things could be worse, you could be stuck underground in a hole full of water.' I know he means well.",
id: "j34"
}, {
text: "When my wife said she wanted a cat, I told her I'm allergic. So we compromised and got a cat.",
id: "j35"
}, {
text: "A guy walks into a bar with a newt on his shoulder. The bartender asks, 'What's his name?' The guy says, 'Tiny.' The bartender asks, 'Why?' The guy replies, 'Because he's my newt!'",
id: "j36"
}, {
text: "Someone stole my mood ring. I don't know how I feel about that.",
id: "j37"
}],
'Dad Jokes': [{
text: "I don't trust stairs. They're always up to something.",
id: "j38"
}, {
text: "Why don't scientists trust atoms? Because they make up everything!",
id: "j39"
}, {
text: "What do you call a fake noodle? An impasta!",
id: "j40"
}, {
text: "What do you call cheese that isn't yours? Nacho cheese!",
id: "j41"
}, {
text: "How do you organize a space party? You planet!",
id: "j42"
}, {
text: "I'm reading a book on anti-gravity. It's impossible to put down!",
id: "j43"
}, {
text: "Did you hear about the restaurant on the moon? Great food, no atmosphere!",
id: "j44"
}, {
text: "Why did the scarecrow win an award? Because he was outstanding in his field!",
id: "j45"
}, {
text: "I used to be a baker, but I couldn't make enough dough.",
id: "j46"
}, {
text: "I told my wife she was drawing her eyebrows too high. She looked surprised!",
id: "j47"
}, {
text: "What did the buffalo say when his son left for college? Bison!",
id: "j48"
}, {
text: "Why do fathers take an extra pair of socks when they go golfing? In case they get a hole in one!",
id: "j49"
}, {
text: "How do you get a squirrel to like you? Act like a nut!",
id: "j50"
}, {
text: "Why don't eggs tell jokes? They'd crack each other up!",
id: "j51"
}]
},
riddles: {
'Classic Riddles': [{
text: "I'm tall when I'm young, and I'm short when I'm old. What am I?",
punchline: "A candle",
id: "r1"
}, {
text: "What has a head and a tail but no body?",
punchline: "A coin",
id: "r2"
}, {
text: "What has to be broken before you can use it?",
punchline: "An egg",
id: "r3"
}, {
text: "What gets wetter as it dries?",
punchline: "A towel",
id: "r10"
}, {
text: "What has a thumb and four fingers, but is not alive?",
punchline: "A glove",
id: "r11"
}, {
text: "The more you take, the more you leave behind. What am I?",
punchline: "Footsteps",
id: "r12"
}, {
text: "What has many keys but can't open a single lock?",
punchline: "A piano",
id: "r13"
}, {
text: "What has a neck but no head?",
punchline: "A bottle",
id: "r14"
}, {
text: "What comes once in a minute, twice in a moment, but never in a thousand years?",
punchline: "The letter 'M'",
id: "r15"
}, {
text: "What can travel around the world while staying in a corner?",
punchline: "A stamp",
id: "r16"
}, {
text: "What has 13 hearts but no other organs?",
punchline: "A deck of cards",
id: "r17"
}, {
text: "What runs but never walks, has a mouth but never talks?",
punchline: "A river",
id: "r18"
}],
'Brain Teasers': [{
text: "A man walks into a bar and asks for a glass of water. The bartender pulls out a gun and points it at him. The man says 'Thank you' and walks out. Why?",
punchline: "The man had hiccups. The bartender scared them away.",
id: "r4"
}, {
text: "Forward I am heavy, but backward I am not. What am I?",
punchline: "The word 'ton'",
id: "r5"
}, {
text: "If you have me, you want to share me. If you share me, you haven't got me. What am I?",
punchline: "A secret",
id: "r6"
}, {
text: "I have cities, but no houses. I have mountains, but no trees. I have water, but no fish. What am I?",
punchline: "A map",
id: "r19"
}, {
text: "What is always in front of you but can't be seen?",
punchline: "The future",
id: "r20"
}, {
text: "The person who makes it doesn't want it. The person who buys it doesn't use it. The person who uses it doesn't know it. What is it?",
punchline: "A coffin",
id: "r21"
}, {
text: "I speak without a mouth and hear without ears. I have no body, but I come alive with wind. What am I?",
punchline: "An echo",
id: "r22"
}, {
text: "You see a boat filled with people. It has not sunk, but when you look again you don't see a single person on the boat. Why?",
punchline: "All the people were married",
id: "r23"
}, {
text: "What is so fragile that saying its name breaks it?",
punchline: "Silence",
id: "r24"
}, {
text: "A father's child, a mother's child, yet no one's son. Who am I?",
punchline: "A daughter",
id: "r25"
}, {
text: "How can a woman in New York, legally marry 20 men, without getting divorced or widowed even once?",
punchline: "She's a minister/wedding officiant",
id: "r26"
}, {
text: "What can you keep after giving it to someone else?",
punchline: "Your word",
id: "r27"
}, {
text: "Turn me on my side and I am everything. Cut me in half and I am nothing. What am I?",
punchline: "The number 8",
id: "r28"
}],
'Word Riddles': [{
text: "What word is spelled incorrectly in every single dictionary?",
punchline: "Incorrectly",
id: "r7"
}, {
text: "What has 4 letters, sometimes 9 letters, but never has 5 letters?",
punchline: "The words 'what', 'sometimes', and 'never'",
id: "r8"
}, {
text: "What starts with an E, ends with an E, but only contains one letter?",
punchline: "An envelope",
id: "r9"
}, {
text: "What five-letter word becomes shorter when you add two letters to it?",
punchline: "Short (add -er to make 'shorter')",
id: "r29"
}, {
text: "Which word in the dictionary is spelled incorrectly?",
punchline: "Incorrectly",
id: "r30"
}, {
text: "What word is pronounced the same if you take away four of its five letters?",
punchline: "Queue (Q)",
id: "r31"
}, {
text: "I am a word that begins with the letter 'i.' If you add the letter 'a' to me, I become a different word with a different meaning, but that sounds exactly the same. What word am I?",
punchline: "Isle (add 'a' to make 'aisle')",
id: "r32"
}, {
text: "What English word has three consecutive double letters?",
punchline: "Bookkeeper",
id: "r33"
}, {
text: "What is the only word in the English language that ends with the letters 'mt'?",
punchline: "Dreamt",
id: "r34"
}, {
text: "What 8-letter word can have a letter taken away and still make a word? Take another letter away and it still makes a word. Keep doing that until you have one letter left. What is the word?",
punchline: "Starting (starting, staring, string, sting, sing, sin, in, I)",
id: "r35"
}, {
text: "What's black when you get it, red when you use it, and white when you're all through with it?",
punchline: "Charcoal",
id: "r36"
}, {
text: "What common English word is nine letters long and each time you remove a letter from it, it still remains an English word - from nine letters all the way down to a single letter?",
punchline: "Startling (startling, starting, staring, string, sting, sing, sin, in, I)",
id: "r37"
}, {
text: "I am a word of letters three; add two and fewer there will be. What word am I?",
punchline: "Few (add 'er' to make 'fewer')",
id: "r38"
}, {
text: "What begins with T, ends with T, and has T in it?",
punchline: "A teapot",
id: "r39"
}, {
text: "What four-letter word can be written forward, backward, or upside down, and can still be read from left to right?",
punchline: "NOON",
id: "r40"
}]
}
};
// Game variables
var currentMode = storage.mode || 'jokes';
var currentCategory = CATEGORIES[currentMode][0];
var currentCardIndex = 0;
var categoryButtons = [];
var contentCards = [];
var currentContentList = [];
// Create title
var titleText = new Text2("Jokes Express", {
size: 100,
fill: 0x000000
});
titleText.anchor.set(0.5, 0);
titleText.y = 50;
LK.gui.top.addChild(titleText);
// Create points display
var pointsText = new Text2("Points: " + storage.points, {
size: 60,
fill: 0x000000
});
pointsText.anchor.set(1, 0);
pointsText.x = 1950;
pointsText.y = 70;
LK.gui.topRight.addChild(pointsText);
// Create toggle switch for jokes/riddles
var modeToggle = new ToggleSwitch("Jokes", "Riddles");
modeToggle.x = 1024;
modeToggle.y = 700; // Moved higher up (from 900 to 700)
game.addChild(modeToggle);
modeToggle.setState(currentMode === 'riddles');
modeToggle.onToggle = function (state) {
currentMode = state ? 'riddles' : 'jokes';
storage.mode = currentMode;
refreshCategories();
refreshContent();
};
// Favorites button removed
// Create category container
var categoryContainer = new Container();
categoryContainer.x = 1024;
categoryContainer.y = 400;
game.addChild(categoryContainer);
// Create content card container
var cardContainer = new Container();
cardContainer.x = 1024;
cardContainer.y = 1300;
game.addChild(cardContainer);
// Create navigation buttons
var prevButton = new Text2("< Prev", {
size: 70,
fill: 0x000000
});
prevButton.anchor.set(0.5, 0.5);
prevButton.x = 700;
prevButton.y = 1800;
game.addChild(prevButton);
var nextButton = new Text2("Next >", {
size: 70,
fill: 0x000000
});
nextButton.anchor.set(0.5, 0.5);
nextButton.x = 1350;
nextButton.y = 1800;
game.addChild(nextButton);
// Initialize categories
function refreshCategories() {
// Clear existing buttons
categoryContainer.removeChildren();
categoryButtons = [];
// Create category buttons
var categories = CATEGORIES[currentMode];
var totalWidth = categories.length * 350;
var startX = -totalWidth / 2 + 175;
categories.forEach(function (category, index) {
var button = new CategoryButton(category, index);
button.x = startX + index * 350;
button.y = 0;
button.onSelect = function (category) {
selectCategory(category);
};
categoryContainer.addChild(button);
categoryButtons.push(button);
});
selectCategory(categories[0]);
}
// Select category
function selectCategory(category) {
currentCategory = category;
currentCardIndex = 0;
refreshContent();
// Update visual selection
categoryButtons.forEach(function (button) {
button.setSelected(button.category === category);
});
}
// Get content without favorites filter
function getFilteredContent() {
return CONTENT[currentMode][currentCategory];
}
// Refresh content cards
function refreshContent() {
// Clear existing cards
cardContainer.removeChildren();
contentCards = [];
// Get filtered content
currentContentList = getFilteredContent();
if (currentContentList.length === 0) {
var noContentText = new Text2("No favorites in this category", {
size: 70,
fill: 0x000000
});
noContentText.anchor.set(0.5, 0.5);
cardContainer.addChild(noContentText);
// Disable navigation buttons
prevButton.alpha = 0.5;
nextButton.alpha = 0.5;
return;
}
// Create content card
var content = currentContentList[currentCardIndex];
var card = new ContentCard(content);
card.onPointEarned = function () {
pointsText.setText("Points: " + storage.points);
};
card.onFavoriteToggled = function () {
if (showingFavoritesOnly) {
refreshContent();
}
};
cardContainer.addChild(card);
contentCards.push(card);
// Update navigation buttons
prevButton.alpha = currentCardIndex > 0 ? 1 : 0.5;
nextButton.alpha = currentCardIndex < currentContentList.length - 1 ? 1 : 0.5;
LK.getSound('cardFlip').play();
}
// Favorites button handler removed
prevButton.interactive = true;
prevButton.down = function () {
LK.getSound('point').play();
if (currentCardIndex > 0) {
currentCardIndex--;
refreshContent();
}
};
nextButton.interactive = true;
nextButton.down = function () {
LK.getSound('point').play();
if (currentCardIndex < currentContentList.length - 1) {
currentCardIndex++;
refreshContent();
}
};
// Initialize the game
refreshCategories();
// Play background music on loop
LK.playMusic('bgmusic');
;