User prompt
There are 3 cards in the game. The number of cards increases with each level. In the final, there are 9 cards. If I choose the right one, I win.
User prompt
undo action
User prompt
I accidentally deleted it, make it final
User prompt
move the cards to the right of the screen
User prompt
Please fix the bug: 'actualSpacing is not defined' in or related to this line: 'card.x = startX + col * actualSpacing;' Line Number: 127
User prompt
center cards on screen
User prompt
Separate the cards from each other so they don't stick together
User prompt
open the cards
User prompt
increase card sizes
User prompt
The cards should be a little closer to the side, 3 rows up, 6 rows up
User prompt
be chosen with a stick in the game
User prompt
have a background in the game
User prompt
let there be music in the game
User prompt
The correct card is worth 1000 points.
User prompt
May the cars increase in every section
User prompt
At the beginning of the game, show me the card and deal 3 cards on the ground. Shuffle them slowly. If I find the correct card, I win. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
pacman
Code edit (1 edits merged)
Please save this source code
User prompt
Beauty Contest Judge
Initial prompt
Miss Mister World '96 tarzı oyun yapacaksın resimlerini benim seçeceğim yükleyeceğim
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var ContestantCard = Container.expand(function (contestantData) {
var self = Container.call(this);
self.contestantData = contestantData;
self.isSelected = false;
self.currentRating = 0;
// Card background
var cardBg = self.attachAsset('contestantCard', {
anchorX: 0.5,
anchorY: 0.5
});
// Photo placeholder
var photo = self.attachAsset('contestantPhoto', {
anchorX: 0.5,
anchorY: 0.5,
y: -20
});
// Contestant name
var nameText = new Text2(contestantData.name, {
size: 24,
fill: 0x333333
});
nameText.anchor.set(0.5, 0.5);
nameText.x = 0;
nameText.y = 120;
self.addChild(nameText);
// Rating display
var ratingText = new Text2('Rating: 0', {
size: 20,
fill: 0x666666
});
ratingText.anchor.set(0.5, 0.5);
ratingText.x = 0;
ratingText.y = 150;
self.addChild(ratingText);
// Rating buttons
var ratingButtons = [];
for (var i = 1; i <= 5; i++) {
var button = self.attachAsset('ratingButton', {
anchorX: 0.5,
anchorY: 0.5,
x: (i - 3) * 60,
y: 180
});
var buttonText = new Text2(i.toString(), {
size: 18,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
button.addChild(buttonText);
button.rating = i;
ratingButtons.push(button);
}
self.setRating = function (rating) {
self.currentRating = rating;
ratingText.setText('Rating: ' + rating);
// Update button colors
for (var i = 0; i < ratingButtons.length; i++) {
var button = ratingButtons[i];
if (button.rating <= rating) {
button.tint = 0xf39c12;
} else {
button.tint = 0x4a90e2;
}
}
};
self.setSelected = function (selected) {
self.isSelected = selected;
if (selected) {
cardBg.tint = 0xf1c40f;
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeOut
});
} else {
cardBg.tint = 0xffffff;
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 300,
easing: tween.easeOut
});
}
};
self.down = function (x, y, obj) {
// Check if clicked on rating button
for (var i = 0; i < ratingButtons.length; i++) {
var button = ratingButtons[i];
var buttonPos = button.getBounds();
var globalPos = self.toGlobal({
x: x,
y: y
});
if (globalPos.x >= buttonPos.x && globalPos.x <= buttonPos.x + buttonPos.width && globalPos.y >= buttonPos.y && globalPos.y <= buttonPos.y + buttonPos.height) {
self.setRating(button.rating);
LK.getSound('select').play();
return;
}
}
// Otherwise select/deselect contestant
self.setSelected(!self.isSelected);
LK.getSound('select').play();
};
return self;
});
var JudgePanel = Container.expand(function () {
var self = Container.call(this);
var panelBg = self.attachAsset('judgePanel', {
anchorX: 0.5,
anchorY: 0.5
});
var titleText = new Text2('Beauty Contest Judge', {
size: 36,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -60;
self.addChild(titleText);
var scoreText = new Text2('Score: 0', {
size: 24,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0.5);
scoreText.x = -300;
scoreText.y = -20;
self.addChild(scoreText);
var roundText = new Text2('Round: 1', {
size: 24,
fill: 0xFFFFFF
});
roundText.anchor.set(0.5, 0.5);
roundText.x = 0;
roundText.y = -20;
self.addChild(roundText);
var categoryText = new Text2('Evening Wear', {
size: 24,
fill: 0xFFFFFF
});
categoryText.anchor.set(0.5, 0.5);
categoryText.x = 300;
categoryText.y = -20;
self.addChild(categoryText);
var nextButton = self.attachAsset('nextRoundButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 40
});
var nextButtonText = new Text2('Next Round', {
size: 20,
fill: 0xFFFFFF
});
nextButtonText.anchor.set(0.5, 0.5);
nextButton.addChild(nextButtonText);
self.updateScore = function (score) {
scoreText.setText('Score: ' + score);
};
self.updateRound = function (round) {
roundText.setText('Round: ' + round);
};
self.updateCategory = function (category) {
categoryText.setText(category);
};
self.down = function (x, y, obj) {
var buttonPos = nextButton.getBounds();
var globalPos = self.toGlobal({
x: x,
y: y
});
if (globalPos.x >= buttonPos.x && globalPos.x <= buttonPos.x + buttonPos.width && globalPos.y >= buttonPos.y && globalPos.y <= buttonPos.y + buttonPos.height) {
nextRound();
LK.getSound('nextRound').play();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
var contestants = [{
name: 'Contestant 1',
id: 1
}, {
name: 'Contestant 2',
id: 2
}, {
name: 'Contestant 3',
id: 3
}, {
name: 'Contestant 4',
id: 4
}, {
name: 'Contestant 5',
id: 5
}, {
name: 'Contestant 6',
id: 6
}];
var categories = ['Evening Wear', 'Swimsuit', 'Talent', 'Interview', 'Final'];
var currentRound = 1;
var currentCategory = 0;
var judgeScore = storage.judgeScore || 0;
var contestantCards = [];
// Create judge panel
var judgePanel = game.addChild(new JudgePanel());
judgePanel.x = 1024;
judgePanel.y = 150;
// Create contestant cards
function createContestantCards() {
// Clear existing cards
for (var i = 0; i < contestantCards.length; i++) {
contestantCards[i].destroy();
}
contestantCards = [];
var startX = 350;
var startY = 500;
var spacing = 350;
for (var i = 0; i < contestants.length; i++) {
var card = game.addChild(new ContestantCard(contestants[i]));
card.x = startX + i % 3 * spacing;
card.y = startY + Math.floor(i / 3) * 500;
contestantCards.push(card);
}
}
function nextRound() {
// Calculate round score based on ratings
var roundScore = 0;
var selectedCount = 0;
for (var i = 0; i < contestantCards.length; i++) {
var card = contestantCards[i];
if (card.isSelected) {
selectedCount++;
roundScore += card.currentRating * 10;
}
roundScore += card.currentRating * 5;
}
// Bonus for selecting the right number of contestants
var expectedSelections = Math.max(1, Math.floor(contestants.length / 2));
if (selectedCount === expectedSelections) {
roundScore += 50;
}
judgeScore += roundScore;
LK.setScore(judgeScore);
storage.judgeScore = judgeScore;
// Eliminate non-selected contestants
var newContestants = [];
for (var i = 0; i < contestantCards.length; i++) {
var card = contestantCards[i];
if (card.isSelected || contestants.length <= 3) {
newContestants.push(card.contestantData);
}
}
contestants = newContestants;
// Advance to next round
currentRound++;
currentCategory = (currentCategory + 1) % categories.length;
// Check if final round
if (contestants.length === 1) {
LK.getSound('winner').play();
LK.effects.flashScreen(0xf1c40f, 1000);
// Add winner bonus
judgeScore += 100;
LK.setScore(judgeScore);
storage.judgeScore = judgeScore;
LK.showYouWin();
return;
}
// Update UI
judgePanel.updateScore(judgeScore);
judgePanel.updateRound(currentRound);
judgePanel.updateCategory(categories[currentCategory]);
// Recreate cards for remaining contestants
createContestantCards();
// Flash effect for round transition
LK.effects.flashScreen(0x3498db, 500);
}
// Initialize game
createContestantCards();
judgePanel.updateScore(judgeScore);
judgePanel.updateRound(currentRound);
judgePanel.updateCategory(categories[currentCategory]);
// Update score display
var scoreDisplay = new Text2('Score: ' + judgeScore, {
size: 32,
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
game.update = function () {
scoreDisplay.setText('Score: ' + LK.getScore());
// Auto-advance if only one contestant remains
if (contestants.length === 1 && currentRound > 1) {
if (LK.ticks % 180 === 0) {
// Wait 3 seconds
nextRound();
}
}
};
// Game over condition - if no progress after many rounds
var maxRounds = 10;
if (currentRound > maxRounds) {
LK.showGameOver();
} ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,324 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var ContestantCard = Container.expand(function (contestantData) {
+ var self = Container.call(this);
+ self.contestantData = contestantData;
+ self.isSelected = false;
+ self.currentRating = 0;
+ // Card background
+ var cardBg = self.attachAsset('contestantCard', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Photo placeholder
+ var photo = self.attachAsset('contestantPhoto', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -20
+ });
+ // Contestant name
+ var nameText = new Text2(contestantData.name, {
+ size: 24,
+ fill: 0x333333
+ });
+ nameText.anchor.set(0.5, 0.5);
+ nameText.x = 0;
+ nameText.y = 120;
+ self.addChild(nameText);
+ // Rating display
+ var ratingText = new Text2('Rating: 0', {
+ size: 20,
+ fill: 0x666666
+ });
+ ratingText.anchor.set(0.5, 0.5);
+ ratingText.x = 0;
+ ratingText.y = 150;
+ self.addChild(ratingText);
+ // Rating buttons
+ var ratingButtons = [];
+ for (var i = 1; i <= 5; i++) {
+ var button = self.attachAsset('ratingButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: (i - 3) * 60,
+ y: 180
+ });
+ var buttonText = new Text2(i.toString(), {
+ size: 18,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ button.addChild(buttonText);
+ button.rating = i;
+ ratingButtons.push(button);
+ }
+ self.setRating = function (rating) {
+ self.currentRating = rating;
+ ratingText.setText('Rating: ' + rating);
+ // Update button colors
+ for (var i = 0; i < ratingButtons.length; i++) {
+ var button = ratingButtons[i];
+ if (button.rating <= rating) {
+ button.tint = 0xf39c12;
+ } else {
+ button.tint = 0x4a90e2;
+ }
+ }
+ };
+ self.setSelected = function (selected) {
+ self.isSelected = selected;
+ if (selected) {
+ cardBg.tint = 0xf1c40f;
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ } else {
+ cardBg.tint = 0xffffff;
+ tween(self, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }
+ };
+ self.down = function (x, y, obj) {
+ // Check if clicked on rating button
+ for (var i = 0; i < ratingButtons.length; i++) {
+ var button = ratingButtons[i];
+ var buttonPos = button.getBounds();
+ var globalPos = self.toGlobal({
+ x: x,
+ y: y
+ });
+ if (globalPos.x >= buttonPos.x && globalPos.x <= buttonPos.x + buttonPos.width && globalPos.y >= buttonPos.y && globalPos.y <= buttonPos.y + buttonPos.height) {
+ self.setRating(button.rating);
+ LK.getSound('select').play();
+ return;
+ }
+ }
+ // Otherwise select/deselect contestant
+ self.setSelected(!self.isSelected);
+ LK.getSound('select').play();
+ };
+ return self;
+});
+var JudgePanel = Container.expand(function () {
+ var self = Container.call(this);
+ var panelBg = self.attachAsset('judgePanel', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var titleText = new Text2('Beauty Contest Judge', {
+ size: 36,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 0;
+ titleText.y = -60;
+ self.addChild(titleText);
+ var scoreText = new Text2('Score: 0', {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ scoreText.anchor.set(0.5, 0.5);
+ scoreText.x = -300;
+ scoreText.y = -20;
+ self.addChild(scoreText);
+ var roundText = new Text2('Round: 1', {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ roundText.anchor.set(0.5, 0.5);
+ roundText.x = 0;
+ roundText.y = -20;
+ self.addChild(roundText);
+ var categoryText = new Text2('Evening Wear', {
+ size: 24,
+ fill: 0xFFFFFF
+ });
+ categoryText.anchor.set(0.5, 0.5);
+ categoryText.x = 300;
+ categoryText.y = -20;
+ self.addChild(categoryText);
+ var nextButton = self.attachAsset('nextRoundButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: 40
+ });
+ var nextButtonText = new Text2('Next Round', {
+ size: 20,
+ fill: 0xFFFFFF
+ });
+ nextButtonText.anchor.set(0.5, 0.5);
+ nextButton.addChild(nextButtonText);
+ self.updateScore = function (score) {
+ scoreText.setText('Score: ' + score);
+ };
+ self.updateRound = function (round) {
+ roundText.setText('Round: ' + round);
+ };
+ self.updateCategory = function (category) {
+ categoryText.setText(category);
+ };
+ self.down = function (x, y, obj) {
+ var buttonPos = nextButton.getBounds();
+ var globalPos = self.toGlobal({
+ x: x,
+ y: y
+ });
+ if (globalPos.x >= buttonPos.x && globalPos.x <= buttonPos.x + buttonPos.width && globalPos.y >= buttonPos.y && globalPos.y <= buttonPos.y + buttonPos.height) {
+ nextRound();
+ LK.getSound('nextRound').play();
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2c3e50
+});
+
+/****
+* Game Code
+****/
+var contestants = [{
+ name: 'Contestant 1',
+ id: 1
+}, {
+ name: 'Contestant 2',
+ id: 2
+}, {
+ name: 'Contestant 3',
+ id: 3
+}, {
+ name: 'Contestant 4',
+ id: 4
+}, {
+ name: 'Contestant 5',
+ id: 5
+}, {
+ name: 'Contestant 6',
+ id: 6
+}];
+var categories = ['Evening Wear', 'Swimsuit', 'Talent', 'Interview', 'Final'];
+var currentRound = 1;
+var currentCategory = 0;
+var judgeScore = storage.judgeScore || 0;
+var contestantCards = [];
+// Create judge panel
+var judgePanel = game.addChild(new JudgePanel());
+judgePanel.x = 1024;
+judgePanel.y = 150;
+// Create contestant cards
+function createContestantCards() {
+ // Clear existing cards
+ for (var i = 0; i < contestantCards.length; i++) {
+ contestantCards[i].destroy();
+ }
+ contestantCards = [];
+ var startX = 350;
+ var startY = 500;
+ var spacing = 350;
+ for (var i = 0; i < contestants.length; i++) {
+ var card = game.addChild(new ContestantCard(contestants[i]));
+ card.x = startX + i % 3 * spacing;
+ card.y = startY + Math.floor(i / 3) * 500;
+ contestantCards.push(card);
+ }
+}
+function nextRound() {
+ // Calculate round score based on ratings
+ var roundScore = 0;
+ var selectedCount = 0;
+ for (var i = 0; i < contestantCards.length; i++) {
+ var card = contestantCards[i];
+ if (card.isSelected) {
+ selectedCount++;
+ roundScore += card.currentRating * 10;
+ }
+ roundScore += card.currentRating * 5;
+ }
+ // Bonus for selecting the right number of contestants
+ var expectedSelections = Math.max(1, Math.floor(contestants.length / 2));
+ if (selectedCount === expectedSelections) {
+ roundScore += 50;
+ }
+ judgeScore += roundScore;
+ LK.setScore(judgeScore);
+ storage.judgeScore = judgeScore;
+ // Eliminate non-selected contestants
+ var newContestants = [];
+ for (var i = 0; i < contestantCards.length; i++) {
+ var card = contestantCards[i];
+ if (card.isSelected || contestants.length <= 3) {
+ newContestants.push(card.contestantData);
+ }
+ }
+ contestants = newContestants;
+ // Advance to next round
+ currentRound++;
+ currentCategory = (currentCategory + 1) % categories.length;
+ // Check if final round
+ if (contestants.length === 1) {
+ LK.getSound('winner').play();
+ LK.effects.flashScreen(0xf1c40f, 1000);
+ // Add winner bonus
+ judgeScore += 100;
+ LK.setScore(judgeScore);
+ storage.judgeScore = judgeScore;
+ LK.showYouWin();
+ return;
+ }
+ // Update UI
+ judgePanel.updateScore(judgeScore);
+ judgePanel.updateRound(currentRound);
+ judgePanel.updateCategory(categories[currentCategory]);
+ // Recreate cards for remaining contestants
+ createContestantCards();
+ // Flash effect for round transition
+ LK.effects.flashScreen(0x3498db, 500);
+}
+// Initialize game
+createContestantCards();
+judgePanel.updateScore(judgeScore);
+judgePanel.updateRound(currentRound);
+judgePanel.updateCategory(categories[currentCategory]);
+// Update score display
+var scoreDisplay = new Text2('Score: ' + judgeScore, {
+ size: 32,
+ fill: 0xFFFFFF
+});
+scoreDisplay.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreDisplay);
+game.update = function () {
+ scoreDisplay.setText('Score: ' + LK.getScore());
+ // Auto-advance if only one contestant remains
+ if (contestants.length === 1 && currentRound > 1) {
+ if (LK.ticks % 180 === 0) {
+ // Wait 3 seconds
+ nextRound();
+ }
+ }
+};
+// Game over condition - if no progress after many rounds
+var maxRounds = 10;
+if (currentRound > maxRounds) {
+ LK.showGameOver();
+}
\ No newline at end of file