User prompt
Move up coins caught counter by 333 unit
User prompt
Change ccb clicker game background wallpapper to ccw asset
User prompt
Change Ccb clicker game mode to this: golden coins falls from the top of the screen and player try to cath them in a pot atvthe bottom of the screen moving in the left and right sides. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Ccb clicker game mode has no level selector, so delete them
User prompt
You replaced the wromg game mode
User prompt
Coin catcher mod should be a different game but not a car game. Change it to it: gold coins falling from the top of the screen and player try to collect them in in a pot or a hat in the bottom of the screen
User prompt
Scale up MW SIZE BY 1.4 IN THE CARD GAME MOD BUT NOT IN THE LEVEL SELECTOR ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Remove finder text from the menu and change his button to CHB asset
User prompt
Remove clicker text from the menu and change his button to CCB asset
User prompt
Swap the finder and clicker buttons place
User prompt
Remove memory card game text from the menu and change his button to MCGB asset
User prompt
Scale up the mw background size in the card game by 1.2
User prompt
Also set MW TO LEVEL SELECTOR AND MEMORY CARD GAME BACKGROUND
User prompt
SET CENTER OF THE MW TO THE CENTER OF THE SCREEN
User prompt
Set MW as menu background
User prompt
Don’t make all the threeLeafClover elements appear at the same time. Instead, make them appear randomly once per second in different places on the screen. Also, don’t just teleport them to the position—make them grow from zero pixels and scale up to their actual image size.” ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Increase threeLeafClover to 5x to fill the whole scret
User prompt
Add grass background to the asset list. Set grass asset to finder game mode background
User prompt
Remove st. Patrick memory card game title text from finder game mode
User prompt
Remove title from the finder game mode
User prompt
Dont load card game level selector if finder mode is selected
User prompt
Add a new game mode to the game: FINDER . IF the player selected this mode you should load a lot of 3 leaf clovers and one pice of 4 leafes clover what player searh click on it and increase counter number
User prompt
Do this last task
User prompt
Move confirm button down by 123 units
User prompt
Confirm button should be under the lowest game mode button
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
bestScore: 0,
level: 1
});
/****
* Classes
****/
var Card = Container.expand(function (cardId, pairId) {
var self = Container.call(this);
self.cardId = cardId;
self.pairId = pairId;
self.isFlipped = false;
self.isMatched = false;
// Card back (shown when not flipped)
var cardBack = self.attachAsset('cardBack', {
anchorX: 0.5,
anchorY: 0.5
});
// Card front (the actual pattern/color)
var cardFront = self.attachAsset('pair' + pairId, {
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
if (pairId === 'J') {
cardFront = self.attachAsset('pairJ', {
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
}
if (pairId === 'K') {
cardFront = self.attachAsset('pairK', {
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
}
if (pairId === 'L') {
cardFront = self.attachAsset('pairL', {
anchorX: 0.5,
anchorY: 0.5,
visible: false
});
}
self.back = cardBack;
self.front = cardFront;
// Method to flip the card
self.flip = function () {
if (self.isMatched || self.isFlipped) {
return false;
}
LK.getSound('flip').play();
self.isFlipped = true;
// Animate the flip
tween(cardBack, {
scaleX: 0
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
cardBack.visible = false;
cardFront.visible = true;
tween(cardFront, {
scaleX: 1
}, {
duration: 150,
easing: tween.easeOut
});
}
});
return true;
};
// Method to flip back
self.flipBack = function () {
if (self.isMatched || !self.isFlipped) {
return;
}
self.isFlipped = false;
tween(cardFront, {
scaleX: 0
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
cardFront.visible = false;
cardBack.visible = true;
tween(cardBack, {
scaleX: 1
}, {
duration: 150,
easing: tween.easeOut
});
}
});
};
// Method to mark card as matched
self.setMatched = function () {
self.isMatched = true;
// Create a matched effect
var matchEffect = self.attachAsset('cardMatch', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
tween(matchEffect, {
alpha: 0.7
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
matchEffect.destroy(); // Remove the matched effect after animation
self.removeChild(matchEffect); // Ensure the effect is removed from the display list
}
});
};
// Handle card selection
self.down = function (x, y, obj) {
if (!gameActive || processingMatch || self.isMatched) {
return;
}
var flipped = self.flip();
if (flipped) {
checkForMatch(self);
}
};
return self;
});
var Clover = Container.expand(function (isFourLeaf) {
var self = Container.call(this);
self.isFourLeaf = isFourLeaf;
var cloverAsset = self.attachAsset(isFourLeaf ? 'fourLeafClover' : 'threeLeafClover', {
anchorX: 0.5,
anchorY: 0.5
});
self.down = function (x, y, obj) {
if (!finderGameActive) {
return;
}
if (self.isFourLeaf) {
finderScore++;
finderCounterText.setText('Found: ' + finderScore);
LK.getSound('match').play();
// Remove the four leaf clover after found
self.destroy();
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Updated to use the latest LK engine default background color
});
/****
* Game Code
****/
// Game state variables
var cards = [];
var gridWidth = 4;
var gridHeight = 3;
var cardWidth = 180;
var cardHeight = 250;
var cardSpacing = 200; // Increased vertical spacing between cards
var flippedCards = [];
var gameActive = false;
var processingMatch = false;
var moves = 0;
var pairsFound = 0;
var level = 1;
var totalPairs = gridWidth * gridHeight / 2;
var gameStartTime;
// UI Elements
var titleText = new Text2("St. Patrick's Day Match Game", {
size: 80,
fill: 0xFFA500,
fontWeight: 'bolder'
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 50;
var movesText = new Text2('Moves: 0', {
size: 60,
fill: 0xFFFFFF
});
movesText.anchor.set(0, 0);
LK.gui.topLeft.addChild(movesText);
movesText.x = 120;
movesText.y = 150;
movesText.visible = false;
var levelText = new Text2('Level: ' + level, {
size: 60,
fill: 0xFFFFFF
});
levelText.anchor.set(1, 0);
LK.gui.topRight.addChild(levelText);
levelText.x = -120;
levelText.y = 150;
levelText.visible = false;
var timerText = new Text2('Time: 0s', {
size: 60,
fill: 0xFFFFFF
});
timerText.anchor.set(0.5, 0);
LK.gui.top.addChild(timerText);
timerText.y = 150;
timerText.visible = false;
// Mode Selector Menu
var modeMenu = new Container();
var mwBackground = modeMenu.attachAsset('MW', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
scaleX: 2048 / 100,
scaleY: 2732 / 100
});
game.addChild(modeMenu);
// Game selector title
var modeTitle = new Text2("Select Game", {
size: 80,
fill: 0xFFA500,
fontWeight: 'bolder'
});
modeTitle.anchor.set(0.5, 0);
modeMenu.addChild(modeTitle);
modeTitle.x = 2048 / 2;
modeTitle.y = 300;
// Game selector buttons
var games = ['Memory Card Game', 'Finder', 'Clicker'];
var modeButtons = [];
var modeButtonY = 2732 / 2 - 300;
var modeButtonVerticalSpacing = 350;
var modeStartX = 2048 / 2;
var selectedMode = 'Memory Card Game';
var finderGameActive = false;
var finderScore = 0;
var finderCounterText;
var finderSpawnInterval;
var finderCloversSpawned = 0;
var finderTotalCloversToSpawn = 30;
for (var modeIdx = 0; modeIdx < games.length; modeIdx++) {
var modeName = games[modeIdx];
var modeBtn = new Container();
var modeBtnBg = modeBtn.attachAsset('cardMatch', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.9,
scaleY: 0.75
});
var modeBtnText = new Text2(modeName, {
size: 50,
fill: 0xFFFFFF
});
modeBtnText.anchor.set(0.5, 0.5);
modeBtnText.x = 0;
modeBtnText.y = 0;
modeBtn.addChild(modeBtnText);
modeBtn.modeName = modeName;
modeBtn.x = modeStartX;
modeBtn.y = modeButtonY + modeIdx * modeButtonVerticalSpacing;
modeMenu.addChild(modeBtn);
modeButtons.push(modeBtn);
modeBtn.down = function (btnMode) {
return function (x, y, obj) {
selectedMode = btnMode;
// Update visual feedback for selected mode
for (var updateModeBtn = 0; updateModeBtn < modeButtons.length; updateModeBtn++) {
var modeBtnBgChild = modeButtons[updateModeBtn].children[0];
if (modeButtons[updateModeBtn].modeName === btnMode) {
tween(modeBtnBgChild, {
tint: 0xFFCC00
}, {
duration: 300,
easing: tween.easeOut
});
} else {
tween(modeBtnBgChild, {
tint: 0xFFFFFF
}, {
duration: 300,
easing: tween.easeOut
});
}
}
};
}(modeName);
}
// Confirm mode button
var confirmModeBtn = new Container();
var confirmModeBtnBg = confirmModeBtn.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
var confirmModeBtnText = new Text2('Confirm', {
size: 60,
fill: 0xFFFFFF
});
confirmModeBtnText.anchor.set(0.5, 0.5);
confirmModeBtn.addChild(confirmModeBtnText);
confirmModeBtn.x = 2048 / 2;
confirmModeBtn.y = modeButtonY + (games.length - 1) * modeButtonVerticalSpacing + 200 + 123;
modeMenu.addChild(confirmModeBtn);
confirmModeBtn.down = function (x, y, obj) {
// Remove Mode Menu
game.removeChild(modeMenu);
// If Finder mode is selected, start Finder game directly
if (selectedMode === 'Finder') {
initializeFinderGame();
} else {
// Otherwise show Card Game Menu for level selection
game.addChild(cardGameMenu);
}
};
// Card Game Menu
var cardGameMenu = new Container();
// Do not add to game yet - will be added after mode selection
// Level selector buttons
var levelButtons = [];
var levelButtonY = 2732 / 2 - 250;
var buttonSpacing = 337.5;
var centerButtonIndex = 2; // Level 3 is at index 2 (0-indexed)
var totalButtons = 5;
var totalButtonWidth = totalButtons * 270 + (totalButtons - 1) * buttonSpacing; // 270 is approximate button width after scaling
var startX = 2048 / 2 - totalButtonWidth / 2 + 700 - 25;
for (var levelNum = 1; levelNum <= 5; levelNum++) {
var levelBtn = new Container();
var levelBtnBg = levelBtn.attachAsset('cardMatch', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.9,
scaleY: 0.75
});
var levelBtnText = new Text2('Level ' + levelNum, {
size: 50,
fill: 0xFFFFFF
});
levelBtnText.anchor.set(0.5, 0.5);
levelBtnText.x = 0;
levelBtnText.y = 0;
levelBtn.addChild(levelBtnText);
levelBtn.levelNum = levelNum;
levelBtn.x = startX + (levelNum - 1) * buttonSpacing;
levelBtn.y = levelButtonY;
cardGameMenu.addChild(levelBtn);
levelButtons.push(levelBtn);
levelBtn.down = function (btnLevel) {
return function (x, y, obj) {
level = btnLevel;
// Update visual feedback for selected level
for (var updateBtn = 0; updateBtn < levelButtons.length; updateBtn++) {
var btnBg = levelButtons[updateBtn].children[0];
if (levelButtons[updateBtn].levelNum === btnLevel) {
tween(btnBg, {
tint: 0xFFCC00
}, {
duration: 300,
easing: tween.easeOut
});
} else {
tween(btnBg, {
tint: 0xFFFFFF
}, {
duration: 300,
easing: tween.easeOut
});
}
}
};
}(levelNum);
}
// Add cardGameMenu to game after mode selection confirmation
var startBtn = new Container();
var startBtnBg = startBtn.attachAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5
});
var startBtnText = new Text2('Start Game', {
size: 60,
fill: 0xFFFFFF
});
startBtnText.anchor.set(0.5, 0.5);
startBtn.addChild(startBtnText);
startBtn.x = 2048 / 2;
startBtn.y = 2732 / 2 + 150;
cardGameMenu.addChild(startBtn);
// Timer update
var timerInterval;
function startTimer() {
gameStartTime = Date.now();
timerInterval = LK.setInterval(function () {
var elapsed = Math.floor((Date.now() - gameStartTime) / 1000);
timerText.setText('Time: ' + elapsed + 's');
}, 1000);
}
// Initialize the Finder game
function initializeFinderGame() {
// Hide title text for Finder game
titleText.visible = false;
// Add grass background
var grassBg = game.addChild(LK.getAsset('grassBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Clear any existing clovers
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
if (child instanceof Clover) {
child.destroy();
}
}
finderGameActive = true;
finderScore = 0;
finderCloversSpawned = 0;
// Create counter text
finderCounterText = new Text2('Found: 0', {
size: 60,
fill: 0xFFFFFF
});
finderCounterText.anchor.set(0.5, 0);
LK.gui.top.addChild(finderCounterText);
finderCounterText.y = 150;
// Determine which clover will be the four-leaf one
var fourLeafIndex = Math.floor(Math.random() * finderTotalCloversToSpawn);
// Start spawning clovers at random positions every second
finderSpawnInterval = LK.setInterval(function () {
if (!finderGameActive || finderCloversSpawned >= finderTotalCloversToSpawn) {
LK.clearInterval(finderSpawnInterval);
return;
}
var isFourLeaf = finderCloversSpawned === fourLeafIndex;
var clover = new Clover(isFourLeaf);
// Random position on screen (avoiding top area where UI is)
var randomX = Math.random() * (2048 - 200) + 100;
var randomY = Math.random() * (2732 - 600) + 300;
clover.x = randomX;
clover.y = randomY;
// Start with scale 0
clover.scaleX = 0;
clover.scaleY = 0;
game.addChild(clover);
// Animate scale to 1
tween(clover, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeOut
});
finderCloversSpawned++;
}, 1000);
// Play background music
LK.playMusic('bgmusic');
}
// Initialize the game board
function initializeBoard() {
// Show title text for Memory Card Game
titleText.visible = true;
// Clear existing cards
for (var i = 0; i < cards.length; i++) {
cards[i].destroy();
}
cards = [];
flippedCards = [];
pairsFound = 0;
moves = 0;
processingMatch = false;
gameActive = true;
movesText.setText('Moves: 0');
// Update level text display
levelText.setText('Level: ' + level);
// Show HUD elements when game starts
movesText.visible = true;
levelText.visible = true;
timerText.visible = true;
// Set level-based grid size
if (level === 1) {
gridWidth = 3;
gridHeight = 3;
} else if (level === 2) {
gridWidth = 3;
gridHeight = 4;
} else if (level === 3) {
gridWidth = 4;
gridHeight = 4;
} else if (level === 4) {
gridWidth = 4;
gridHeight = 5;
} else if (level >= 5) {
gridWidth = 5;
gridHeight = 5;
}
// Calculate total cards accounting for skipped center card on level 1 and level 5
var totalCards = gridWidth * gridHeight;
if (level === 1 || level === 5) {
totalCards = totalCards - 1;
}
totalPairs = totalCards / 2;
// Create cards and assign pairs
var pairIds = [];
if (level >= 5) {
// Level 5: Create 12 pairs (A-L) each appearing exactly twice to fill 24 cards
// 12 pairs × 2 = 24 cards with perfect pairing
for (var p = 0; p < 12; p++) {
var pairLetter = String.fromCharCode(65 + p);
pairIds.push(pairLetter);
pairIds.push(pairLetter);
}
} else {
// Levels 1-4: Create exact pairs needed without repetition
for (var p = 0; p < totalPairs; p++) {
var pairLetter = String.fromCharCode(65 + p);
pairIds.push(pairLetter);
pairIds.push(pairLetter);
}
}
// Shuffle pairs
for (var s = pairIds.length - 1; s > 0; s--) {
var j = Math.floor(Math.random() * (s + 1));
var temp = pairIds[s];
pairIds[s] = pairIds[j];
pairIds[j] = temp;
}
// Determine the grid layout positioning
var gridTotalWidth = gridWidth * cardWidth + (gridWidth - 1) * cardSpacing;
var gridTotalHeight = gridHeight * cardHeight + (gridHeight - 1) * cardSpacing;
var startX = (2048 - gridTotalWidth) / 2;
var startY = (2732 - gridTotalHeight) / 2 + (level >= 5 ? 100 : 0);
// Move level 4 cards down by 123 units
if (level === 4) {
startY += 123;
}
// Create and position the cards
var cardIndex = 0;
for (var row = 0; row < gridHeight; row++) {
for (var col = 0; col < gridWidth; col++) {
// Skip center card for level 1 and level 5
if (level === 1 && row === 1 && col === 1 || level === 5 && row === 2 && col === 2) {
continue;
}
var x = startX + col * (cardWidth + cardSpacing) + cardWidth / 2;
var y = startY + row * (cardHeight + cardSpacing) + cardHeight / 2;
var card = new Card(cardIndex, pairIds[cardIndex]);
card.x = x;
card.y = y;
cards.push(card);
game.addChild(card);
cardIndex++;
}
}
// Start the timer
startTimer();
// Play background music
LK.playMusic('bgmusic');
}
// Check for matching cards
function checkForMatch(card) {
flippedCards.push(card);
if (flippedCards.length === 2) {
processingMatch = true;
moves++;
movesText.setText('Moves: ' + moves);
var card1 = flippedCards[0];
var card2 = flippedCards[1];
if (card1.pairId === card2.pairId) {
// Match found
LK.setTimeout(function () {
LK.getSound('match').play();
card1.setMatched();
card2.setMatched();
flippedCards = [];
processingMatch = false;
// Increment pairs found
pairsFound++;
// Check for win condition
if (pairsFound === totalPairs) {
gameWon();
}
}, 500);
} else {
// No match
LK.setTimeout(function () {
LK.getSound('nomatch').play();
card1.flipBack();
card2.flipBack();
flippedCards = [];
processingMatch = false;
}, 1000);
}
}
}
// Handle game win
function gameWon() {
gameActive = false;
// Calculate score based on moves and time
var timeElapsed = Math.floor((Date.now() - gameStartTime) / 1000);
LK.clearInterval(timerInterval);
// Calculate score (fewer moves and less time = higher score)
var baseScore = 1000;
var movePenalty = moves * 10;
var timePenalty = timeElapsed * 2;
var score = Math.max(100, baseScore - movePenalty - timePenalty);
// Update best score
if (score > storage.bestScore) {
storage.bestScore = score;
}
// Set the score
LK.setScore(score);
// Play win sound
LK.getSound('win').play();
// Show win message
LK.setTimeout(function () {
// Hide HUD elements
movesText.visible = false;
levelText.visible = false;
timerText.visible = false;
// Level up
level++;
storage.level = level;
// Show you win screen
LK.showYouWin();
// Load the next level after a short delay to ensure transition
LK.setTimeout(function () {
initializeBoard();
gameActive = true; // Reactivate the game
startTimer(); // Restart the timer for the new level
}, 2000); // Delay to allow the win screen to show
}, 1500);
}
// Start button interaction
startBtn.down = function (x, y, obj) {
// Remove Card Game Menu from display
game.removeChild(cardGameMenu);
// Initialize appropriate game based on selected mode
if (selectedMode === 'Memory Card Game') {
initializeBoard();
} else if (selectedMode === 'Finder') {
initializeFinderGame();
} else {
// Handle other game modes here in the future
console.log("Selected game: " + selectedMode);
}
};
// Handle game update
game.update = function () {
// Nothing needed here as the game logic is event-driven
}; ===================================================================
--- original.js
+++ change.js
@@ -214,8 +214,16 @@
timerText.y = 150;
timerText.visible = false;
// Mode Selector Menu
var modeMenu = new Container();
+var mwBackground = modeMenu.attachAsset('MW', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ scaleX: 2048 / 100,
+ scaleY: 2732 / 100
+});
game.addChild(modeMenu);
// Game selector title
var modeTitle = new Text2("Select Game", {
size: 80,
yellow rectangle button
Golden shamrock pendant. High contrast
3 leaf clover in a white paper card with rounded corners, front view.
Lucky star in a white paper-card with rounded corners, front view.. In-Game asset. 2d. No shadows
Green Hearth in a white paper-card with rounded corners, front view.. In-Game asset. 2d. High contrast. No shadows
Green ribbon with shamrock in a white paper-card with rounded corners, front view..