User prompt
when new players play the player can write name. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
do life text .up
User prompt
when we open learderbord do not see questions and logo
User prompt
do when open learderbord button see full screan. do screen ui.
User prompt
do add button that do see learderbord player. to do not like this. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
do learbord on side of logo and logo con.
User prompt
we can change name to save data.
User prompt
Please fix the bug: 'Error: Invalid value. Only literals or 1-level deep objects/arrays containing literals are allowed.' in or related to this line: 'storage.leaderboard = leaderboard;' Line Number: 479 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Change the learderbord. in learderbord name, score and star ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
do reshuffle the options were given
User prompt
fix all text that were not see .
User prompt
add learbord and more 5 logo. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Do big text of number that we get stars
User prompt
do big text of no.
User prompt
Give life. When wrong. The live lost. When all live lost your game over the game.
User prompt
do question text down to logo and logo con
User prompt
Please fix the bug: 'can't access property "fill", questionText.style is undefined' in or related to this line: 'questionText.style.fill = 0x000000;' Line Number: 324
User prompt
cange the colour to see the text. to question text down to logo
User prompt
change the text colour and big the text to see.
User prompt
big the text and side the text.
User prompt
remove hint.
User prompt
fix that romdom logo come to ask
User prompt
make it asset i give you logo to the game
Code edit (1 edits merged)
Please save this source code
User prompt
पहचानो लोगो! (Pehchano Logo!)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var OptionButton = Container.expand(function (text, isCorrect, index) {
var self = Container.call(this);
self.isCorrect = isCorrect;
self.isSelected = false;
self.buttonIndex = index;
var buttonBg = self.attachAsset('optionButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 48,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.setText = function (newText) {
buttonText.setText(newText);
};
self.showCorrect = function () {
buttonBg.destroy();
buttonBg = self.attachAsset('optionButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(buttonBg, 0);
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.easeOut
});
};
self.showWrong = function () {
buttonBg.destroy();
buttonBg = self.attachAsset('optionButtonWrong', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(buttonBg, 0);
tween(self, {
x: self.x + 10
}, {
duration: 50
});
tween(self, {
x: self.x - 10
}, {
duration: 50
});
tween(self, {
x: self.x
}, {
duration: 50
});
};
self.reset = function () {
self.isSelected = false;
buttonBg.destroy();
buttonBg = self.attachAsset('optionButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.addChildAt(buttonBg, 0);
self.scaleX = 1.0;
self.scaleY = 1.0;
};
self.down = function (x, y, obj) {
if (gameState !== 'playing') return;
if (self.isCorrect) {
self.showCorrect();
handleCorrectAnswer();
} else {
self.showWrong();
handleWrongAnswer();
}
};
return self;
});
var StarDisplay = Container.expand(function () {
var self = Container.call(this);
var starBg = self.attachAsset('starIcon', {
anchorX: 0.5,
anchorY: 0.5
});
var starText = new Text2('0', {
size: 72,
fill: 0x000000
});
starText.anchor.set(0.5, 0.5);
self.addChild(starText);
self.updateStars = function (count) {
starText.setText(count.toString());
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFF8E1
});
/****
* Game Code
****/
// Brand Logo Assets
// Game state variables
var gameState = 'playing';
var currentLevel = 1;
var currentQuestion = 0;
var score = 0;
var stars = storage.stars || 0;
var highScore = storage.highScore || 0;
var usedQuestions = [];
var lives = 3; // Initialize player lives
// Logo database
var logoDatabase = [
// Level 1 - Indian Brands
{
name: 'टाटा',
options: ['टाटा', 'रिलायंस', 'अडानी', 'बिड़ला'],
correct: 0,
fact: 'टाटा ग्रुप की स्थापना 1868 में जमशेदजी टाटा ने की थी।',
level: 1,
logoColor: 0x0066CC,
logoAssetId: 'tataLogo'
}, {
name: 'रिलायंस',
options: ['टाटा', 'रिलायंस', 'अडानी', 'बिड़ला'],
correct: 1,
fact: 'रिलायंस इंडस्ट्रीज भारत की सबसे बड़ी निजी कंपनी है।',
level: 1,
logoColor: 0xFF0000,
logoAssetId: 'relianceLogo'
}, {
name: 'बजाज',
options: ['हीरो', 'बजाज', 'टीवीएस', 'महिंद्रा'],
correct: 1,
fact: 'बजाज ऑटो भारत की प्रमुख मोटरसाइकिल निर्माता कंपनी है।',
level: 1,
logoColor: 0x0066FF,
logoAssetId: 'bajajLogo'
},
// Level 2 - International Brands
{
name: 'कोका-कोला',
options: ['पेप्सी', 'कोका-कोला', 'स्प्राइट', 'फैंटा'],
correct: 1,
fact: 'कोका-कोला दुनिया का सबसे प्रसिद्ध पेय पदार्थ ब्रांड है।',
level: 2,
logoColor: 0xDC143C,
logoAssetId: 'cocaColaLogo'
}, {
name: 'मैकडॉनल्ड्स',
options: ['केएफसी', 'मैकडॉनल्ड्स', 'बर्गर किंग', 'सबवे'],
correct: 1,
fact: 'मैकडॉनल्ड्स दुनिया की सबसे बड़ी फास्ट फूड चेन है।',
level: 2,
logoColor: 0xFFD700,
logoAssetId: 'mcdonaldsLogo'
}, {
name: 'गूगल',
options: ['माइक्रोसॉफ्ट', 'गूगल', 'एप्पल', 'अमेज़न'],
correct: 1,
fact: 'गूगल दुनिया का सबसे बड़ा सर्च इंजन है।',
level: 2,
logoColor: 0x4285f4,
logoAssetId: 'googleLogo'
}, {
name: 'अमेज़न',
options: ['ईबे', 'अमेज़न', 'अलीबाबा', 'शॉपिफाई'],
correct: 1,
fact: 'अमेज़न दुनिया की सबसे बड़ी ई-कॉमर्स कंपनी है।',
level: 2,
logoColor: 0xFF9900,
logoAssetId: 'amazonLogo'
}, {
name: 'इंफोसिस',
options: ['टीसीएस', 'इंफोसिस', 'विप्रो', 'एचसीएल'],
correct: 1,
fact: 'इंफोसिस भारत की प्रमुख आईटी कंपनी है।',
level: 1,
logoColor: 0x0066CC,
logoAssetId: 'infosysLogo'
}, {
name: 'फ्लिपकार्ट',
options: ['अमेज़न', 'फ्लिपकार्ट', 'स्नैपडील', 'मिंत्रा'],
correct: 1,
fact: 'फ्लिपकार्ट भारत की सबसे बड़ी ई-कॉमर्स कंपनी है।',
level: 1,
logoColor: 0xF7971E,
logoAssetId: 'flipkartLogo'
}, {
name: 'ज़ोमैटो',
options: ['स्विगी', 'ज़ोमैटो', 'उबर ईट्स', 'फूडपांडा'],
correct: 1,
fact: 'ज़ोमैटो भारत की प्रमुख फूड डिलीवरी कंपनी है।',
level: 1,
logoColor: 0xE23744,
logoAssetId: 'zomatoLogo'
}, {
name: 'ओला',
options: ['उबर', 'ओला', 'मेरु', 'लिफ्ट'],
correct: 1,
fact: 'ओला भारत की सबसे बड़ी राइड-शेयरिंग कंपनी है।',
level: 1,
logoColor: 0x000000,
logoAssetId: 'olaLogo'
}];
// UI Elements
var logoContainer;
var logoDisplay;
var optionButtons = [];
var starDisplay;
var scoreText;
var levelText;
var questionText;
var factText;
// Background
var background = game.attachAsset('backgroundPattern', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Logo container
logoContainer = game.attachAsset('logoContainer', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 400
});
// Logo display will be created dynamically in loadQuestion()
logoDisplay = null;
// Score display
scoreText = new Text2('स्कोर: ' + score, {
size: 48,
fill: 0xFF6B6B
});
scoreText.anchor.set(0.5, 0);
scoreText.x = 2048 / 2;
scoreText.y = 50;
game.addChild(scoreText);
// High score display
var highScoreText = new Text2('उच्च स्कोर: ' + highScore, {
size: 42,
fill: 0xFFD700
});
highScoreText.anchor.set(0.5, 0);
highScoreText.x = 2048 / 2;
highScoreText.y = 110;
game.addChild(highScoreText);
// Level display
levelText = new Text2('स्तर: ' + currentLevel, {
size: 42,
fill: 0x4ECDC4
});
levelText.anchor.set(0, 0);
levelText.x = 150;
levelText.y = 50;
game.addChild(levelText);
// Stars display
starDisplay = new StarDisplay();
starDisplay.x = 2048 - 150;
starDisplay.y = 80;
starDisplay.updateStars(stars);
game.addChild(starDisplay);
// Lives display
var livesText = new Text2('जीवन: ' + lives, {
size: 42,
fill: 0xFF0000
});
livesText.anchor.set(0.5, 0);
livesText.x = 2048 / 2;
livesText.y = 170;
game.addChild(livesText);
// Question text
questionText = new Text2('लोगो पहचानें:', {
size: 72,
fill: 0x000000
});
questionText.anchor.set(0.5, 0);
questionText.x = 2048 / 2;
questionText.y = 700;
game.addChild(questionText);
// Create option buttons
for (var i = 0; i < 4; i++) {
var button = new OptionButton('विकल्प ' + (i + 1), false, i);
button.x = 2048 / 2;
button.y = 900 + i * 120;
optionButtons.push(button);
game.addChild(button);
}
// Fact display text
factText = new Text2('', {
size: 36,
fill: 0x7B68EE
});
factText.anchor.set(0.5, 0);
factText.x = 2048 / 2;
factText.y = 1500;
game.addChild(factText);
// Feedback text
var feedbackText = new Text2('', {
size: 60,
fill: 0x00D300
});
feedbackText.anchor.set(0.5, 0.5);
feedbackText.x = 2048 / 2;
feedbackText.y = 1700;
game.addChild(feedbackText);
// Utility function to shuffle array
function shuffleArray(array) {
var shuffled = array.slice(); // Create a copy
for (var i = shuffled.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = shuffled[i];
shuffled[i] = shuffled[j];
shuffled[j] = temp;
}
return shuffled;
}
// Game functions
function loadQuestion() {
if (usedQuestions.length >= logoDatabase.length) {
// Game completed
showGameComplete();
return;
}
// Get available questions (not used yet)
var availableQuestions = [];
for (var i = 0; i < logoDatabase.length; i++) {
if (usedQuestions.indexOf(i) === -1) {
availableQuestions.push(i);
}
}
// Select random question from available ones
var randomIndex = Math.floor(Math.random() * availableQuestions.length);
currentQuestion = availableQuestions[randomIndex];
usedQuestions.push(currentQuestion);
var question = logoDatabase[currentQuestion];
// Remove old logo display
if (logoDisplay) {
logoDisplay.destroy();
}
// Create new logo display with actual brand logo
logoDisplay = LK.getAsset(question.logoAssetId, {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 400
});
game.addChild(logoDisplay);
// Update question text
questionText.setText('यह कौन सा ब्रांड है?');
questionText.tint = 0x000000;
questionText.y = 700;
// Shuffle options while keeping track of correct answer
var originalOptions = question.options.slice(); // Create copy
var correctAnswer = originalOptions[question.correct];
var shuffledOptions = shuffleArray(originalOptions);
var newCorrectIndex = shuffledOptions.indexOf(correctAnswer);
// Update option buttons
for (var i = 0; i < 4; i++) {
optionButtons[i].setText(shuffledOptions[i]);
optionButtons[i].isCorrect = i === newCorrectIndex;
optionButtons[i].reset();
}
// Clear fact text
factText.setText('');
feedbackText.setText('');
// Update level if needed
if (question.level !== currentLevel) {
currentLevel = question.level;
levelText.setText('स्तर: ' + currentLevel);
}
gameState = 'playing';
}
function handleCorrectAnswer() {
gameState = 'answered';
// Play correct sound
LK.getSound('correctSound').play();
// Update score
score += 10;
LK.setScore(score);
scoreText.setText('स्कोर: ' + score);
// Check and update high score
if (score > highScore) {
highScore = score;
storage.highScore = highScore;
highScoreText.setText('उच्च स्कोर: ' + highScore);
}
// Award stars
stars += 1;
storage.stars = stars;
starDisplay.updateStars(stars);
// Show feedback
var praises = ['सही जवाब!', 'बहुत बढ़िया!', 'शाबाश!', 'उत्कृष्ट!'];
var randomPraise = praises[Math.floor(Math.random() * praises.length)];
feedbackText.setText(randomPraise);
feedbackText.tint = 0x4CAF50;
// Show fact
var question = logoDatabase[currentQuestion];
factText.setText(question.fact);
// Create confetti effect
createConfetti();
// Move to next question after delay
LK.setTimeout(function () {
loadQuestion();
}, 3000);
}
function handleWrongAnswer() {
// Play wrong sound
LK.getSound('wrongSound').play();
// Show feedback
feedbackText.setText('फिर से कोशिश करें!');
feedbackText.tint = 0xf44336;
// Decrease life
lives -= 1;
livesText.setText('जीवन: ' + lives);
// Check for game over
if (lives <= 0) {
gameState = 'gameover';
LK.showGameOver();
return;
}
// Clear feedback after delay
LK.setTimeout(function () {
feedbackText.setText('');
}, 1500);
}
function createConfetti() {
// Simple confetti effect using colored rectangles
for (var i = 0; i < 10; i++) {
var confetti = LK.getAsset('starIcon', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + (Math.random() - 0.5) * 400,
y: 400,
scaleX: 0.3,
scaleY: 0.3
});
var colors = [0xFF6B6B, 0x4ECDC4, 0x45B7D1, 0xFFA07A, 0x98D8C8];
confetti.tint = colors[Math.floor(Math.random() * colors.length)];
game.addChild(confetti);
// Animate confetti
tween(confetti, {
y: 800 + Math.random() * 200,
x: confetti.x + (Math.random() - 0.5) * 300,
rotation: Math.random() * Math.PI * 2,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
confetti.destroy();
}
});
}
}
function showGameComplete() {
gameState = 'complete';
// Show completion message
var completionText = new Text2('बधाई हो! आपने सभी लोगो पहचान लिए!', {
size: 56,
fill: 0x00C853
});
completionText.anchor.set(0.5, 0.5);
completionText.x = 2048 / 2;
completionText.y = 1200;
game.addChild(completionText);
// Show final score
var finalScoreText = new Text2('अंतिम स्कोर: ' + score, {
size: 48,
fill: 0xFF1744
});
finalScoreText.anchor.set(0.5, 0.5);
finalScoreText.x = 2048 / 2;
finalScoreText.y = 1300;
game.addChild(finalScoreText);
// Reset lives
lives = 3;
livesText.setText('जीवन: ' + lives);
// Show you win after delay
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
}
// Initialize first question
loadQuestion();
// Play background music
LK.playMusic('backgroundMusic');
// Game update loop
game.update = function () {
// Update any animations or game logic here
if (gameState === 'playing') {
// Game is active, handle any continuous updates
}
}; ===================================================================
--- original.js
+++ change.js
@@ -120,10 +120,10 @@
/****
* Game Code
****/
-// Game state variables
// Brand Logo Assets
+// Game state variables
var gameState = 'playing';
var currentLevel = 1;
var currentQuestion = 0;
var score = 0;
@@ -326,8 +326,19 @@
feedbackText.anchor.set(0.5, 0.5);
feedbackText.x = 2048 / 2;
feedbackText.y = 1700;
game.addChild(feedbackText);
+// Utility function to shuffle array
+function shuffleArray(array) {
+ var shuffled = array.slice(); // Create a copy
+ for (var i = shuffled.length - 1; i > 0; i--) {
+ var j = Math.floor(Math.random() * (i + 1));
+ var temp = shuffled[i];
+ shuffled[i] = shuffled[j];
+ shuffled[j] = temp;
+ }
+ return shuffled;
+}
// Game functions
function loadQuestion() {
if (usedQuestions.length >= logoDatabase.length) {
// Game completed
@@ -361,12 +372,17 @@
// Update question text
questionText.setText('यह कौन सा ब्रांड है?');
questionText.tint = 0x000000;
questionText.y = 700;
+ // Shuffle options while keeping track of correct answer
+ var originalOptions = question.options.slice(); // Create copy
+ var correctAnswer = originalOptions[question.correct];
+ var shuffledOptions = shuffleArray(originalOptions);
+ var newCorrectIndex = shuffledOptions.indexOf(correctAnswer);
// Update option buttons
for (var i = 0; i < 4; i++) {
- optionButtons[i].setText(question.options[i]);
- optionButtons[i].isCorrect = i === question.correct;
+ optionButtons[i].setText(shuffledOptions[i]);
+ optionButtons[i].isCorrect = i === newCorrectIndex;
optionButtons[i].reset();
}
// Clear fact text
factText.setText('');