User prompt
oyunun içinde ki durdurma butonu sadece durdurmaktan ibaret olmasın. main menu ve quit butonu da olsun. challangelara da tıklayınca o challange için yeni bir oyun açılsın ve challange ı tamamladıysa puanı eklensin ve challange ekranın da o challange ın yanında tik olsun ve tıklayamasın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
menünün içinde farklı bir yer açalım ve orada challangelar koyalım
User prompt
meü açılmıyor
User prompt
Please fix the bug: 'Cannot set properties of null (setting 'width')' in or related to this line: 'progressBarFill.width = 1600 * fillPercentage;' Line Number: 272
User prompt
giriş menüsü ekelyelim kendine çekecek ve güzel bir şekilde
Code edit (1 edits merged)
Please save this source code
User prompt
Tap to Win
Initial prompt
şu aşırı kolay ve berbat indirmesi aşırı yüksek reklam oyunları varya ondan yapmanı istiyorum
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var ChallengesMenu = Container.expand(function () { var self = Container.call(this); // Background var background = self.attachAsset('challengeMenuBg', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Title var titleText = new Text2('CHALLENGES', { size: 120, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 400; self.addChild(titleText); // Back button var backButton = self.attachAsset('backButton', { anchorX: 0.5, anchorY: 0.5, x: 200, y: 200 }); var backButtonText = new Text2('BACK', { size: 60, fill: 0xFFFFFF }); backButtonText.anchor.set(0.5, 0.5); backButtonText.x = 200; backButtonText.y = 200; self.addChild(backButtonText); // Challenge items var challenges = [{ title: 'Speed Demon', desc: 'Complete 100 taps in 30 seconds', reward: '500 points' }, { title: 'Marathon', desc: 'Reach level 50 without stopping', reward: '1000 points' }, { title: 'Color Master', desc: 'Unlock all tap colors', reward: 'Special effect' }, { title: 'Dedication', desc: 'Play for 7 days in a row', reward: '2000 points' }, { title: 'Tap God', desc: 'Complete 10,000 total taps', reward: 'Golden theme' }]; for (var i = 0; i < challenges.length; i++) { var challenge = challenges[i]; var yPos = 600 + i * 200; var isCompleted = completedChallenges.indexOf(i) !== -1; // Challenge background var challengeBg = self.attachAsset('challengeItem', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: yPos, alpha: isCompleted ? 0.5 : 1 }); // Store challenge index for click handler challengeBg.challengeIndex = i; challengeBg.isCompleted = isCompleted; // Challenge title var challengeTitle = new Text2(challenge.title, { size: 60, fill: isCompleted ? 0x888888 : 0xFFD700 }); challengeTitle.anchor.set(0.5, 0); challengeTitle.x = 2048 / 2; challengeTitle.y = yPos - 50; self.addChild(challengeTitle); // Challenge description var challengeDesc = new Text2(challenge.desc, { size: 45, fill: isCompleted ? 0x666666 : 0xCCCCCC }); challengeDesc.anchor.set(0.5, 0); challengeDesc.x = 2048 / 2; challengeDesc.y = yPos - 10; self.addChild(challengeDesc); // Challenge reward var challengeReward = new Text2('Reward: ' + challenge.reward, { size: 40, fill: isCompleted ? 0x666666 : 0x4CAF50 }); challengeReward.anchor.set(0.5, 0); challengeReward.x = 2048 / 2; challengeReward.y = yPos + 30; self.addChild(challengeReward); // Check mark for completed challenges if (isCompleted) { var checkMark = self.attachAsset('checkMark', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 + 850, y: yPos }); } // Challenge click handler if (!isCompleted) { challengeBg.down = function (x, y, obj) { LK.getSound('menuClick').play(); currentChallenge = this.challengeIndex; gameState = 'challenge_playing'; // Initialize challenge-specific variables challengeStartTime = Date.now(); challengeTapCount = 0; currentLevel = 1; currentProgress = 0; tapsRequired = getChallengeRequirement(currentChallenge); tween(self, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 300, onFinish: function onFinish() { self.destroy(); initializeMainGame(); } }); }; } } // Back button click handler backButton.down = function (x, y, obj) { LK.getSound('menuClick').play(); tween(self, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 300, onFinish: function onFinish() { self.destroy(); gameState = 'intro'; introMenu = game.addChild(new IntroMenu()); } }); }; // Initial entrance animation self.alpha = 0; self.scaleX = 0.8; self.scaleY = 0.8; tween(self, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 500, easing: tween.easeOut }); return self; }); var IntroMenu = Container.expand(function () { var self = Container.call(this); // Background var background = self.attachAsset('introBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Title glow effects (multiple for better visual impact) var titleGlow1 = self.attachAsset('titleGlow', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 800, alpha: 0.3 }); var titleGlow2 = self.attachAsset('titleGlow', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 800, alpha: 0.2 }); // Title text var titleText = new Text2('TAP TO WIN', { size: 150, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 800; self.addChild(titleText); // Subtitle var subtitleText = new Text2('Endless Tapping Adventure', { size: 60, fill: 0xFFD700 }); subtitleText.anchor.set(0.5, 0.5); subtitleText.x = 2048 / 2; subtitleText.y = 900; self.addChild(subtitleText); // Play button var playButton = self.attachAsset('playButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1400 }); // Play button text var playButtonText = new Text2('PLAY', { size: 80, fill: 0xFFFFFF }); playButtonText.anchor.set(0.5, 0.5); playButtonText.x = 2048 / 2; playButtonText.y = 1400; self.addChild(playButtonText); // Challenges button var challengesButton = self.attachAsset('challengesButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 1600 }); // Challenges button text var challengesButtonText = new Text2('CHALLENGES', { size: 70, fill: 0xFFFFFF }); challengesButtonText.anchor.set(0.5, 0.5); challengesButtonText.x = 2048 / 2; challengesButtonText.y = 1600; self.addChild(challengesButtonText); // Animation variables var glowAnimation = 0; var titlePulse = 0; var buttonPulse = 0; self.update = function () { // Animate title glow glowAnimation += 0.08; titleGlow1.scaleX = 1 + Math.sin(glowAnimation) * 0.3; titleGlow1.scaleY = 1 + Math.sin(glowAnimation) * 0.3; titleGlow2.scaleX = 1 + Math.sin(glowAnimation + 1) * 0.2; titleGlow2.scaleY = 1 + Math.sin(glowAnimation + 1) * 0.2; // Pulse title text titlePulse += 0.05; titleText.alpha = 0.8 + Math.sin(titlePulse) * 0.2; // Pulse play button buttonPulse += 0.1; playButton.scaleX = 1 + Math.sin(buttonPulse) * 0.1; playButton.scaleY = 1 + Math.sin(buttonPulse) * 0.1; // Pulse challenges button challengesButton.scaleX = 1 + Math.sin(buttonPulse + 0.5) * 0.1; challengesButton.scaleY = 1 + Math.sin(buttonPulse + 0.5) * 0.1; }; // Play button click handler playButton.down = function (x, y, obj) { LK.getSound('menuClick').play(); LK.effects.flashScreen(0x4CAF50, 300); // Animate menu out tween(self, { alpha: 0, scaleX: 1.2, scaleY: 1.2 }, { duration: 500, onFinish: function onFinish() { gameState = 'playing'; self.destroy(); initializeMainGame(); } }); }; // Challenges button click handler challengesButton.down = function (x, y, obj) { LK.getSound('menuClick').play(); LK.effects.flashScreen(0xFF6B35, 300); // Animate menu out tween(self, { alpha: 0, scaleX: 1.2, scaleY: 1.2 }, { duration: 500, onFinish: function onFinish() { gameState = 'challenges'; self.destroy(); var challengesMenu = game.addChild(new ChallengesMenu()); } }); }; // Initial entrance animation self.alpha = 0; self.scaleX = 0.8; self.scaleY = 0.8; tween(self, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 800, easing: tween.easeOut }); return self; }); var LevelCompleteEffect = Container.expand(function () { var self = Container.call(this); var effect = self.attachAsset('levelCompleteEffect', { anchorX: 0.5, anchorY: 0.5 }); self.animate = function () { self.x = 2048 / 2; self.y = 2732 / 2; self.alpha = 0.8; effect.scaleX = 0; effect.scaleY = 0; // Animate scale up and fade out tween(effect, { scaleX: 8, scaleY: 8 }, { duration: 800, easing: tween.easeOut }); tween(self, { alpha: 0 }, { duration: 800, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); var PauseMenu = Container.expand(function () { var self = Container.call(this); // Semi-transparent overlay var overlay = LK.getAsset('pauseMenuBg', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: 2048, height: 2732, alpha: 0.8 }); self.addChild(overlay); // Menu background var menuBg = self.attachAsset('pauseMenuBg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); // Title var titleText = new Text2('PAUSED', { size: 80, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 2048 / 2; titleText.y = 2732 / 2 - 150; self.addChild(titleText); // Resume button var resumeButton = self.attachAsset('pauseMenuButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 50 }); var resumeText = new Text2('RESUME', { size: 50, fill: 0xFFFFFF }); resumeText.anchor.set(0.5, 0.5); resumeText.x = 2048 / 2; resumeText.y = 2732 / 2 - 50; self.addChild(resumeText); // Main menu button var mainMenuButton = self.attachAsset('pauseMenuButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 30 }); var mainMenuText = new Text2('MAIN MENU', { size: 50, fill: 0xFFFFFF }); mainMenuText.anchor.set(0.5, 0.5); mainMenuText.x = 2048 / 2; mainMenuText.y = 2732 / 2 + 30; self.addChild(mainMenuText); // Quit button var quitButton = self.attachAsset('pauseMenuButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 110 }); var quitText = new Text2('QUIT', { size: 50, fill: 0xFFFFFF }); quitText.anchor.set(0.5, 0.5); quitText.x = 2048 / 2; quitText.y = 2732 / 2 + 110; self.addChild(quitText); // Button handlers resumeButton.down = function () { LK.getSound('menuClick').play(); LK.resume(); self.destroy(); }; mainMenuButton.down = function () { LK.getSound('menuClick').play(); LK.resume(); gameState = 'intro'; // Clear current game elements if (levelText) levelText.destroy(); if (progressBarBg) progressBarBg.destroy(); if (progressBarFill) progressBarFill.destroy(); if (progressText) progressText.destroy(); if (pointsText) pointsText.destroy(); if (tapInstructionText) tapInstructionText.destroy(); levelText = null; progressBarBg = null; progressBarFill = null; progressText = null; pointsText = null; tapInstructionText = null; self.destroy(); introMenu = game.addChild(new IntroMenu()); }; quitButton.down = function () { LK.getSound('menuClick').play(); LK.resume(); LK.showGameOver(); }; return self; }); var TapParticle = Container.expand(function () { var self = Container.call(this); var particle = self.attachAsset('tapParticle', { anchorX: 0.5, anchorY: 0.5 }); self.animate = function (targetX, targetY) { self.x = targetX; self.y = targetY; self.alpha = 1; particle.scaleX = 0.5; particle.scaleY = 0.5; // Animate scale and fade out tween(particle, { scaleX: 2, scaleY: 2 }, { duration: 300 }); tween(self, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { self.destroy(); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ // Game state management var gameState = 'intro'; // 'intro', 'playing', 'challenges', or 'challenge_playing' var introMenu = null; var currentChallenge = null; // Game variables var currentLevel = storage.level || 1; var currentProgress = storage.progress || 0; var tapsRequired = 10 + (currentLevel - 1) * 5; // Each level needs 5 more taps var totalPoints = storage.totalPoints || 0; var tapEffectColor = storage.tapEffectColor || 0xFFD700; // Challenge completion tracking var completedChallenges = storage.completedChallenges || []; var challengeStartTime = 0; var challengeTapCount = 0; // UI Elements (will be created when main game starts) var levelText = null; var progressBarBg = null; var progressBarFill = null; var progressText = null; var pointsText = null; var tapInstructionText = null; // Function to initialize main game UI function initializeMainGame() { levelText = new Text2('Level ' + currentLevel, { size: 80, fill: 0xFFFFFF }); levelText.anchor.set(0.5, 0); LK.gui.top.addChild(levelText); levelText.y = 150; progressBarBg = game.addChild(LK.getAsset('progressBarBg', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 300 })); progressBarFill = game.addChild(LK.getAsset('progressBarFill', { anchorX: 0, anchorY: 0.5, x: (2048 - 1600) / 2, y: 300 })); progressText = new Text2(currentProgress + ' / ' + tapsRequired, { size: 60, fill: 0xFFFFFF }); progressText.anchor.set(0.5, 0); progressText.x = 2048 / 2; progressText.y = 350; game.addChild(progressText); pointsText = new Text2('Points: ' + totalPoints, { size: 50, fill: 0xFFFF00 }); pointsText.anchor.set(1, 0); LK.gui.topRight.addChild(pointsText); pointsText.x = -20; pointsText.y = 20; tapInstructionText = new Text2('TAP ANYWHERE TO PROGRESS!', { size: 70, fill: 0xFFFFFF }); tapInstructionText.anchor.set(0.5, 0.5); tapInstructionText.x = 2048 / 2; tapInstructionText.y = 2732 / 2 + 200; game.addChild(tapInstructionText); // Initialize progress bar display updateProgressBar(); } ; // Override pause button to show custom pause menu LK.onPause = function () { if (gameState === 'playing' || gameState === 'challenge_playing') { var pauseMenu = game.addChild(new PauseMenu()); return false; // Prevent default pause behavior } return true; // Allow default behavior for other states }; // Initialize intro menu immediately when game starts introMenu = game.addChild(new IntroMenu()); // Initialize progress bar fill width function updateProgressBar() { var fillPercentage = currentProgress / tapsRequired; progressBarFill.width = 1600 * fillPercentage; progressText.setText(currentProgress + ' / ' + tapsRequired); } function completeLevel() { // Add points for completing level var levelBonus = currentLevel * 10; totalPoints += levelBonus; // Play level complete sound LK.getSound('levelComplete').play(); // Flash screen with celebration color LK.effects.flashScreen(0x4CAF50, 500); // Create level complete effect var completeEffect = game.addChild(new LevelCompleteEffect()); completeEffect.animate(); // Move to next level currentLevel++; currentProgress = 0; tapsRequired = 10 + (currentLevel - 1) * 5; // Unlock new tap color every 5 levels if (currentLevel % 5 === 0) { var colors = [0xFFD700, 0xFF69B4, 0x00FFFF, 0xFF4500, 0x9370DB, 0x32CD32]; tapEffectColor = colors[Math.floor(currentLevel / 5) % colors.length]; storage.tapEffectColor = tapEffectColor; } // Update UI levelText.setText('Level ' + currentLevel); pointsText.setText('Points: ' + totalPoints); updateProgressBar(); // Save progress storage.level = currentLevel; storage.progress = currentProgress; storage.totalPoints = totalPoints; } function getChallengeRequirement(challengeIndex) { switch (challengeIndex) { case 0: return 100; // Speed Demon: 100 taps case 1: return 50 * (10 + 49 * 5); // Marathon: reach level 50 case 2: return 5; // Color Master: unlock 5 colors (every 5 levels) case 3: return 7; // Dedication: 7 days (simplified to 7 taps for demo) case 4: return 10000; // Tap God: 10,000 taps default: return 100; } } function checkChallengeCompletion() { if (currentChallenge === null) return; var completed = false; var challengeIndex = currentChallenge; switch (challengeIndex) { case 0: // Speed Demon: 100 taps in 30 seconds if (challengeTapCount >= 100 && Date.now() - challengeStartTime <= 30000) { completed = true; totalPoints += 500; } break; case 1: // Marathon: reach level 50 if (currentLevel >= 50) { completed = true; totalPoints += 1000; } break; case 2: // Color Master: unlock all tap colors (5 colors) if (currentLevel >= 25) { // 5 colors unlocked at levels 5, 10, 15, 20, 25 completed = true; totalPoints += 100; } break; case 3: // Dedication: simplified to 7 taps for demo if (challengeTapCount >= 7) { completed = true; totalPoints += 2000; } break; case 4: // Tap God: 10,000 total taps if (challengeTapCount >= 10000) { completed = true; totalPoints += 5000; } break; } if (completed && completedChallenges.indexOf(challengeIndex) === -1) { completedChallenges.push(challengeIndex); storage.completedChallenges = completedChallenges; storage.totalPoints = totalPoints; LK.effects.flashScreen(0xFFD700, 1000); LK.getSound('levelComplete').play(); // Show completion message var completeText = new Text2('CHALLENGE COMPLETED!', { size: 80, fill: 0xFFD700 }); completeText.anchor.set(0.5, 0.5); completeText.x = 2048 / 2; completeText.y = 2732 / 2 - 200; game.addChild(completeText); LK.setTimeout(function () { completeText.destroy(); }, 3000); } } function createTapEffect(x, y) { var particle = game.addChild(new TapParticle()); // Update particle color based on current theme particle.children[0].tint = tapEffectColor; particle.animate(x, y); } // Progress bar will be initialized when main game starts // Game input handling game.down = function (x, y, obj) { // Only handle taps when in playing or challenge playing state if (gameState !== 'playing' && gameState !== 'challenge_playing') return; // Increment progress currentProgress++; // Track challenge taps if (gameState === 'challenge_playing') { challengeTapCount++; } // Play tap sound LK.getSound('tapSound').play(); // Create tap effect at touch position createTapEffect(x, y); // Small screen flash for feedback LK.effects.flashScreen(0xffffff, 100); // Update progress bar updateProgressBar(); // Check if level is complete if (currentProgress >= tapsRequired) { completeLevel(); } // Check challenge completion if (gameState === 'challenge_playing') { checkChallengeCompletion(); } // Save progress every 10 taps if (currentProgress % 10 === 0) { storage.progress = currentProgress; } }; // Animate tap instruction text var instructionPulse = 0; game.update = function () { if ((gameState === 'playing' || gameState === 'challenge_playing') && tapInstructionText) { // Pulse the instruction text instructionPulse += 0.1; tapInstructionText.alpha = 0.7 + Math.sin(instructionPulse) * 0.3; // Save progress periodically if (LK.ticks % 300 === 0) { // Every 5 seconds storage.level = currentLevel; storage.progress = currentProgress; storage.totalPoints = totalPoints; } } };
===================================================================
--- original.js
+++ change.js
@@ -64,42 +64,81 @@
}];
for (var i = 0; i < challenges.length; i++) {
var challenge = challenges[i];
var yPos = 600 + i * 200;
+ var isCompleted = completedChallenges.indexOf(i) !== -1;
// Challenge background
var challengeBg = self.attachAsset('challengeItem', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
- y: yPos
+ y: yPos,
+ alpha: isCompleted ? 0.5 : 1
});
+ // Store challenge index for click handler
+ challengeBg.challengeIndex = i;
+ challengeBg.isCompleted = isCompleted;
// Challenge title
var challengeTitle = new Text2(challenge.title, {
size: 60,
- fill: 0xFFD700
+ fill: isCompleted ? 0x888888 : 0xFFD700
});
challengeTitle.anchor.set(0.5, 0);
challengeTitle.x = 2048 / 2;
challengeTitle.y = yPos - 50;
self.addChild(challengeTitle);
// Challenge description
var challengeDesc = new Text2(challenge.desc, {
size: 45,
- fill: 0xCCCCCC
+ fill: isCompleted ? 0x666666 : 0xCCCCCC
});
challengeDesc.anchor.set(0.5, 0);
challengeDesc.x = 2048 / 2;
challengeDesc.y = yPos - 10;
self.addChild(challengeDesc);
// Challenge reward
var challengeReward = new Text2('Reward: ' + challenge.reward, {
size: 40,
- fill: 0x4CAF50
+ fill: isCompleted ? 0x666666 : 0x4CAF50
});
challengeReward.anchor.set(0.5, 0);
challengeReward.x = 2048 / 2;
challengeReward.y = yPos + 30;
self.addChild(challengeReward);
+ // Check mark for completed challenges
+ if (isCompleted) {
+ var checkMark = self.attachAsset('checkMark', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2 + 850,
+ y: yPos
+ });
+ }
+ // Challenge click handler
+ if (!isCompleted) {
+ challengeBg.down = function (x, y, obj) {
+ LK.getSound('menuClick').play();
+ currentChallenge = this.challengeIndex;
+ gameState = 'challenge_playing';
+ // Initialize challenge-specific variables
+ challengeStartTime = Date.now();
+ challengeTapCount = 0;
+ currentLevel = 1;
+ currentProgress = 0;
+ tapsRequired = getChallengeRequirement(currentChallenge);
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ self.destroy();
+ initializeMainGame();
+ }
+ });
+ };
+ }
}
// Back button click handler
backButton.down = function (x, y, obj) {
LK.getSound('menuClick').play();
@@ -306,8 +345,115 @@
});
};
return self;
});
+var PauseMenu = Container.expand(function () {
+ var self = Container.call(this);
+ // Semi-transparent overlay
+ var overlay = LK.getAsset('pauseMenuBg', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ width: 2048,
+ height: 2732,
+ alpha: 0.8
+ });
+ self.addChild(overlay);
+ // Menu background
+ var menuBg = self.attachAsset('pauseMenuBg', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2
+ });
+ // Title
+ var titleText = new Text2('PAUSED', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.x = 2048 / 2;
+ titleText.y = 2732 / 2 - 150;
+ self.addChild(titleText);
+ // Resume button
+ var resumeButton = self.attachAsset('pauseMenuButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 - 50
+ });
+ var resumeText = new Text2('RESUME', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ resumeText.anchor.set(0.5, 0.5);
+ resumeText.x = 2048 / 2;
+ resumeText.y = 2732 / 2 - 50;
+ self.addChild(resumeText);
+ // Main menu button
+ var mainMenuButton = self.attachAsset('pauseMenuButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 + 30
+ });
+ var mainMenuText = new Text2('MAIN MENU', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ mainMenuText.anchor.set(0.5, 0.5);
+ mainMenuText.x = 2048 / 2;
+ mainMenuText.y = 2732 / 2 + 30;
+ self.addChild(mainMenuText);
+ // Quit button
+ var quitButton = self.attachAsset('pauseMenuButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 2732 / 2 + 110
+ });
+ var quitText = new Text2('QUIT', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ quitText.anchor.set(0.5, 0.5);
+ quitText.x = 2048 / 2;
+ quitText.y = 2732 / 2 + 110;
+ self.addChild(quitText);
+ // Button handlers
+ resumeButton.down = function () {
+ LK.getSound('menuClick').play();
+ LK.resume();
+ self.destroy();
+ };
+ mainMenuButton.down = function () {
+ LK.getSound('menuClick').play();
+ LK.resume();
+ gameState = 'intro';
+ // Clear current game elements
+ if (levelText) levelText.destroy();
+ if (progressBarBg) progressBarBg.destroy();
+ if (progressBarFill) progressBarFill.destroy();
+ if (progressText) progressText.destroy();
+ if (pointsText) pointsText.destroy();
+ if (tapInstructionText) tapInstructionText.destroy();
+ levelText = null;
+ progressBarBg = null;
+ progressBarFill = null;
+ progressText = null;
+ pointsText = null;
+ tapInstructionText = null;
+ self.destroy();
+ introMenu = game.addChild(new IntroMenu());
+ };
+ quitButton.down = function () {
+ LK.getSound('menuClick').play();
+ LK.resume();
+ LK.showGameOver();
+ };
+ return self;
+});
var TapParticle = Container.expand(function () {
var self = Container.call(this);
var particle = self.attachAsset('tapParticle', {
anchorX: 0.5,
@@ -348,16 +494,21 @@
/****
* Game Code
****/
// Game state management
-var gameState = 'intro'; // 'intro', 'playing', or 'challenges'
+var gameState = 'intro'; // 'intro', 'playing', 'challenges', or 'challenge_playing'
var introMenu = null;
+var currentChallenge = null;
// Game variables
var currentLevel = storage.level || 1;
var currentProgress = storage.progress || 0;
var tapsRequired = 10 + (currentLevel - 1) * 5; // Each level needs 5 more taps
var totalPoints = storage.totalPoints || 0;
var tapEffectColor = storage.tapEffectColor || 0xFFD700;
+// Challenge completion tracking
+var completedChallenges = storage.completedChallenges || [];
+var challengeStartTime = 0;
+var challengeTapCount = 0;
// UI Elements (will be created when main game starts)
var levelText = null;
var progressBarBg = null;
var progressBarFill = null;
@@ -412,8 +563,16 @@
// Initialize progress bar display
updateProgressBar();
}
;
+// Override pause button to show custom pause menu
+LK.onPause = function () {
+ if (gameState === 'playing' || gameState === 'challenge_playing') {
+ var pauseMenu = game.addChild(new PauseMenu());
+ return false; // Prevent default pause behavior
+ }
+ return true; // Allow default behavior for other states
+};
// Initialize intro menu immediately when game starts
introMenu = game.addChild(new IntroMenu());
// Initialize progress bar fill width
function updateProgressBar() {
@@ -450,8 +609,91 @@
storage.level = currentLevel;
storage.progress = currentProgress;
storage.totalPoints = totalPoints;
}
+function getChallengeRequirement(challengeIndex) {
+ switch (challengeIndex) {
+ case 0:
+ return 100;
+ // Speed Demon: 100 taps
+ case 1:
+ return 50 * (10 + 49 * 5);
+ // Marathon: reach level 50
+ case 2:
+ return 5;
+ // Color Master: unlock 5 colors (every 5 levels)
+ case 3:
+ return 7;
+ // Dedication: 7 days (simplified to 7 taps for demo)
+ case 4:
+ return 10000;
+ // Tap God: 10,000 taps
+ default:
+ return 100;
+ }
+}
+function checkChallengeCompletion() {
+ if (currentChallenge === null) return;
+ var completed = false;
+ var challengeIndex = currentChallenge;
+ switch (challengeIndex) {
+ case 0:
+ // Speed Demon: 100 taps in 30 seconds
+ if (challengeTapCount >= 100 && Date.now() - challengeStartTime <= 30000) {
+ completed = true;
+ totalPoints += 500;
+ }
+ break;
+ case 1:
+ // Marathon: reach level 50
+ if (currentLevel >= 50) {
+ completed = true;
+ totalPoints += 1000;
+ }
+ break;
+ case 2:
+ // Color Master: unlock all tap colors (5 colors)
+ if (currentLevel >= 25) {
+ // 5 colors unlocked at levels 5, 10, 15, 20, 25
+ completed = true;
+ totalPoints += 100;
+ }
+ break;
+ case 3:
+ // Dedication: simplified to 7 taps for demo
+ if (challengeTapCount >= 7) {
+ completed = true;
+ totalPoints += 2000;
+ }
+ break;
+ case 4:
+ // Tap God: 10,000 total taps
+ if (challengeTapCount >= 10000) {
+ completed = true;
+ totalPoints += 5000;
+ }
+ break;
+ }
+ if (completed && completedChallenges.indexOf(challengeIndex) === -1) {
+ completedChallenges.push(challengeIndex);
+ storage.completedChallenges = completedChallenges;
+ storage.totalPoints = totalPoints;
+ LK.effects.flashScreen(0xFFD700, 1000);
+ LK.getSound('levelComplete').play();
+ // Show completion message
+ var completeText = new Text2('CHALLENGE COMPLETED!', {
+ size: 80,
+ fill: 0xFFD700
+ });
+ completeText.anchor.set(0.5, 0.5);
+ completeText.x = 2048 / 2;
+ completeText.y = 2732 / 2 - 200;
+ game.addChild(completeText);
+ LK.setTimeout(function () {
+ completeText.destroy();
+ }, 3000);
+ }
+}
function createTapEffect(x, y) {
var particle = game.addChild(new TapParticle());
// Update particle color based on current theme
particle.children[0].tint = tapEffectColor;
@@ -459,12 +701,16 @@
}
// Progress bar will be initialized when main game starts
// Game input handling
game.down = function (x, y, obj) {
- // Only handle taps when in playing state
- if (gameState !== 'playing') return;
+ // Only handle taps when in playing or challenge playing state
+ if (gameState !== 'playing' && gameState !== 'challenge_playing') return;
// Increment progress
currentProgress++;
+ // Track challenge taps
+ if (gameState === 'challenge_playing') {
+ challengeTapCount++;
+ }
// Play tap sound
LK.getSound('tapSound').play();
// Create tap effect at touch position
createTapEffect(x, y);
@@ -475,17 +721,21 @@
// Check if level is complete
if (currentProgress >= tapsRequired) {
completeLevel();
}
+ // Check challenge completion
+ if (gameState === 'challenge_playing') {
+ checkChallengeCompletion();
+ }
// Save progress every 10 taps
if (currentProgress % 10 === 0) {
storage.progress = currentProgress;
}
};
// Animate tap instruction text
var instructionPulse = 0;
game.update = function () {
- if (gameState === 'playing' && tapInstructionText) {
+ if ((gameState === 'playing' || gameState === 'challenge_playing') && tapInstructionText) {
// Pulse the instruction text
instructionPulse += 0.1;
tapInstructionText.alpha = 0.7 + Math.sin(instructionPulse) * 0.3;
// Save progress periodically