User prompt
Play egg cracking sound when cracking animation run
User prompt
Create a welcome screen and make size choices list game versions 4x4 and 6x6 on the menu
User prompt
Use 5 different image to animate egg cracking sequential ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make 5 step of egg crack to animate the egg cracking ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make animation more smooth and slow ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
After egg cracking animation only show the cell images ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When click the cell make egg cracking animation and the cell image appears after ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Move game title to bottom in the middle
User prompt
Write game title in the middle and show score left upper corner. Locate timer at right upper corner
User prompt
Show the timer on the screen and count down from one minutes. Each matches adds 10 seconds to the game
User prompt
Draw lines between matrix cells
User prompt
Make margins between lmages on matrix
User prompt
Make matrises 6x6
User prompt
If second image matches don't hide both
User prompt
Each second move closes the images if both is not matches
User prompt
Use 8-bit sytle cartoon characters as image and set a 1 min time limiter to game and change game finishes after time exited and the count the matches as score and show the score when the game finished
Code edit (1 edits merged)
Please save this source code
User prompt
Memory Matrix 8-Bit
Initial prompt
Develop an 2d 8bit style image macthing game the hase 5x5 image matris. User Will click each image to revieal and if the second images are matches it Will continue else game finishes
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Card = Container.expand(function (symbolType) {
var self = Container.call(this);
self.symbolType = symbolType;
self.isRevealed = false;
self.isMatched = false;
// Card background
var cardBack = self.attachAsset('cardBack', {
anchorX: 0.5,
anchorY: 0.5
});
// Card front (hidden initially)
var cardFront = self.attachAsset('cardFront', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
// Symbol (hidden initially)
var symbol = self.attachAsset('symbol' + symbolType, {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0
});
self.reveal = function () {
if (self.isRevealed || self.isMatched) return;
self.isRevealed = true;
LK.getSound('cardFlip').play();
// Hide card back and show only symbol
tween(cardBack, {
alpha: 0
}, {
duration: 400
});
tween(symbol, {
alpha: 1
}, {
duration: 400
});
};
self.hide = function () {
if (!self.isRevealed || self.isMatched) return;
self.isRevealed = false;
// Animate card flip back
tween(cardBack, {
alpha: 1
}, {
duration: 400
});
tween(symbol, {
alpha: 0
}, {
duration: 400
});
};
self.setMatched = function () {
self.isMatched = true;
self.isRevealed = true;
// Flash green to indicate match
tween(symbol, {
tint: 0x4CAF50
}, {
duration: 300,
onFinish: function onFinish() {
tween(symbol, {
tint: 0xFFFFFF
}, {
duration: 300
});
}
});
};
self.down = function (x, y, obj) {
if (gameState !== 'playing') return;
if (self.isMatched) return;
if (!self.isRevealed) {
if (revealedCards.length < 2) {
// Create egg cracking animation - Step 1
LK.getSound('eggCrack').play();
var eggCrack1 = LK.getAsset('eggCrack1', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
});
eggCrack1.x = self.x;
eggCrack1.y = self.y;
game.addChild(eggCrack1);
// Step 1: Show first crack
LK.setTimeout(function () {
eggCrack1.destroy();
// Step 2: Show second crack image
var eggCrack2 = LK.getAsset('eggCrack2', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
});
eggCrack2.x = self.x;
eggCrack2.y = self.y;
game.addChild(eggCrack2);
LK.setTimeout(function () {
eggCrack2.destroy();
// Step 3: Show third crack image
var eggCrack3 = LK.getAsset('eggCrack3', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
});
eggCrack3.x = self.x;
eggCrack3.y = self.y;
game.addChild(eggCrack3);
LK.setTimeout(function () {
eggCrack3.destroy();
// Step 4: Show fourth crack image
var eggCrack4 = LK.getAsset('eggCrack4', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
});
eggCrack4.x = self.x;
eggCrack4.y = self.y;
game.addChild(eggCrack4);
LK.setTimeout(function () {
eggCrack4.destroy();
// Step 5: Show final crack image
var eggCrack5 = LK.getAsset('eggCrack5', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
});
eggCrack5.x = self.x;
eggCrack5.y = self.y;
game.addChild(eggCrack5);
LK.setTimeout(function () {
eggCrack5.destroy();
// Reveal card after egg animation
self.reveal();
}, 160);
}, 160);
}, 160);
}, 160);
}, 160);
revealedCards.push(self);
if (revealedCards.length === 2) {
LK.setTimeout(function () {
checkMatch();
}, 850); // Wait for 5-step egg animation to complete (5 * 160ms = 800ms)
}
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1A1A1A
});
/****
* Game Code
****/
var gameState = 'menu';
var cards = [];
var revealedCards = [];
var matchedPairs = 0;
var totalPairs = 18;
var selectedGridSize = 6; // Default grid size
var welcomeScreen = null;
var menuButtons = [];
// Create welcome screen
function createWelcomeScreen() {
welcomeScreen = new Container();
game.addChild(welcomeScreen);
// Welcome title
var welcomeTitle = new Text2('Memory Matrix 8-Bit', {
size: 120,
fill: 0xFFD700
});
welcomeTitle.anchor.set(0.5, 0.5);
welcomeTitle.x = 2048 / 2;
welcomeTitle.y = 800;
welcomeScreen.addChild(welcomeTitle);
// Subtitle
var subtitle = new Text2('Choose Your Challenge', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.x = 2048 / 2;
subtitle.y = 950;
welcomeScreen.addChild(subtitle);
// 4x4 Button
var button4x4 = new Container();
var button4x4Bg = LK.getAsset('cardBack', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5,
tint: 0x4CAF50
});
var button4x4Text = new Text2('4x4 Easy', {
size: 60,
fill: 0xFFFFFF
});
button4x4Text.anchor.set(0.5, 0.5);
button4x4.addChild(button4x4Bg);
button4x4.addChild(button4x4Text);
button4x4.x = 2048 / 2;
button4x4.y = 1300;
button4x4.down = function () {
startGame(4);
};
welcomeScreen.addChild(button4x4);
menuButtons.push(button4x4);
// 6x6 Button
var button6x6 = new Container();
var button6x6Bg = LK.getAsset('cardBack', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 1.5,
tint: 0xFF6B6B
});
var button6x6Text = new Text2('6x6 Hard', {
size: 60,
fill: 0xFFFFFF
});
button6x6Text.anchor.set(0.5, 0.5);
button6x6.addChild(button6x6Bg);
button6x6.addChild(button6x6Text);
button6x6.x = 2048 / 2;
button6x6.y = 1600;
button6x6.down = function () {
startGame(6);
};
welcomeScreen.addChild(button6x6);
menuButtons.push(button6x6);
}
function startGame(gridSize) {
selectedGridSize = gridSize;
totalPairs = gridSize * gridSize / 2;
gameState = 'playing';
// Remove welcome screen
if (welcomeScreen) {
welcomeScreen.destroy();
welcomeScreen = null;
menuButtons = [];
}
// Create and start the actual game
createGameGrid();
}
function createGameGrid() {
// Create symbol pairs array
var symbolPairs = [];
for (var i = 1; i <= totalPairs; i++) {
symbolPairs.push(i);
symbolPairs.push(i);
}
// Shuffle the symbol pairs
shuffleArray(symbolPairs);
// Create grid of cards
createCards(symbolPairs);
// Create grid lines
createGridLines();
// Reset game variables
revealedCards = [];
matchedPairs = 0;
timeRemaining = 60;
lastTimeUpdate = Date.now();
// Update UI
scoreTxt.setText('Matches: 0');
timerTxt.setText('Time: 60s');
}
// Shuffle the symbol pairs
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
function createCards(symbolPairs) {
// Clear existing cards
for (var i = 0; i < cards.length; i++) {
cards[i].destroy();
}
cards = [];
// Calculate card size based on grid size
var cardSize = selectedGridSize === 4 ? 350 : 280;
var cardSpacing = 20; // Add margin between cards
var totalGridWidth = selectedGridSize * cardSize + (selectedGridSize - 1) * cardSpacing;
var totalGridHeight = selectedGridSize * cardSize + (selectedGridSize - 1) * cardSpacing;
var startX = (2048 - totalGridWidth) / 2 + cardSize / 2;
var startY = (2732 - totalGridHeight) / 2 + cardSize / 2;
for (var row = 0; row < selectedGridSize; row++) {
for (var col = 0; col < selectedGridSize; col++) {
var cardIndex = row * selectedGridSize + col;
var card = new Card(symbolPairs[cardIndex]);
card.x = startX + col * (cardSize + cardSpacing);
card.y = startY + row * (cardSize + cardSpacing);
cards.push(card);
game.addChild(card);
}
}
}
function createGridLines() {
var cardSize = selectedGridSize === 4 ? 350 : 280;
var cardSpacing = 20;
var totalGridWidth = selectedGridSize * cardSize + (selectedGridSize - 1) * cardSpacing;
var totalGridHeight = selectedGridSize * cardSize + (selectedGridSize - 1) * cardSpacing;
var startX = (2048 - totalGridWidth) / 2 + cardSize / 2;
var startY = (2732 - totalGridHeight) / 2 + cardSize / 2;
// Draw horizontal grid lines
for (var row = 0; row <= selectedGridSize; row++) {
var lineY = startY - cardSize / 2 + row * (cardSize + cardSpacing) - cardSpacing / 2;
for (var x = startX - cardSize / 2; x < startX - cardSize / 2 + totalGridWidth; x += 10) {
var horizontalLine = LK.getAsset('gridLine', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 1
});
horizontalLine.x = x;
horizontalLine.y = lineY;
game.addChild(horizontalLine);
}
}
// Draw vertical grid lines
for (var col = 0; col <= selectedGridSize; col++) {
var lineX = startX - cardSize / 2 + col * (cardSize + cardSpacing) - cardSpacing / 2;
for (var y = startY - cardSize / 2; y < startY - cardSize / 2 + totalGridHeight; y += 10) {
var verticalLine = LK.getAsset('gridLine', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 2.5
});
verticalLine.x = lineX;
verticalLine.y = y;
game.addChild(verticalLine);
}
}
}
// Timer and score variables
var timeRemaining = 60; // Start with 60 seconds
var lastTimeUpdate = Date.now();
// Score display - left upper corner
var scoreTxt = new Text2('Matches: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
scoreTxt.x = 120; // Offset from left edge to avoid menu icon
scoreTxt.y = 50;
LK.gui.topLeft.addChild(scoreTxt);
// Timer display - right upper corner
var timerTxt = new Text2('Time: 60s', {
size: 80,
fill: 0xFF6B6B
});
timerTxt.anchor.set(1, 0);
timerTxt.x = -50; // Offset from right edge
timerTxt.y = 50;
LK.gui.topRight.addChild(timerTxt);
// Title - bottom middle of screen
var titleTxt = new Text2('Memory Matrix 8-Bit', {
size: 100,
fill: 0xFFD700
});
titleTxt.anchor.set(0.5, 1);
titleTxt.x = 0;
titleTxt.y = -50; // Position at bottom with small margin
LK.gui.bottom.addChild(titleTxt);
// Initialize welcome screen
createWelcomeScreen();
function checkMatch() {
if (revealedCards.length !== 2) return;
var card1 = revealedCards[0];
var card2 = revealedCards[1];
LK.setTimeout(function () {
if (card1.symbolType === card2.symbolType) {
// Match found - keep cards revealed
card1.setMatched();
card2.setMatched();
matchedPairs++;
// Add 10 seconds to timer for each match
timeRemaining += 10;
timerTxt.setText('Time: ' + timeRemaining + 's');
LK.getSound('match').play();
LK.setScore(matchedPairs);
scoreTxt.setText('Matches: ' + matchedPairs);
// Check for victory
if (matchedPairs === totalPairs) {
gameState = 'won';
LK.setTimeout(function () {
LK.showYouWin();
}, 1000);
}
} else {
// No match - hide cards automatically
card1.hide();
card2.hide();
}
revealedCards = [];
}, 1000);
}
game.update = function () {
// Update timer countdown
if (gameState === 'playing') {
var currentTime = Date.now();
if (currentTime - lastTimeUpdate >= 1000) {
// Update every second
timeRemaining--;
timerTxt.setText('Time: ' + timeRemaining + 's');
lastTimeUpdate = currentTime;
// Check if time is up
if (timeRemaining <= 0) {
gameState = 'gameOver';
LK.showGameOver();
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -81,8 +81,9 @@
if (self.isMatched) return;
if (!self.isRevealed) {
if (revealedCards.length < 2) {
// Create egg cracking animation - Step 1
+ LK.getSound('eggCrack').play();
var eggCrack1 = LK.getAsset('eggCrack1', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 1
Make it 8 bit style dinosaur cartoon character. In-Game asset. High contrast. No shadows
8 bit style dinosaur egg. 2d. High contrast. No shadows. 8 bit
Generate cracked version
Make it different color
Make it blue
Make it 8 bit style dinosaur Achelousaurus cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur Ankylosaurus cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur Atrociraptor cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur Anchiornis cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur pterodactyl cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur stegosaurus cartoon character. In-Game asset. High contrast. No shadows
Make it 8 bit style dinosaur parasaurus cartoon character. In-Game asset. High contrast. No shadows