User prompt
way up
User prompt
logo should be above the text
User prompt
Put a Logo on the Kemal Dev text
User prompt
Change your font style to 3D style
User prompt
put a song in the background
User prompt
average the score text and move it down a little
User prompt
take down the score text
User prompt
let the game be in english
User prompt
Move the switch button from English language support and Turkish language support to the top
User prompt
Switching between English and Turkish language support
User prompt
Add Turkish language support to the game
User prompt
Enlarge small text in menu
User prompt
Please fix the bug: 'Timeout.tick error: instructText is not defined' in or related to this line: 'tween(instructText, {' Line Number: 603 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Enlarge small text in menu
User prompt
Texts in the menu should move slowly left and right ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
BEAUTIFYING GRAPHICS
User prompt
WRITE KEMALDEV IN BIG BEFORE THE MENU
User prompt
Don't show the game behind the menu
User prompt
clear difficulty selection
User prompt
move the difficulty selection buttons down to the bottom ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Set the difficulty to low
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 318
User prompt
Make the background in the menu black
User prompt
have difficulty selection in menu Easy Medium IMPOSSIBLE ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
put start menu ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var NumberDisplay = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('numberDisplay', {
anchorX: 0.5,
anchorY: 0.5
});
var numberText = new Text2('?', {
size: 80,
fill: 0xFFFFFF
});
numberText.anchor.set(0.5, 0.5);
self.addChild(numberText);
self.currentNumber = 0;
self.generateNumber = function () {
self.currentNumber = Math.floor(Math.random() * 100) + 1;
numberText.setText(self.currentNumber.toString());
// Enhanced pulse with color flash
tween(self, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 300,
easing: tween.bounceOut
});
// Color flash effect
tween(bg, {
tint: 0xffffff
}, {
duration: 100,
easing: tween.easeOut
});
tween(bg, {
tint: 0x4a90e2
}, {
duration: 200,
easing: tween.easeIn
});
};
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
var particle = self.attachAsset('numberDisplay', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 0;
self.vy = 0;
self.life = 1.0;
self.decay = 0.02;
self.init = function (color, size) {
particle.tint = color;
self.scaleX = size;
self.scaleY = size;
self.alpha = 1;
// Random velocity
self.vx = (Math.random() - 0.5) * 10;
self.vy = (Math.random() - 0.5) * 10 - 5;
};
self.update = function () {
self.x += self.vx;
self.y += self.vy;
self.vy += 0.3; // gravity
self.life -= self.decay;
self.alpha = self.life;
self.scaleX *= 0.98;
self.scaleY *= 0.98;
if (self.life <= 0) {
self.destroy();
}
};
return self;
});
var ParticleSystem = Container.expand(function () {
var self = Container.call(this);
var particles = [];
self.burst = function (x, y, color, count) {
for (var i = 0; i < count; i++) {
var particle = new Particle();
particle.x = x;
particle.y = y;
particle.init(color, Math.random() * 0.3 + 0.2);
particles.push(particle);
self.addChild(particle);
}
};
self.update = function () {
for (var i = particles.length - 1; i >= 0; i--) {
if (particles[i].life <= 0) {
particles.splice(i, 1);
}
}
};
return self;
});
var StartMenu = Container.expand(function () {
var self = Container.call(this);
// Background overlay
var bg = self.attachAsset('tapArea', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
bg.tint = 0x000000;
// Title
var titleText = new Text2('LUCKY NUMBERS\nRUSH', {
size: 80,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
titleText.y = -300;
self.addChild(titleText);
// Difficulty selection text
var diffSelectText = new Text2('SELECT DIFFICULTY', {
size: 45,
fill: 0xFFFFFF
});
diffSelectText.anchor.set(0.5, 0.5);
diffSelectText.x = 0;
diffSelectText.y = -150;
self.addChild(diffSelectText);
// Easy button
var easyBg = self.attachAsset('targetPattern', {
anchorX: 0.5,
anchorY: 0.5
});
easyBg.scaleX = 1.8;
easyBg.scaleY = 1.2;
easyBg.tint = 0x50c878;
easyBg.x = 0;
easyBg.y = -50;
var easyText = new Text2('EASY', {
size: 40,
fill: 0xFFFFFF
});
easyText.anchor.set(0.5, 0.5);
easyText.x = 0;
easyText.y = -50;
self.addChild(easyText);
// Medium button
var mediumBg = self.attachAsset('targetPattern', {
anchorX: 0.5,
anchorY: 0.5
});
mediumBg.scaleX = 1.8;
mediumBg.scaleY = 1.2;
mediumBg.tint = 0xffd700;
mediumBg.x = 0;
mediumBg.y = 50;
var mediumText = new Text2('MEDIUM', {
size: 40,
fill: 0x000000
});
mediumText.anchor.set(0.5, 0.5);
mediumText.x = 0;
mediumText.y = 50;
self.addChild(mediumText);
// Impossible button
var impossibleBg = self.attachAsset('targetPattern', {
anchorX: 0.5,
anchorY: 0.5
});
impossibleBg.scaleX = 1.8;
impossibleBg.scaleY = 1.2;
impossibleBg.tint = 0xff0000;
impossibleBg.x = 0;
impossibleBg.y = 150;
var impossibleText = new Text2('IMPOSSIBLE', {
size: 35,
fill: 0xFFFFFF
});
impossibleText.anchor.set(0.5, 0.5);
impossibleText.x = 0;
impossibleText.y = 150;
self.addChild(impossibleText);
// Instructions
var instructText = new Text2('Match target patterns\nEarn points and streaks\nBeat the clock!', {
size: 30,
fill: 0xCCCCCC
});
instructText.anchor.set(0.5, 0.5);
instructText.y = 250;
self.addChild(instructText);
// Store selected difficulty
self.selectedDifficulty = 1; // Default to easy
// Entrance animations
self.show = function () {
self.alpha = 0;
self.scaleX = 0.8;
self.scaleY = 0.8;
tween(self, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.bounceOut
});
// Pulse title
var _pulseTitleAnim = function pulseTitleAnim() {
tween(titleText, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(titleText, {
scaleX: 1,
scaleY: 1
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: _pulseTitleAnim
});
}
});
};
LK.setTimeout(_pulseTitleAnim, 500);
// Animate difficulty buttons with staggered timing
LK.setTimeout(function () {
tween(easyBg, {
scaleX: 2.0,
scaleY: 1.4
}, {
duration: 600,
easing: tween.bounceOut
});
}, 300);
LK.setTimeout(function () {
tween(mediumBg, {
scaleX: 2.0,
scaleY: 1.4
}, {
duration: 600,
easing: tween.bounceOut
});
}, 400);
LK.setTimeout(function () {
tween(impossibleBg, {
scaleX: 2.0,
scaleY: 1.4
}, {
duration: 600,
easing: tween.bounceOut
});
}, 500);
// Pulse selected difficulty button
var _pulseSelectedButton2 = function _pulseSelectedButton() {
var selectedBg = self.selectedDifficulty === 1 ? easyBg : self.selectedDifficulty === 2 ? mediumBg : impossibleBg;
var originalScaleX = selectedBg.scaleX;
var originalScaleY = selectedBg.scaleY;
tween(selectedBg, {
scaleX: originalScaleX + 0.1,
scaleY: originalScaleY + 0.1
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(selectedBg, {
scaleX: originalScaleX,
scaleY: originalScaleY
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: _pulseSelectedButton2
});
}
});
};
LK.setTimeout(_pulseSelectedButton2, 800);
};
self.hide = function (callback) {
tween(self, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 500,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
if (callback) callback();
}
});
};
// Touch handling
self.down = function (x, y, obj) {
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
// Check which button was pressed
if (localPos.y >= -80 && localPos.y <= -20) {
// Easy button pressed
self.selectedDifficulty = 1;
tween(easyBg, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(easyBg, {
tint: 0x50c878
}, {
duration: 200,
easing: tween.easeIn
});
}
});
self.hide(function () {
startGame(1);
});
} else if (localPos.y >= 20 && localPos.y <= 80) {
// Medium button pressed
self.selectedDifficulty = 2;
tween(mediumBg, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(mediumBg, {
tint: 0xffd700
}, {
duration: 200,
easing: tween.easeIn
});
}
});
self.hide(function () {
startGame(2);
});
} else if (localPos.y >= 120 && localPos.y <= 180) {
// Impossible button pressed
self.selectedDifficulty = 3;
tween(impossibleBg, {
tint: 0xFFFFFF
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(impossibleBg, {
tint: 0xff0000
}, {
duration: 200,
easing: tween.easeIn
});
}
});
self.hide(function () {
startGame(3);
});
}
};
return self;
});
var StreakDisplay = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('streakBg', {
anchorX: 0.5,
anchorY: 0.5
});
var streakText = new Text2('Streak: 0', {
size: 30,
fill: 0x000000
});
streakText.anchor.set(0.5, 0.5);
self.addChild(streakText);
self.currentStreak = 0;
self.updateStreak = function (streak) {
self.currentStreak = streak;
streakText.setText('Streak: ' + streak);
if (streak > 0) {
// Flash animation for streak
tween(bg, {
tint: 0xffffff
}, {
duration: 200
});
tween(bg, {
tint: 0xffd700
}, {
duration: 200
});
}
};
return self;
});
var TargetPattern = Container.expand(function () {
var self = Container.call(this);
var bg = self.attachAsset('targetPattern', {
anchorX: 0.5,
anchorY: 0.5
});
var patternText = new Text2('Target: 50-60', {
size: 40,
fill: 0xFFFFFF
});
patternText.anchor.set(0.5, 0.5);
self.addChild(patternText);
self.targetMin = 50;
self.targetMax = 60;
self.points = 10;
self.generatePattern = function (difficulty) {
// Slide out animation
tween(self, {
scaleX: 0.8,
scaleY: 0.8,
alpha: 0.5
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
var patternType = Math.floor(Math.random() * 3);
if (patternType === 0) {
// Range pattern
var center = Math.floor(Math.random() * 80) + 10;
var range = Math.max(5, 20 - difficulty * 2);
self.targetMin = center - Math.floor(range / 2);
self.targetMax = center + Math.floor(range / 2);
patternText.setText('Target: ' + self.targetMin + '-' + self.targetMax);
self.points = 10 + difficulty * 2;
} else if (patternType === 1) {
// Even/Odd pattern
var isEven = Math.random() < 0.5;
self.targetMin = isEven ? 2 : 1;
self.targetMax = isEven ? 100 : 99;
patternText.setText(isEven ? 'Target: EVEN' : 'Target: ODD');
self.points = 5 + difficulty;
} else {
// Divisible pattern
var divisor = [3, 5, 7, 11][Math.floor(Math.random() * 4)];
self.targetMin = divisor;
self.targetMax = divisor;
patternText.setText('Target: ÷' + divisor);
self.points = 15 + difficulty * 3;
}
// Slide in animation
tween(self, {
scaleX: 1.0,
scaleY: 1.0,
alpha: 1.0
}, {
duration: 300,
easing: tween.bounceOut
});
}
});
};
self.checkMatch = function (number) {
if (self.targetMin === self.targetMax) {
// Divisible pattern
return number % self.targetMin === 0;
} else if (self.targetMin === 1 || self.targetMin === 2) {
// Even/Odd pattern
return number % 2 === 0 && self.targetMin === 2 || number % 2 === 1 && self.targetMin === 1;
} else {
// Range pattern
return number >= self.targetMin && number <= self.targetMax;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a2e
});
/****
* Game Code
****/
// Game state variables
var gameTime = 60000; // 60 seconds
var timeRemaining = gameTime;
var difficulty = 1;
var selectedGameDifficulty = 1;
var currentStreak = 0;
var multiplier = 1;
var gameActive = false; // Start with menu
var shakeIntensity = 0;
var shakeDecay = 0.9;
var lastRngTime = 0;
var rngCooldown = 500; // 0.5 second cooldown in milliseconds
var gameState = 'menu'; // 'menu' or 'playing'
// Particle system
var particleSystem = game.addChild(new ParticleSystem());
// Start menu
var startMenu = game.addChild(new StartMenu());
startMenu.x = 1024;
startMenu.y = 1366;
startMenu.show();
// Start game function
function startGame(difficultyLevel) {
gameState = 'playing';
gameActive = true;
selectedGameDifficulty = difficultyLevel;
difficulty = difficultyLevel;
// Adjust game parameters based on difficulty
if (difficultyLevel === 1) {
// Easy: More time, slower progression
gameTime = 90000; // 90 seconds
rngCooldown = 300; // Faster RNG
} else if (difficultyLevel === 2) {
// Medium: Normal settings
gameTime = 60000; // 60 seconds
rngCooldown = 500; // Normal RNG
} else {
// Impossible: Less time, faster progression, longer cooldown
gameTime = 45000; // 45 seconds
rngCooldown = 800; // Slower RNG
}
timeRemaining = gameTime;
// Start timers
startGameTimers();
}
function startGameTimers() {
// Game timer
gameTimer = LK.setInterval(function () {
if (!gameActive) return;
timeRemaining -= 100;
var seconds = Math.ceil(timeRemaining / 1000);
timeTxt.setText(seconds.toString());
// Dynamic background color based on time remaining
if (timeRemaining < 10000) {
// Gradually shift to red as time runs out
var urgency = 1 - timeRemaining / 10000;
var red = Math.floor(26 + urgency * 100);
var green = Math.floor(26 * (1 - urgency));
var blue = Math.floor(46 * (1 - urgency));
game.setBackgroundColor(red << 16 | green << 8 | blue);
} else if (currentStreak > 5) {
// Golden background for high streaks
game.setBackgroundColor(0x2a1810);
} else {
// Default background
game.setBackgroundColor(0x1a1a2e);
}
if (timeRemaining <= 0) {
gameActive = false;
LK.clearInterval(gameTimer);
LK.clearInterval(difficultyTimer);
if (LK.getScore() >= 500) {
LK.showYouWin();
} else {
LK.showGameOver();
}
}
}, 100);
// Difficulty progression
difficultyTimer = LK.setInterval(function () {
if (!gameActive) return;
var baseDifficulty = selectedGameDifficulty;
var timeFactor = Math.floor((gameTime - timeRemaining) / 10000);
difficulty = Math.min(10, baseDifficulty + timeFactor);
difficultyTxt.setText('Level ' + difficulty);
// Generate new pattern every 5 seconds
if ((gameTime - timeRemaining) % 5000 < 100) {
targetPattern.generatePattern(difficulty);
}
}, 100);
}
// UI Elements (initially hidden)
var scoreTxt = new Text2('0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.alpha = 0;
scoreTxt.y = -50;
LK.gui.top.addChild(scoreTxt);
var timeTxt = new Text2('60', {
size: 50,
fill: 0xFF6B6B
});
timeTxt.anchor.set(1, 0);
timeTxt.x = -20;
timeTxt.y = 20;
timeTxt.alpha = 0;
timeTxt.scaleX = 0;
timeTxt.scaleY = 0;
LK.gui.topRight.addChild(timeTxt);
// Animate timer entrance
LK.setTimeout(function () {
tween(timeTxt, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.bounceOut
});
}, 200);
var difficultyTxt = new Text2('Level 1', {
size: 40,
fill: 0x4ECDC4
});
difficultyTxt.anchor.set(0, 0);
difficultyTxt.x = 20;
difficultyTxt.y = 120;
difficultyTxt.alpha = 0;
difficultyTxt.x = -100;
LK.gui.topLeft.addChild(difficultyTxt);
// Animate difficulty entrance
LK.setTimeout(function () {
tween(difficultyTxt, {
alpha: 1,
x: 20
}, {
duration: 700,
easing: tween.easeOut
});
}, 400);
// Game objects
var tapArea = game.attachAsset('tapArea', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0
});
// Fade in tap area
tween(tapArea, {
alpha: 0.1
}, {
duration: 1000,
easing: tween.easeIn
});
var numberDisplay = game.addChild(new NumberDisplay());
numberDisplay.x = 1024;
numberDisplay.y = 800;
numberDisplay.alpha = 0;
numberDisplay.scaleX = 0.3;
numberDisplay.scaleY = 0.3;
// Animate number display entrance
LK.setTimeout(function () {
tween(numberDisplay, {
alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: 800,
easing: tween.bounceOut
});
}, 600);
var targetPattern = game.addChild(new TargetPattern());
targetPattern.x = 1024;
targetPattern.y = 400;
targetPattern.alpha = 0;
targetPattern.y = 300;
// Animate target pattern entrance
LK.setTimeout(function () {
tween(targetPattern, {
alpha: 1,
y: 400
}, {
duration: 600,
easing: tween.easeOut
});
}, 800);
var streakDisplay = game.addChild(new StreakDisplay());
streakDisplay.x = 1024;
streakDisplay.y = 1200;
streakDisplay.alpha = 0;
streakDisplay.y = 1300;
// Animate streak display entrance
LK.setTimeout(function () {
tween(streakDisplay, {
alpha: 1,
y: 1200
}, {
duration: 500,
easing: tween.easeOut
});
}, 1000);
// Initialize first pattern after animations
LK.setTimeout(function () {
targetPattern.generatePattern(difficulty);
}, 1200);
// Instructions
var instructionText = new Text2('TAP TO GENERATE NUMBERS!', {
size: 50,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0.5);
instructionText.x = 1024;
instructionText.y = 600;
instructionText.alpha = 0;
game.addChild(instructionText);
// Entrance animation for instructions
tween(instructionText, {
alpha: 1,
y: 580
}, {
duration: 800,
easing: tween.bounceOut
});
// Floating animation
var _floatInstructions = function floatInstructions() {
tween(instructionText, {
y: 620
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(instructionText, {
y: 580
}, {
duration: 2000,
easing: tween.easeInOut,
onFinish: _floatInstructions
});
}
});
};
LK.setTimeout(_floatInstructions, 800);
// Fade out instructions after 3 seconds
LK.setTimeout(function () {
tween(instructionText, {
alpha: 0,
y: 550
}, {
duration: 1000,
easing: tween.easeIn
});
}, 3000);
// Timer variables
var gameTimer;
var difficultyTimer;
// Touch handling
game.down = function (x, y, obj) {
if (!gameActive || gameState !== 'playing') return;
// Check cooldown
var currentTime = Date.now();
if (currentTime - lastRngTime < rngCooldown) {
return; // Still in cooldown, ignore tap
}
lastRngTime = currentTime;
numberDisplay.generateNumber();
LK.getSound('numberGenerate').play();
// Check for match
if (targetPattern.checkMatch(numberDisplay.currentNumber)) {
// Match found!
currentStreak++;
multiplier = Math.min(5, 1 + Math.floor(currentStreak / 3));
var points = targetPattern.points * multiplier;
LK.setScore(LK.getScore() + points);
scoreTxt.setText(LK.getScore().toString());
// Screen shake for big matches
if (multiplier > 2) {
shakeIntensity = Math.min(15, multiplier * 3);
}
// Particle burst for matches
var particleColor = multiplier > 3 ? 0xFFD700 : 0x00FF00;
var particleCount = Math.min(20, 5 + multiplier * 2);
particleSystem.burst(numberDisplay.x, numberDisplay.y, particleColor, particleCount);
// Enhanced score animation
tween(scoreTxt, {
scaleX: 1.3 + multiplier * 0.1,
scaleY: 1.3 + multiplier * 0.1
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreTxt, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}
});
// Enhanced number display celebration
tween(numberDisplay, {
rotation: Math.PI * 2
}, {
duration: 600,
easing: tween.easeOut
});
streakDisplay.updateStreak(currentStreak);
// Visual feedback
LK.effects.flashObject(targetPattern, 0x00ff00, 500);
if (currentStreak > 1) {
LK.getSound('streak').play();
// Extra particles for streak
particleSystem.burst(streakDisplay.x, streakDisplay.y, 0xFFD700, 8);
} else {
LK.getSound('match').play();
}
// Generate new pattern
targetPattern.generatePattern(difficulty);
} else {
// No match, reset streak
if (currentStreak > 0) {
currentStreak = 0;
multiplier = 1;
streakDisplay.updateStreak(currentStreak);
// Flash red for missed match
LK.effects.flashObject(numberDisplay, 0xff0000, 300);
// Red particles for miss
particleSystem.burst(numberDisplay.x, numberDisplay.y, 0xFF0000, 5);
}
}
};
// Multiplier display
var multiplierTxt = new Text2('x1', {
size: 40,
fill: 0xFFD700
});
multiplierTxt.anchor.set(0.5, 1);
multiplierTxt.alpha = 0;
multiplierTxt.y = 50;
LK.gui.bottom.addChild(multiplierTxt);
// Animate multiplier entrance
LK.setTimeout(function () {
tween(multiplierTxt, {
alpha: 1,
y: 0
}, {
duration: 500,
easing: tween.bounceOut
});
}, 1200);
game.update = function () {
if (!gameActive) return;
// Screen shake effect
if (shakeIntensity > 0) {
game.x = (Math.random() - 0.5) * shakeIntensity;
game.y = (Math.random() - 0.5) * shakeIntensity;
shakeIntensity *= shakeDecay;
if (shakeIntensity < 0.5) {
shakeIntensity = 0;
game.x = 0;
game.y = 0;
}
}
// Update multiplier display
multiplierTxt.setText('x' + multiplier);
// Enhanced pulse multiplier when active
if (multiplier > 1) {
var pulse = Math.sin(LK.ticks * 0.15) * 0.15 + 1;
multiplierTxt.scaleX = pulse;
multiplierTxt.scaleY = pulse;
// Color shift for high multipliers
if (multiplier > 3) {
var colorShift = Math.sin(LK.ticks * 0.1) * 0.5 + 0.5;
multiplierTxt.tint = 0xFFFFFF * colorShift + 0xFF0000 * (1 - colorShift);
}
} else {
multiplierTxt.scaleX = 1;
multiplierTxt.scaleY = 1;
multiplierTxt.tint = 0xFFD700;
}
// Enhanced time warning effect
if (timeRemaining < 10000) {
var flash = Math.sin(LK.ticks * 0.3) * 0.3 + 0.7;
timeTxt.alpha = flash;
// Pulse timer when very low
if (timeRemaining < 5000) {
var urgentPulse = Math.sin(LK.ticks * 0.2) * 0.2 + 1;
timeTxt.scaleX = urgentPulse;
timeTxt.scaleY = urgentPulse;
}
}
// Subtle floating animation for number display
numberDisplay.y = 800 + Math.sin(LK.ticks * 0.05) * 10;
// Rainbow effect for high scores
if (LK.getScore() > 200) {
var rainbow = Math.sin(LK.ticks * 0.1) * 0.5 + 0.5;
scoreTxt.tint = 0xFFFFFF * rainbow + 0x00FFFF * (1 - rainbow);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -123,33 +123,83 @@
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 0;
- titleText.y = -200;
+ titleText.y = -300;
self.addChild(titleText);
- // Start button background
- var startBg = self.attachAsset('targetPattern', {
+ // Difficulty selection text
+ var diffSelectText = new Text2('SELECT DIFFICULTY', {
+ size: 45,
+ fill: 0xFFFFFF
+ });
+ diffSelectText.anchor.set(0.5, 0.5);
+ diffSelectText.x = 0;
+ diffSelectText.y = -150;
+ self.addChild(diffSelectText);
+ // Easy button
+ var easyBg = self.attachAsset('targetPattern', {
anchorX: 0.5,
anchorY: 0.5
});
- startBg.scaleX = 2;
- startBg.scaleY = 1.5;
- startBg.tint = 0x4a90e2;
- // Start button text
- var startText = new Text2('TAP TO START', {
- size: 50,
+ easyBg.scaleX = 1.8;
+ easyBg.scaleY = 1.2;
+ easyBg.tint = 0x50c878;
+ easyBg.x = 0;
+ easyBg.y = -50;
+ var easyText = new Text2('EASY', {
+ size: 40,
fill: 0xFFFFFF
});
- startText.anchor.set(0.5, 0.5);
- self.addChild(startText);
+ easyText.anchor.set(0.5, 0.5);
+ easyText.x = 0;
+ easyText.y = -50;
+ self.addChild(easyText);
+ // Medium button
+ var mediumBg = self.attachAsset('targetPattern', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ mediumBg.scaleX = 1.8;
+ mediumBg.scaleY = 1.2;
+ mediumBg.tint = 0xffd700;
+ mediumBg.x = 0;
+ mediumBg.y = 50;
+ var mediumText = new Text2('MEDIUM', {
+ size: 40,
+ fill: 0x000000
+ });
+ mediumText.anchor.set(0.5, 0.5);
+ mediumText.x = 0;
+ mediumText.y = 50;
+ self.addChild(mediumText);
+ // Impossible button
+ var impossibleBg = self.attachAsset('targetPattern', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ impossibleBg.scaleX = 1.8;
+ impossibleBg.scaleY = 1.2;
+ impossibleBg.tint = 0xff0000;
+ impossibleBg.x = 0;
+ impossibleBg.y = 150;
+ var impossibleText = new Text2('IMPOSSIBLE', {
+ size: 35,
+ fill: 0xFFFFFF
+ });
+ impossibleText.anchor.set(0.5, 0.5);
+ impossibleText.x = 0;
+ impossibleText.y = 150;
+ self.addChild(impossibleText);
// Instructions
var instructText = new Text2('Match target patterns\nEarn points and streaks\nBeat the clock!', {
- size: 35,
+ size: 30,
fill: 0xCCCCCC
});
instructText.anchor.set(0.5, 0.5);
- instructText.y = 150;
+ instructText.y = 250;
self.addChild(instructText);
+ // Store selected difficulty
+ self.selectedDifficulty = 1; // Default to easy
// Entrance animations
self.show = function () {
self.alpha = 0;
self.scaleX = 0.8;
@@ -182,29 +232,60 @@
}
});
};
LK.setTimeout(_pulseTitleAnim, 500);
- // Pulse start button
- var _pulseStartAnim = function pulseStartAnim() {
- tween(startBg, {
- scaleX: 2.2,
- scaleY: 1.7
+ // Animate difficulty buttons with staggered timing
+ LK.setTimeout(function () {
+ tween(easyBg, {
+ scaleX: 2.0,
+ scaleY: 1.4
}, {
+ duration: 600,
+ easing: tween.bounceOut
+ });
+ }, 300);
+ LK.setTimeout(function () {
+ tween(mediumBg, {
+ scaleX: 2.0,
+ scaleY: 1.4
+ }, {
+ duration: 600,
+ easing: tween.bounceOut
+ });
+ }, 400);
+ LK.setTimeout(function () {
+ tween(impossibleBg, {
+ scaleX: 2.0,
+ scaleY: 1.4
+ }, {
+ duration: 600,
+ easing: tween.bounceOut
+ });
+ }, 500);
+ // Pulse selected difficulty button
+ var _pulseSelectedButton2 = function _pulseSelectedButton() {
+ var selectedBg = self.selectedDifficulty === 1 ? easyBg : self.selectedDifficulty === 2 ? mediumBg : impossibleBg;
+ var originalScaleX = selectedBg.scaleX;
+ var originalScaleY = selectedBg.scaleY;
+ tween(selectedBg, {
+ scaleX: originalScaleX + 0.1,
+ scaleY: originalScaleY + 0.1
+ }, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
- tween(startBg, {
- scaleX: 2,
- scaleY: 1.5
+ tween(selectedBg, {
+ scaleX: originalScaleX,
+ scaleY: originalScaleY
}, {
duration: 800,
easing: tween.easeInOut,
- onFinish: _pulseStartAnim
+ onFinish: _pulseSelectedButton2
});
}
});
};
- LK.setTimeout(_pulseStartAnim, 300);
+ LK.setTimeout(_pulseSelectedButton2, 800);
};
self.hide = function (callback) {
tween(self, {
alpha: 0,
@@ -220,24 +301,71 @@
});
};
// Touch handling
self.down = function (x, y, obj) {
- // Flash button
- tween(startBg, {
- tint: 0xFFFFFF
- }, {
- duration: 100,
- easing: tween.easeOut,
- onFinish: function onFinish() {
- tween(startBg, {
- tint: 0x4a90e2
- }, {
- duration: 200,
- easing: tween.easeIn
- });
- }
- });
- self.hide(startGame);
+ var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
+ // Check which button was pressed
+ if (localPos.y >= -80 && localPos.y <= -20) {
+ // Easy button pressed
+ self.selectedDifficulty = 1;
+ tween(easyBg, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(easyBg, {
+ tint: 0x50c878
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ self.hide(function () {
+ startGame(1);
+ });
+ } else if (localPos.y >= 20 && localPos.y <= 80) {
+ // Medium button pressed
+ self.selectedDifficulty = 2;
+ tween(mediumBg, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(mediumBg, {
+ tint: 0xffd700
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ self.hide(function () {
+ startGame(2);
+ });
+ } else if (localPos.y >= 120 && localPos.y <= 180) {
+ // Impossible button pressed
+ self.selectedDifficulty = 3;
+ tween(impossibleBg, {
+ tint: 0xFFFFFF
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(impossibleBg, {
+ tint: 0xff0000
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ self.hide(function () {
+ startGame(3);
+ });
+ }
};
return self;
});
var StreakDisplay = Container.expand(function () {
@@ -361,34 +489,103 @@
// Game state variables
var gameTime = 60000; // 60 seconds
var timeRemaining = gameTime;
var difficulty = 1;
+var selectedGameDifficulty = 1;
var currentStreak = 0;
var multiplier = 1;
-var gameActive = true;
+var gameActive = false; // Start with menu
var shakeIntensity = 0;
var shakeDecay = 0.9;
var lastRngTime = 0;
var rngCooldown = 500; // 0.5 second cooldown in milliseconds
+var gameState = 'menu'; // 'menu' or 'playing'
// Particle system
var particleSystem = game.addChild(new ParticleSystem());
-// UI Elements
+// Start menu
+var startMenu = game.addChild(new StartMenu());
+startMenu.x = 1024;
+startMenu.y = 1366;
+startMenu.show();
+// Start game function
+function startGame(difficultyLevel) {
+ gameState = 'playing';
+ gameActive = true;
+ selectedGameDifficulty = difficultyLevel;
+ difficulty = difficultyLevel;
+ // Adjust game parameters based on difficulty
+ if (difficultyLevel === 1) {
+ // Easy: More time, slower progression
+ gameTime = 90000; // 90 seconds
+ rngCooldown = 300; // Faster RNG
+ } else if (difficultyLevel === 2) {
+ // Medium: Normal settings
+ gameTime = 60000; // 60 seconds
+ rngCooldown = 500; // Normal RNG
+ } else {
+ // Impossible: Less time, faster progression, longer cooldown
+ gameTime = 45000; // 45 seconds
+ rngCooldown = 800; // Slower RNG
+ }
+ timeRemaining = gameTime;
+ // Start timers
+ startGameTimers();
+}
+function startGameTimers() {
+ // Game timer
+ gameTimer = LK.setInterval(function () {
+ if (!gameActive) return;
+ timeRemaining -= 100;
+ var seconds = Math.ceil(timeRemaining / 1000);
+ timeTxt.setText(seconds.toString());
+ // Dynamic background color based on time remaining
+ if (timeRemaining < 10000) {
+ // Gradually shift to red as time runs out
+ var urgency = 1 - timeRemaining / 10000;
+ var red = Math.floor(26 + urgency * 100);
+ var green = Math.floor(26 * (1 - urgency));
+ var blue = Math.floor(46 * (1 - urgency));
+ game.setBackgroundColor(red << 16 | green << 8 | blue);
+ } else if (currentStreak > 5) {
+ // Golden background for high streaks
+ game.setBackgroundColor(0x2a1810);
+ } else {
+ // Default background
+ game.setBackgroundColor(0x1a1a2e);
+ }
+ if (timeRemaining <= 0) {
+ gameActive = false;
+ LK.clearInterval(gameTimer);
+ LK.clearInterval(difficultyTimer);
+ if (LK.getScore() >= 500) {
+ LK.showYouWin();
+ } else {
+ LK.showGameOver();
+ }
+ }
+ }, 100);
+ // Difficulty progression
+ difficultyTimer = LK.setInterval(function () {
+ if (!gameActive) return;
+ var baseDifficulty = selectedGameDifficulty;
+ var timeFactor = Math.floor((gameTime - timeRemaining) / 10000);
+ difficulty = Math.min(10, baseDifficulty + timeFactor);
+ difficultyTxt.setText('Level ' + difficulty);
+ // Generate new pattern every 5 seconds
+ if ((gameTime - timeRemaining) % 5000 < 100) {
+ targetPattern.generatePattern(difficulty);
+ }
+ }, 100);
+}
+// UI Elements (initially hidden)
var scoreTxt = new Text2('0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
scoreTxt.alpha = 0;
scoreTxt.y = -50;
LK.gui.top.addChild(scoreTxt);
-// Animate score entrance
-tween(scoreTxt, {
- alpha: 1,
- y: 0
-}, {
- duration: 600,
- easing: tween.bounceOut
-});
var timeTxt = new Text2('60', {
size: 50,
fill: 0xFF6B6B
});
@@ -542,52 +739,14 @@
duration: 1000,
easing: tween.easeIn
});
}, 3000);
-// Game timer
-var gameTimer = LK.setInterval(function () {
- if (!gameActive) return;
- timeRemaining -= 100;
- var seconds = Math.ceil(timeRemaining / 1000);
- timeTxt.setText(seconds.toString());
- // Dynamic background color based on time remaining
- if (timeRemaining < 10000) {
- // Gradually shift to red as time runs out
- var urgency = 1 - timeRemaining / 10000;
- var red = Math.floor(26 + urgency * 100);
- var green = Math.floor(26 * (1 - urgency));
- var blue = Math.floor(46 * (1 - urgency));
- game.setBackgroundColor(red << 16 | green << 8 | blue);
- } else if (currentStreak > 5) {
- // Golden background for high streaks
- game.setBackgroundColor(0x2a1810);
- } else {
- // Default background
- game.setBackgroundColor(0x1a1a2e);
- }
- if (timeRemaining <= 0) {
- gameActive = false;
- LK.clearInterval(gameTimer);
- if (LK.getScore() >= 500) {
- LK.showYouWin();
- } else {
- LK.showGameOver();
- }
- }
-}, 100);
-// Difficulty progression
-var difficultyTimer = LK.setInterval(function () {
- if (!gameActive) return;
- difficulty = Math.min(10, Math.floor((gameTime - timeRemaining) / 10000) + 1);
- difficultyTxt.setText('Level ' + difficulty);
- // Generate new pattern every 5 seconds
- if ((gameTime - timeRemaining) % 5000 < 100) {
- targetPattern.generatePattern(difficulty);
- }
-}, 100);
+// Timer variables
+var gameTimer;
+var difficultyTimer;
// Touch handling
game.down = function (x, y, obj) {
- if (!gameActive) return;
+ if (!gameActive || gameState !== 'playing') return;
// Check cooldown
var currentTime = Date.now();
if (currentTime - lastRngTime < rngCooldown) {
return; // Still in cooldown, ignore tap