Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
fix all the next level button at once
User prompt
the button on level 2 ,next level doesnt work
User prompt
the text going out of the screen for final completion mesages
User prompt
add bit humouristic on the text messages
User prompt
next level button doesnt work on level 5
User prompt
the next level button doesnt work on level 4
User prompt
the next level button is not working after that
User prompt
not working
User prompt
the word button is the button
User prompt
put the hidden button on the button word on level 2
User prompt
make it bigger
Code edit (1 edits merged)
Please save this source code
User prompt
This Is Not Game: The Game
Initial prompt
this is not game : the game ! let's be creative and make few level
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { currentLevel: 1, attemptsCount: 0 }); /**** * Classes ****/ var Button = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); var label = new Text2('', { size: 50, fill: 0xFFFFFF }); label.anchor.set(0.5, 0.5); self.addChild(label); self.isActive = true; self.setText = function (text) { label.setText(text); return self; }; self.setColor = function (color) { background.tint = color; return self; }; self.setActive = function (active) { self.isActive = active; background.alpha = active ? 1.0 : 0.5; return self; }; self.down = function (x, y, obj) { if (self.isActive) { background.alpha = 0.7; if (self.onPress) { self.onPress(); } LK.getSound('click').play(); } }; self.up = function (x, y, obj) { if (self.isActive) { background.alpha = 1.0; } }; return self; }); var HiddenButton = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('hiddenButton', { anchorX: 0.5, anchorY: 0.5 }); background.alpha = 0; self.down = function (x, y, obj) { if (self.onPress) { self.onPress(); } // Briefly flash to give feedback background.alpha = 0.3; LK.setTimeout(function () { background.alpha = 0; }, 200); }; return self; }); var MovingTarget = Container.expand(function () { var self = Container.call(this); var target = self.attachAsset('movingTarget', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.direction = Math.random() * Math.PI * 2; self.alpha = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; // Bounce off edges if (self.x < 50 || self.x > 2048 - 50) { self.direction = Math.PI - self.direction; } if (self.y < 50 || self.y > 2732 - 50) { self.direction = -self.direction; } }; self.down = function (x, y, obj) { if (self.onPress) { self.onPress(); } }; self.show = function () { self.alpha = 1; }; self.hide = function () { self.alpha = 0; }; return self; }); var ProgressBar = Container.expand(function () { var self = Container.call(this); var background = self.attachAsset('progressBarBackground', { anchorX: 0, anchorY: 0.5 }); var bar = self.attachAsset('progressBar', { anchorX: 0, anchorY: 0.5 }); self.progress = 0; self.setProgress = function (value) { self.progress = Math.max(0, Math.min(1, value)); bar.scale.x = self.progress; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF }); /**** * Game Code ****/ var currentLevel = storage.currentLevel || 1; var maxLevel = 5; var isLevelComplete = false; var instructions; var mainButton; var hiddenElements = []; var clickCounter = 0; var gameTimer = 0; var timeLimit = 0; var progressBar; var movingTarget; var dragNode = null; // Set up game background var background = LK.getAsset('backgroundRect', { anchorX: 0, anchorY: 0 }); game.addChild(background); function startGame() { resetGame(); LK.playMusic('bgMusic'); loadLevel(currentLevel); } function resetGame() { clearLevel(); isLevelComplete = false; clickCounter = 0; gameTimer = 0; // Clear any existing timers if (game.gameTimerId) { LK.clearInterval(game.gameTimerId); game.gameTimerId = null; } } function clearLevel() { // Remove all level-specific elements if (instructions) { instructions.destroy(); instructions = null; } if (mainButton) { mainButton.destroy(); mainButton = null; } if (progressBar) { progressBar.destroy(); progressBar = null; } if (movingTarget) { movingTarget.destroy(); movingTarget = null; } // Clear any hidden elements for (var i = 0; i < hiddenElements.length; i++) { if (hiddenElements[i]) { hiddenElements[i].destroy(); } } hiddenElements = []; } function loadLevel(level) { clearLevel(); // Common setup for instructions text instructions = new Text2("", { size: 60, fill: 0x000000 }); instructions.anchor.set(0.5, 0); instructions.x = 2048 / 2; instructions.y = 200; game.addChild(instructions); // Set up the main button that appears in all levels mainButton = new Button(); mainButton.x = 2048 / 2; mainButton.y = 2732 / 2; mainButton.scaleX = 1.5; // Increase width mainButton.scaleY = 1.5; // Increase height game.addChild(mainButton); // Progress bar (used in some levels) progressBar = new ProgressBar(); progressBar.x = 2048 / 2 - 200; progressBar.y = 2732 - 200; progressBar.setProgress(0); // Level-specific setup switch (level) { case 1: setupLevel1(); break; case 2: setupLevel2(); break; case 3: setupLevel3(); break; case 4: setupLevel4(); break; case 5: setupLevel5(); break; default: // Game complete instructions.setText("Congratulations! You've completed all the non-games!"); mainButton.setText("Play Again").setColor(0x22CC22); mainButton.onPress = function () { currentLevel = 1; storage.currentLevel = currentLevel; startGame(); }; break; } } function setupLevel1() { instructions.setText("This is not a game.\nDon't press the button."); mainButton.setText("DO NOT PRESS"); // The trick: player needs to NOT press the button and instead wait timeLimit = 5; gameTimer = 0; game.addChild(progressBar); game.gameTimerId = LK.setInterval(function () { gameTimer += 1 / 60; progressBar.setProgress(gameTimer / timeLimit); if (gameTimer >= timeLimit) { completeLevel(); } }, 16); // ~60fps mainButton.onPress = function () { // Pressing the button is the wrong action instructions.setText("I told you not to press the button!\nTry again..."); gameTimer = 0; progressBar.setProgress(0); LK.getSound('failure').play(); }; } function setupLevel2() { instructions.setText("This is not a game.\nThere is no hidden button."); mainButton.setText("NEXT LEVEL").setActive(false); // The trick: there IS a hidden button var hiddenBtn = new HiddenButton(); hiddenBtn.x = mainButton.x - mainButton.width / 2 + 100; // Position on the 'button' word hiddenBtn.y = mainButton.y - mainButton.height / 2 + 50; // Adjust y to align with the word hiddenBtn.scaleX = 2; // Increase width hiddenBtn.scaleY = 2; // Increase height hiddenBtn.onPress = function () { mainButton.setActive(true); instructions.setText("You found the button that doesn't exist!"); LK.getSound('success').play(); }; game.addChild(hiddenBtn); hiddenElements.push(hiddenBtn); mainButton.onPress = function () { if (mainButton.isActive) { completeLevel(); } }; } function setupLevel3() { instructions.setText("This is not a game.\nClick exactly 5 times anywhere."); mainButton.setText("CLICK COUNT: 0").setActive(false); clickCounter = 0; // The trick: clicking the button doesn't count, clicking elsewhere does background.interactive = true; background.down = function () { clickCounter++; mainButton.setText("CLICK COUNT: " + clickCounter); if (clickCounter === 5) { mainButton.setText("NEXT LEVEL").setActive(true); instructions.setText("Perfect! Exactly 5 clicks."); LK.getSound('success').play(); } else if (clickCounter > 5) { // Reset if they click too many times clickCounter = 0; mainButton.setText("CLICK COUNT: 0").setActive(false); instructions.setText("Too many clicks! Start over.\nExactly 5 clicks needed."); LK.getSound('failure').play(); } }; mainButton.onPress = function () { if (mainButton.isActive) { background.interactive = false; background.down = null; completeLevel(); } }; } function setupLevel4() { instructions.setText("This is not a game.\nNothing to catch here."); mainButton.setText("SKIP LEVEL").setActive(true); // The trick: catch the moving target that appears briefly movingTarget = new MovingTarget(); movingTarget.x = 2048 / 2; movingTarget.y = 1500; movingTarget.scaleX = 1.5; // Increase width movingTarget.scaleY = 1.5; // Increase height game.addChild(movingTarget); var targetAppearances = 0; var targetCaught = false; // Make the target appear periodically game.gameTimerId = LK.setInterval(function () { if (!targetCaught && targetAppearances < 5) { movingTarget.show(); // Hide it after a short time LK.setTimeout(function () { movingTarget.hide(); targetAppearances++; }, 1000); } }, 3000); movingTarget.onPress = function () { targetCaught = true; movingTarget.hide(); mainButton.setText("NEXT LEVEL"); instructions.setText("You caught it! But this is still not a game..."); LK.getSound('success').play(); }; mainButton.onPress = function () { if (targetCaught) { completeLevel(); } else { // If they skip without catching, do not proceed to the next level instructions.setText("You need to catch the target first!"); LK.getSound('failure').play(); } }; } function setupLevel5() { instructions.setText("This is not a game.\nThere's definitely no need to shake your device."); mainButton.setText("GIVE UP").setActive(true); // Track "fake" mouse movement to detect shaking var lastPositions = []; var shakeCounter = 0; var shakenEnough = false; game.addChild(progressBar); game.move = function (x, y, obj) { lastPositions.push({ x: x, y: y }); // Keep only the last 10 positions if (lastPositions.length > 10) { lastPositions.shift(); } // Calculate movement if (lastPositions.length > 5) { var totalMovement = 0; for (var i = 1; i < lastPositions.length; i++) { var dx = lastPositions[i].x - lastPositions[i - 1].x; var dy = lastPositions[i].y - lastPositions[i - 1].y; totalMovement += Math.sqrt(dx * dx + dy * dy); } // Detect "shaking" as rapid movement across the screen if (totalMovement > 100) { shakeCounter++; progressBar.setProgress(Math.min(1, shakeCounter / 20)); if (shakeCounter >= 20 && !shakenEnough) { shakenEnough = true; mainButton.setText("NEXT LEVEL"); instructions.setText("You shook it! How did that even work?"); LK.getSound('success').play(); } } } }; mainButton.onPress = function () { if (shakenEnough) { game.move = null; // Remove event listener completeLevel(); } else { instructions.setText("Are you sure? Maybe try something else first..."); } }; } function completeLevel() { if (isLevelComplete) { return; } isLevelComplete = true; LK.getSound('levelComplete').play(); if (game.gameTimerId) { LK.clearInterval(game.gameTimerId); game.gameTimerId = null; } // Display level complete message var levelCompleteText = new Text2("Level " + currentLevel + " complete!\nThis wasn't a game either...", { size: 80, fill: 0x008800 }); levelCompleteText.anchor.set(0.5, 0.5); levelCompleteText.x = 2048 / 2; levelCompleteText.y = 2732 / 2 - 400; game.addChild(levelCompleteText); // Update level progress currentLevel++; storage.currentLevel = currentLevel; // Move to next level after short delay LK.setTimeout(function () { levelCompleteText.destroy(); if (currentLevel <= maxLevel) { loadLevel(currentLevel); } else { instructions.setText("Congratulations! You've completed all the non-games!"); mainButton.setText("Play Again").setColor(0x22CC22); mainButton.onPress = function () { currentLevel = 1; storage.currentLevel = currentLevel; startGame(); }; } }, 2000); } // Handle game input events game.down = function (x, y, obj) { // This will be handled by specific elements with their own down handlers }; game.up = function (x, y, obj) { // This will be handled by specific elements with their own up handlers }; // Main game loop game.update = function () { if (movingTarget) { movingTarget.update(); } }; // Start the game startGame();
===================================================================
--- original.js
+++ change.js
@@ -350,11 +350,11 @@
mainButton.onPress = function () {
if (targetCaught) {
completeLevel();
} else {
- // If they skip without catching, count it as a fail
- storage.attemptsCount = (storage.attemptsCount || 0) + 1;
- completeLevel();
+ // If they skip without catching, do not proceed to the next level
+ instructions.setText("You need to catch the target first!");
+ LK.getSound('failure').play();
}
};
}
function setupLevel5() {