/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MemoryBox = Container.expand(function (colorValue) { var self = Container.call(this); // Store the original color self.originalColor = 0xFFFFFF; // Always start with white self.isHighlighted = false; self.isClickable = false; // Create the box graphics var boxGraphics = self.attachAsset('memoryBox', { anchorX: 0.5, anchorY: 0.5 }); // Set the box color boxGraphics.tint = self.originalColor; // Highlight the box self.highlight = function () { if (!self.isHighlighted) { self.isHighlighted = true; // Tween to red color tween(boxGraphics, { tint: 0xFF0000 }, { duration: 200 }); // Play highlight sound LK.getSound('boxHighlight').play(); // Auto-unhighlight after 600ms LK.setTimeout(function () { self.unhighlight(); }, 600); } }; // Remove highlight self.unhighlight = function () { if (self.isHighlighted) { self.isHighlighted = false; // Tween back to original color tween(boxGraphics, { tint: self.originalColor }, { duration: 200 }); } }; // Handle touch/click self.down = function (x, y, obj) { if (self.isClickable) { // Visual feedback self.highlight(); // Notify game of click if (typeof onBoxClicked === 'function') { onBoxClicked(self); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ // Set background image var background = game.attachAsset('arkaplan', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732 }); // Game state variables var gameState = 'waiting'; // 'waiting', 'showing', 'input', 'gameover' var currentLevel = 1; var sequence = []; var playerInput = []; var currentSequenceIndex = 0; var currentInputIndex = 0; var boxes = []; // Colors for the boxes var boxColors = [0xff6b6b, // Red 0x4ecdc4, // Teal 0x45b7d1, // Blue 0x96ceb4, // Green 0xfeca57, // Yellow 0xff9ff3 // Pink ]; // Create score display var scoreText = new Text2('Level: 1', { size: 80, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Create instruction text var instructionText = new Text2('Watch the sequence!', { size: 60, fill: 0xFF0000 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 2732 - 300; game.addChild(instructionText); // Create Ready button var readyButton = new Text2('I\'m not monke', { size: 80, fill: 0xFF0000 }); readyButton.anchor.set(0.5, 0.5); readyButton.x = 2048 / 2; readyButton.y = 2732 - 150; readyButton.visible = false; game.addChild(readyButton); // Create IQ score display var iqText = new Text2('', { size: 100, fill: 0xFF6B6B }); iqText.anchor.set(0.5, 0.5); iqText.x = 2048 / 2; iqText.y = 2732 / 2; iqText.visible = false; game.addChild(iqText); // Create permanent IQ display at top-left var permanentIqText = new Text2('Your IQ: 80', { size: 60, fill: 0xFF0000 }); permanentIqText.anchor.set(0, 0); permanentIqText.x = 120; permanentIqText.y = 50; game.addChild(permanentIqText); // Create the memory boxes in a 9x8 grid function createBoxes() { var boxWidth = 180; var boxHeight = 180; var spacingX = 220; var spacingY = 220; var startX = (2048 - (9 * spacingX - (spacingX - boxWidth))) / 2; var startY = (2732 - (8 * spacingY - (spacingY - boxHeight))) / 2; for (var row = 0; row < 8; row++) { for (var col = 0; col < 9; col++) { var box = new MemoryBox(); box.x = startX + col * spacingX + boxWidth / 2; box.y = startY + row * spacingY + boxHeight / 2; box.boxIndex = row * 9 + col; // Index from 0 to 71 boxes.push(box); game.addChild(box); } } } // Generate new sequence function generateSequence() { // Always highlight exactly 6 boxes var sequenceLength = 6; sequence = []; var availableBoxes = []; // Create array of all box indices (0-71) for (var i = 0; i < 72; i++) { availableBoxes.push(i); } // Randomly select boxes for the sequence for (var i = 0; i < sequenceLength; i++) { var randomIndex = Math.floor(Math.random() * availableBoxes.length); sequence.push(availableBoxes[randomIndex]); availableBoxes.splice(randomIndex, 1); // Remove selected box to avoid duplicates } } // Show the sequence to player function showSequence() { gameState = 'showing'; instructionText.setText('Memorize the red boxes!'); // Disable all boxes during sequence for (var i = 0; i < boxes.length; i++) { boxes[i].isClickable = false; } // Highlight all sequence boxes in red simultaneously for (var i = 0; i < sequence.length; i++) { var boxIndex = sequence[i]; var box = boxes[boxIndex]; box.isHighlighted = true; var boxGraphics = box.children[0]; tween(boxGraphics, { tint: 0xFF0000 }, { duration: 200 }); } // Show Ready button after highlighting gameState = 'ready'; instructionText.setText('Press \'I\'m not monke\' if you are not monkey'); readyButton.visible = true; } // Start accepting player input function startPlayerInput() { gameState = 'input'; instructionText.setText('Tap the boxes you remember in any order!'); readyButton.visible = false; playerInput = []; currentInputIndex = 0; // Turn all boxes white first for (var i = 0; i < boxes.length; i++) { boxes[i].unhighlight(); } // Enable all boxes for clicking for (var i = 0; i < boxes.length; i++) { boxes[i].isClickable = true; } } // Handle Ready button click readyButton.down = function (x, y, obj) { if (gameState === 'ready') { startPlayerInput(); } }; // Handle box clicks function onBoxClicked(clickedBox) { if (gameState !== 'input') return; // Check if this box is in the sequence and hasn't been clicked yet var isCorrectBox = false; for (var i = 0; i < sequence.length; i++) { if (sequence[i] === clickedBox.boxIndex && playerInput.indexOf(clickedBox.boxIndex) === -1) { isCorrectBox = true; break; } } if (isCorrectBox) { // Correct box clicked playerInput.push(clickedBox.boxIndex); clickedBox.isClickable = false; // Disable this box if (playerInput.length >= sequence.length) { // All boxes clicked successfully LK.getSound('correct').play(); completeLevel(); } } else { // Wrong box clicked (either not in sequence or already clicked) LK.getSound('wrong').play(); gameOver(); } } // Complete current level function completeLevel() { gameState = 'waiting'; currentLevel++; LK.setScore(currentLevel - 1); scoreText.setText('Level: ' + currentLevel); // Update permanent IQ display var currentIq = Math.min(80 + (currentLevel - 1) * 5, 200); permanentIqText.setText('Your IQ: ' + currentIq); instructionText.setText('Great! Next level in 2 seconds...'); // Disable all boxes for (var i = 0; i < boxes.length; i++) { boxes[i].isClickable = false; } // Start next level after delay LK.setTimeout(function () { generateSequence(); showSequence(); }, 2000); } // Handle game over function gameOver() { gameState = 'gameover'; instructionText.setText('monkey x)'); // Calculate IQ based on level reached var iqScore = Math.min(80 + (currentLevel - 1) * 5, 200); iqText.setText('Your IQ: ' + iqScore); iqText.visible = true; readyButton.visible = false; // Disable all boxes for (var i = 0; i < boxes.length; i++) { boxes[i].isClickable = false; } // Flash screen red LK.effects.flashScreen(0xff6b6b, 1000); // Show game over after delay LK.setTimeout(function () { LK.showGameOver(); }, 1500); } // Start the game function startGame() { generateSequence(); LK.setTimeout(function () { showSequence(); }, 1000); } // Initialize everything createBoxes(); startGame(); // Play background music LK.playMusic('loop'); // Main game update loop game.update = function () { // Update score display scoreText.setText('Level: ' + currentLevel); };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var MemoryBox = Container.expand(function (colorValue) {
var self = Container.call(this);
// Store the original color
self.originalColor = 0xFFFFFF; // Always start with white
self.isHighlighted = false;
self.isClickable = false;
// Create the box graphics
var boxGraphics = self.attachAsset('memoryBox', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the box color
boxGraphics.tint = self.originalColor;
// Highlight the box
self.highlight = function () {
if (!self.isHighlighted) {
self.isHighlighted = true;
// Tween to red color
tween(boxGraphics, {
tint: 0xFF0000
}, {
duration: 200
});
// Play highlight sound
LK.getSound('boxHighlight').play();
// Auto-unhighlight after 600ms
LK.setTimeout(function () {
self.unhighlight();
}, 600);
}
};
// Remove highlight
self.unhighlight = function () {
if (self.isHighlighted) {
self.isHighlighted = false;
// Tween back to original color
tween(boxGraphics, {
tint: self.originalColor
}, {
duration: 200
});
}
};
// Handle touch/click
self.down = function (x, y, obj) {
if (self.isClickable) {
// Visual feedback
self.highlight();
// Notify game of click
if (typeof onBoxClicked === 'function') {
onBoxClicked(self);
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Set background image
var background = game.attachAsset('arkaplan', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0,
width: 2048,
height: 2732
});
// Game state variables
var gameState = 'waiting'; // 'waiting', 'showing', 'input', 'gameover'
var currentLevel = 1;
var sequence = [];
var playerInput = [];
var currentSequenceIndex = 0;
var currentInputIndex = 0;
var boxes = [];
// Colors for the boxes
var boxColors = [0xff6b6b,
// Red
0x4ecdc4,
// Teal
0x45b7d1,
// Blue
0x96ceb4,
// Green
0xfeca57,
// Yellow
0xff9ff3 // Pink
];
// Create score display
var scoreText = new Text2('Level: 1', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
// Create instruction text
var instructionText = new Text2('Watch the sequence!', {
size: 60,
fill: 0xFF0000
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 2048 / 2;
instructionText.y = 2732 - 300;
game.addChild(instructionText);
// Create Ready button
var readyButton = new Text2('I\'m not monke', {
size: 80,
fill: 0xFF0000
});
readyButton.anchor.set(0.5, 0.5);
readyButton.x = 2048 / 2;
readyButton.y = 2732 - 150;
readyButton.visible = false;
game.addChild(readyButton);
// Create IQ score display
var iqText = new Text2('', {
size: 100,
fill: 0xFF6B6B
});
iqText.anchor.set(0.5, 0.5);
iqText.x = 2048 / 2;
iqText.y = 2732 / 2;
iqText.visible = false;
game.addChild(iqText);
// Create permanent IQ display at top-left
var permanentIqText = new Text2('Your IQ: 80', {
size: 60,
fill: 0xFF0000
});
permanentIqText.anchor.set(0, 0);
permanentIqText.x = 120;
permanentIqText.y = 50;
game.addChild(permanentIqText);
// Create the memory boxes in a 9x8 grid
function createBoxes() {
var boxWidth = 180;
var boxHeight = 180;
var spacingX = 220;
var spacingY = 220;
var startX = (2048 - (9 * spacingX - (spacingX - boxWidth))) / 2;
var startY = (2732 - (8 * spacingY - (spacingY - boxHeight))) / 2;
for (var row = 0; row < 8; row++) {
for (var col = 0; col < 9; col++) {
var box = new MemoryBox();
box.x = startX + col * spacingX + boxWidth / 2;
box.y = startY + row * spacingY + boxHeight / 2;
box.boxIndex = row * 9 + col; // Index from 0 to 71
boxes.push(box);
game.addChild(box);
}
}
}
// Generate new sequence
function generateSequence() {
// Always highlight exactly 6 boxes
var sequenceLength = 6;
sequence = [];
var availableBoxes = [];
// Create array of all box indices (0-71)
for (var i = 0; i < 72; i++) {
availableBoxes.push(i);
}
// Randomly select boxes for the sequence
for (var i = 0; i < sequenceLength; i++) {
var randomIndex = Math.floor(Math.random() * availableBoxes.length);
sequence.push(availableBoxes[randomIndex]);
availableBoxes.splice(randomIndex, 1); // Remove selected box to avoid duplicates
}
}
// Show the sequence to player
function showSequence() {
gameState = 'showing';
instructionText.setText('Memorize the red boxes!');
// Disable all boxes during sequence
for (var i = 0; i < boxes.length; i++) {
boxes[i].isClickable = false;
}
// Highlight all sequence boxes in red simultaneously
for (var i = 0; i < sequence.length; i++) {
var boxIndex = sequence[i];
var box = boxes[boxIndex];
box.isHighlighted = true;
var boxGraphics = box.children[0];
tween(boxGraphics, {
tint: 0xFF0000
}, {
duration: 200
});
}
// Show Ready button after highlighting
gameState = 'ready';
instructionText.setText('Press \'I\'m not monke\' if you are not monkey');
readyButton.visible = true;
}
// Start accepting player input
function startPlayerInput() {
gameState = 'input';
instructionText.setText('Tap the boxes you remember in any order!');
readyButton.visible = false;
playerInput = [];
currentInputIndex = 0;
// Turn all boxes white first
for (var i = 0; i < boxes.length; i++) {
boxes[i].unhighlight();
}
// Enable all boxes for clicking
for (var i = 0; i < boxes.length; i++) {
boxes[i].isClickable = true;
}
}
// Handle Ready button click
readyButton.down = function (x, y, obj) {
if (gameState === 'ready') {
startPlayerInput();
}
};
// Handle box clicks
function onBoxClicked(clickedBox) {
if (gameState !== 'input') return;
// Check if this box is in the sequence and hasn't been clicked yet
var isCorrectBox = false;
for (var i = 0; i < sequence.length; i++) {
if (sequence[i] === clickedBox.boxIndex && playerInput.indexOf(clickedBox.boxIndex) === -1) {
isCorrectBox = true;
break;
}
}
if (isCorrectBox) {
// Correct box clicked
playerInput.push(clickedBox.boxIndex);
clickedBox.isClickable = false; // Disable this box
if (playerInput.length >= sequence.length) {
// All boxes clicked successfully
LK.getSound('correct').play();
completeLevel();
}
} else {
// Wrong box clicked (either not in sequence or already clicked)
LK.getSound('wrong').play();
gameOver();
}
}
// Complete current level
function completeLevel() {
gameState = 'waiting';
currentLevel++;
LK.setScore(currentLevel - 1);
scoreText.setText('Level: ' + currentLevel);
// Update permanent IQ display
var currentIq = Math.min(80 + (currentLevel - 1) * 5, 200);
permanentIqText.setText('Your IQ: ' + currentIq);
instructionText.setText('Great! Next level in 2 seconds...');
// Disable all boxes
for (var i = 0; i < boxes.length; i++) {
boxes[i].isClickable = false;
}
// Start next level after delay
LK.setTimeout(function () {
generateSequence();
showSequence();
}, 2000);
}
// Handle game over
function gameOver() {
gameState = 'gameover';
instructionText.setText('monkey x)');
// Calculate IQ based on level reached
var iqScore = Math.min(80 + (currentLevel - 1) * 5, 200);
iqText.setText('Your IQ: ' + iqScore);
iqText.visible = true;
readyButton.visible = false;
// Disable all boxes
for (var i = 0; i < boxes.length; i++) {
boxes[i].isClickable = false;
}
// Flash screen red
LK.effects.flashScreen(0xff6b6b, 1000);
// Show game over after delay
LK.setTimeout(function () {
LK.showGameOver();
}, 1500);
}
// Start the game
function startGame() {
generateSequence();
LK.setTimeout(function () {
showSequence();
}, 1000);
}
// Initialize everything
createBoxes();
startGame();
// Play background music
LK.playMusic('loop');
// Main game update loop
game.update = function () {
// Update score display
scoreText.setText('Level: ' + currentLevel);
};
monkey in peace head. In-Game asset. 2d. High contrast. No shadows
Create a pixel art background image for a 2D mobile game in portrait orientation. The scene should feature a bright blue sky with some pixelated white clouds, and a grassy green field at the bottom. Use a colorful, retro pixel art style (16-bit style), keeping the image light and cheerful. The background should not include any characters or objects, only environment elements. Leave space in the middle of the screen for gameplay elements (like the grid of boxes). Make sure the image loops or tiles well if needed.. In-Game asset. 2d. High contrast. No shadows