User prompt
Diseña la interfaz y hazla funcional pls ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Crea una interfaz al iniciar el juego que aparezca la opción de jugar cambiar el idioma de juego y tu máxima puntuación en cada idioma ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Haz un sitio donde aparezcan las vidas
User prompt
Please fix the bug: 'storage.get is not a function. (In 'storage.get('selectedLanguage')', 'storage.get' is undefined)' in or related to this line: 'var currentLanguage = storage.get('selectedLanguage') || 'es';' Line Number: 153 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Sip puedes poner una interfaz y que puedas cambiar el idioma de las palabras
User prompt
Add músic
User prompt
Finx de bugs pls
Code edit (1 edits merged)
Please save this source code
User prompt
Puedes poner el fondo más colorido y que vaya cambiando dependiendo de la velocidad ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Le añades musica
Code edit (1 edits merged)
Please save this source code
User prompt
Palabras Volantes
Initial prompt
Hablas español
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphic = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var LanguageButton = Container.expand(function () { var self = Container.call(this); // Create button background var buttonBg = self.attachAsset('wordBubble', { anchorX: 0.5, anchorY: 0.5 }); buttonBg.width = 200; buttonBg.height = 60; // Create text for the button self.buttonText = new Text2('Español', { size: 36, fill: 0xFFFFFF }); self.buttonText.anchor.set(0.5, 0.5); self.addChild(self.buttonText); self.setLanguage = function (lang) { if (lang === 'es') { self.buttonText.setText('Español'); } else if (lang === 'en') { self.buttonText.setText('English'); } else if (lang === 'fr') { self.buttonText.setText('Français'); } }; // Touch handler for language cycling self.down = function (x, y, obj) { // Cycle through languages if (currentLanguage === 'es') { currentLanguage = 'en'; } else if (currentLanguage === 'en') { currentLanguage = 'fr'; } else { currentLanguage = 'es'; } // Save language preference storage.set('selectedLanguage', currentLanguage); // Update button text self.setLanguage(currentLanguage); // Update word categories updateWordCategories(); // Visual feedback LK.effects.flashObject(self, 0xFFEB3B, 300); }; return self; }); var Word = Container.expand(function () { var self = Container.call(this); // Create word bubble background var bubble = self.attachAsset('wordBubble', { anchorX: 0.5, anchorY: 0.5 }); // Create text for the word self.wordText = new Text2('', { size: 48, fill: 0xFFFFFF }); self.wordText.anchor.set(0.5, 0.5); self.addChild(self.wordText); // Word properties self.fallSpeed = 2; self.word = ''; self.missed = false; // Set the word text self.setWord = function (word) { self.word = word; self.wordText.setText(word); }; // Update method called every frame self.update = function () { self.y += self.fallSpeed; }; // Touch handler self.down = function (x, y, obj) { if (!self.missed) { // Word was touched correctly LK.setScore(LK.getScore() + 10); scoreText.setText(LK.getScore()); // Visual effect LK.effects.flashObject(self, 0xFFEB3B, 300); tween(self, { scaleX: 1.5, scaleY: 1.5, alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); // Play sound LK.getSound('correctWord').play(); // Remove from words array for (var i = words.length - 1; i >= 0; i--) { if (words[i] === self) { words.splice(i, 1); break; } } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1976D2 }); /**** * Game Code ****/ // Game variables var words = []; var lives = 3; var hearts = []; var currentSpeed = 2; var wordSpawnTimer = 0; var spawnInterval = 120; // Spawn every 2 seconds at 60 FPS var backgroundColors = [0x1976D2, 0x7B1FA2, 0xD32F2F, 0xF57C00, 0x388E3C, 0x1976D2]; var currentColorIndex = 0; var lastSpeedLevel = 0; // Language system var currentLanguage = storage.get('selectedLanguage') || 'es'; var languageButton; // Multi-language words by category var allLanguageWords = { es: { animales: ['gato', 'perro', 'pájaro', 'pez', 'león', 'tigre', 'oso', 'ratón'], colores: ['rojo', 'azul', 'verde', 'amarillo', 'naranja', 'morado', 'rosa', 'negro'], comida: ['manzana', 'pan', 'agua', 'leche', 'queso', 'pollo', 'arroz', 'pasta'], objetos: ['mesa', 'silla', 'libro', 'lápiz', 'coche', 'casa', 'puerta', 'ventana'] }, en: { animals: ['cat', 'dog', 'bird', 'fish', 'lion', 'tiger', 'bear', 'mouse'], colors: ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'black'], food: ['apple', 'bread', 'water', 'milk', 'cheese', 'chicken', 'rice', 'pasta'], objects: ['table', 'chair', 'book', 'pencil', 'car', 'house', 'door', 'window'] }, fr: { animaux: ['chat', 'chien', 'oiseau', 'poisson', 'lion', 'tigre', 'ours', 'souris'], couleurs: ['rouge', 'bleu', 'vert', 'jaune', 'orange', 'violet', 'rose', 'noir'], nourriture: ['pomme', 'pain', 'eau', 'lait', 'fromage', 'poulet', 'riz', 'pâtes'], objets: ['table', 'chaise', 'livre', 'crayon', 'voiture', 'maison', 'porte', 'fenêtre'] } }; var wordCategories = {}; var allWords = []; // Function to update word categories based on current language function updateWordCategories() { wordCategories = allLanguageWords[currentLanguage]; allWords = []; for (var category in wordCategories) { allWords = allWords.concat(wordCategories[category]); } } // Initialize with current language updateWordCategories(); // Score display var scoreText = new Text2('0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); scoreText.y = 50; // Lives display for (var i = 0; i < 3; i++) { var heart = new Heart(); heart.x = 150 + i * 60; heart.y = 50; hearts.push(heart); LK.gui.topRight.addChild(heart); } // Language selection button languageButton = new LanguageButton(); languageButton.x = 150; languageButton.y = 120; languageButton.setLanguage(currentLanguage); LK.gui.topLeft.addChild(languageButton); // Function to spawn a new word function spawnWord() { var word = new Word(); var randomWord = allWords[Math.floor(Math.random() * allWords.length)]; word.setWord(randomWord); // Random horizontal position word.x = Math.random() * (2048 - 300) + 150; word.y = -100; word.fallSpeed = currentSpeed; words.push(word); game.addChild(word); } // Function to lose a life function loseLife() { lives--; if (lives >= 0 && lives < hearts.length) { hearts[lives].alpha = 0.3; } if (lives <= 0) { LK.showGameOver(); } // Play wrong sound LK.getSound('wrongWord').play(); // Flash screen red LK.effects.flashScreen(0xFF1744, 500); } // Game update loop game.update = function () { // Spawn new words wordSpawnTimer++; if (wordSpawnTimer >= spawnInterval) { spawnWord(); wordSpawnTimer = 0; } // Update and check words for (var i = words.length - 1; i >= 0; i--) { var word = words[i]; // Check if word reached bottom if (word.y > 2732 + 50) { if (!word.missed) { word.missed = true; loseLife(); } word.destroy(); words.splice(i, 1); } } // Increase speed every 20 points var speedLevel = Math.floor(LK.getScore() / 20); currentSpeed = 2 + speedLevel * 0.5; // Decrease spawn interval slightly as speed increases spawnInterval = Math.max(60, 120 - speedLevel * 5); // Change background color when speed level increases if (speedLevel !== lastSpeedLevel) { currentColorIndex = speedLevel % backgroundColors.length; var targetColor = backgroundColors[currentColorIndex]; // Simple immediate color change - tween doesn't work well with color interpolation in this context game.setBackgroundColor(targetColor); lastSpeedLevel = speedLevel; } }; // Initialize score scoreText.setText(LK.getScore()); // Play background music LK.playMusic('backgroundMusic');
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
@@ -13,8 +14,54 @@
anchorY: 0.5
});
return self;
});
+var LanguageButton = Container.expand(function () {
+ var self = Container.call(this);
+ // Create button background
+ var buttonBg = self.attachAsset('wordBubble', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ buttonBg.width = 200;
+ buttonBg.height = 60;
+ // Create text for the button
+ self.buttonText = new Text2('Español', {
+ size: 36,
+ fill: 0xFFFFFF
+ });
+ self.buttonText.anchor.set(0.5, 0.5);
+ self.addChild(self.buttonText);
+ self.setLanguage = function (lang) {
+ if (lang === 'es') {
+ self.buttonText.setText('Español');
+ } else if (lang === 'en') {
+ self.buttonText.setText('English');
+ } else if (lang === 'fr') {
+ self.buttonText.setText('Français');
+ }
+ };
+ // Touch handler for language cycling
+ self.down = function (x, y, obj) {
+ // Cycle through languages
+ if (currentLanguage === 'es') {
+ currentLanguage = 'en';
+ } else if (currentLanguage === 'en') {
+ currentLanguage = 'fr';
+ } else {
+ currentLanguage = 'es';
+ }
+ // Save language preference
+ storage.set('selectedLanguage', currentLanguage);
+ // Update button text
+ self.setLanguage(currentLanguage);
+ // Update word categories
+ updateWordCategories();
+ // Visual feedback
+ LK.effects.flashObject(self, 0xFFEB3B, 300);
+ };
+ return self;
+});
var Word = Container.expand(function () {
var self = Container.call(this);
// Create word bubble background
var bubble = self.attachAsset('wordBubble', {
@@ -92,20 +139,44 @@
var spawnInterval = 120; // Spawn every 2 seconds at 60 FPS
var backgroundColors = [0x1976D2, 0x7B1FA2, 0xD32F2F, 0xF57C00, 0x388E3C, 0x1976D2];
var currentColorIndex = 0;
var lastSpeedLevel = 0;
-// Spanish words by category
-var wordCategories = {
- animales: ['gato', 'perro', 'pájaro', 'pez', 'león', 'tigre', 'oso', 'ratón'],
- colores: ['rojo', 'azul', 'verde', 'amarillo', 'naranja', 'morado', 'rosa', 'negro'],
- comida: ['manzana', 'pan', 'agua', 'leche', 'queso', 'pollo', 'arroz', 'pasta'],
- objetos: ['mesa', 'silla', 'libro', 'lápiz', 'coche', 'casa', 'puerta', 'ventana']
+// Language system
+var currentLanguage = storage.get('selectedLanguage') || 'es';
+var languageButton;
+// Multi-language words by category
+var allLanguageWords = {
+ es: {
+ animales: ['gato', 'perro', 'pájaro', 'pez', 'león', 'tigre', 'oso', 'ratón'],
+ colores: ['rojo', 'azul', 'verde', 'amarillo', 'naranja', 'morado', 'rosa', 'negro'],
+ comida: ['manzana', 'pan', 'agua', 'leche', 'queso', 'pollo', 'arroz', 'pasta'],
+ objetos: ['mesa', 'silla', 'libro', 'lápiz', 'coche', 'casa', 'puerta', 'ventana']
+ },
+ en: {
+ animals: ['cat', 'dog', 'bird', 'fish', 'lion', 'tiger', 'bear', 'mouse'],
+ colors: ['red', 'blue', 'green', 'yellow', 'orange', 'purple', 'pink', 'black'],
+ food: ['apple', 'bread', 'water', 'milk', 'cheese', 'chicken', 'rice', 'pasta'],
+ objects: ['table', 'chair', 'book', 'pencil', 'car', 'house', 'door', 'window']
+ },
+ fr: {
+ animaux: ['chat', 'chien', 'oiseau', 'poisson', 'lion', 'tigre', 'ours', 'souris'],
+ couleurs: ['rouge', 'bleu', 'vert', 'jaune', 'orange', 'violet', 'rose', 'noir'],
+ nourriture: ['pomme', 'pain', 'eau', 'lait', 'fromage', 'poulet', 'riz', 'pâtes'],
+ objets: ['table', 'chaise', 'livre', 'crayon', 'voiture', 'maison', 'porte', 'fenêtre']
+ }
};
-// Flatten all words into one array
+var wordCategories = {};
var allWords = [];
-for (var category in wordCategories) {
- allWords = allWords.concat(wordCategories[category]);
+// Function to update word categories based on current language
+function updateWordCategories() {
+ wordCategories = allLanguageWords[currentLanguage];
+ allWords = [];
+ for (var category in wordCategories) {
+ allWords = allWords.concat(wordCategories[category]);
+ }
}
+// Initialize with current language
+updateWordCategories();
// Score display
var scoreText = new Text2('0', {
size: 60,
fill: 0xFFFFFF
@@ -120,8 +191,14 @@
heart.y = 50;
hearts.push(heart);
LK.gui.topRight.addChild(heart);
}
+// Language selection button
+languageButton = new LanguageButton();
+languageButton.x = 150;
+languageButton.y = 120;
+languageButton.setLanguage(currentLanguage);
+LK.gui.topLeft.addChild(languageButton);
// Function to spawn a new word
function spawnWord() {
var word = new Word();
var randomWord = allWords[Math.floor(Math.random() * allWords.length)];