User prompt
Make the invincbility mode back ground darker
User prompt
Make the background green when invincibility mode "on"
User prompt
Make number progress reset when ever you toggle invincibility mode "on" or "off"
User prompt
Add an invincibility mode highest number to a different category
User prompt
Add a invincibility mode hi score to a differnt category
User prompt
Make the invincibility mode score to a different category
User prompt
Don't flash the screen on invincibility mode on a loss
User prompt
Add an invincibility mode that is the same but you don't restart when you lose
User prompt
Make invincibility mode the exact same but you do not lose your progress of you lose
User prompt
Make a button that turns on a mode where you can't lose
Code edit (1 edits merged)
Please save this source code
User prompt
Number Tower: Rare Ascent
Initial prompt
Try to get the highest number possible with luck. Each number is 1.01× rarer than the last number
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
highestNumber: 0,
highScore: 0
});
/****
* Classes
****/
var GenerateButton = Container.expand(function () {
var self = Container.call(this);
// Create button background
var buttonBox = self.attachAsset('generateButton', {
anchorX: 0.5,
anchorY: 0.5
});
// Create button text
self.buttonText = new Text2("TAP TO GENERATE", {
size: 70,
fill: 0xFFFFFF
});
self.buttonText.anchor.set(0.5, 0.5);
self.addChild(self.buttonText);
// Interactive properties
self.interactive = true;
// Handle button press
self.down = function () {
buttonBox.alpha = 0.7;
tween(buttonBox, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
easing: tween.easeOut
});
};
// Handle button release
self.up = function () {
buttonBox.alpha = 1.0;
tween(buttonBox, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut
});
};
return self;
});
var NumberDisplay = Container.expand(function () {
var self = Container.call(this);
// Create the background box
var box = self.attachAsset('numberBox', {
anchorX: 0.5,
anchorY: 0.5
});
// Create text display
self.valueText = new Text2("0", {
size: 120,
fill: 0x333333
});
self.valueText.anchor.set(0.5, 0.5);
self.addChild(self.valueText);
// Create probability display
self.probabilityText = new Text2("100%", {
size: 40,
fill: 0x666666
});
self.probabilityText.anchor.set(0.5, 0.5);
self.probabilityText.y = 80;
self.addChild(self.probabilityText);
// Set the current value and update display
self.currentValue = 0;
// Method to update the display
self.setValue = function (value) {
self.currentValue = value;
self.valueText.setText(value.toString());
// Calculate and display probability of next number
var nextProbability = Math.pow(0.99, value) * 100;
var probabilityDisplay = nextProbability < 0.01 ? "<0.01%" : nextProbability.toFixed(2) + "%";
self.probabilityText.setText(probabilityDisplay);
// Flash effect for new number
LK.effects.flashObject(box, 0x00FF00, 300);
};
return self;
});
var ScoreDisplay = Container.expand(function () {
var self = Container.call(this);
// Create score text
self.scoreText = new Text2("Score: 0", {
size: 60,
fill: 0xFFFFFF
});
self.scoreText.anchor.set(0, 0);
self.addChild(self.scoreText);
// Create high score text
self.highScoreText = new Text2("High Score: 0", {
size: 40,
fill: 0xCCCCCC
});
self.highScoreText.anchor.set(0, 0);
self.highScoreText.y = 70;
self.addChild(self.highScoreText);
// Create highest number text
self.highestNumberText = new Text2("Highest Number: 0", {
size: 40,
fill: 0xCCCCCC
});
self.highestNumberText.anchor.set(0, 0);
self.highestNumberText.y = 120;
self.addChild(self.highestNumberText);
// Update methods
self.updateScore = function (score) {
self.scoreText.setText("Score: " + score);
};
self.updateHighScore = function (highScore) {
self.highScoreText.setText("High Score: " + highScore);
};
self.updateHighestNumber = function (highestNumber) {
self.highestNumberText.setText("Highest Number: " + highestNumber);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Game state variables
var currentNumber = 0;
var currentScore = 0;
var gameActive = true;
var highestReached = 0;
// Create main number display
var numberDisplay = new NumberDisplay();
numberDisplay.x = 2048 / 2;
numberDisplay.y = 2732 / 2 - 300;
game.addChild(numberDisplay);
// Create generate button
var generateButton = new GenerateButton();
generateButton.x = 2048 / 2;
generateButton.y = 2732 / 2 + 300;
game.addChild(generateButton);
// Create score display
var scoreDisplay = new ScoreDisplay();
scoreDisplay.x = 150;
scoreDisplay.y = 150;
game.addChild(scoreDisplay);
// Initialize stored data
scoreDisplay.updateHighScore(storage.highScore || 0);
scoreDisplay.updateHighestNumber(storage.highestNumber || 0);
// Function to try generating the next number
function tryGenerateNext() {
if (!gameActive) {
return;
}
// Play sound
LK.getSound('generate').play();
// Calculate probability for next number (0.99^currentNumber)
var probability = Math.pow(0.99, currentNumber);
// Generate random number and check if we succeed
if (Math.random() < probability) {
// Success - increment number
currentNumber++;
// Update highest reached if needed
if (currentNumber > highestReached) {
highestReached = currentNumber;
// Play success sound
LK.getSound('success').play();
// Add points to score (higher numbers give more points)
var pointsEarned = Math.pow(2, currentNumber);
currentScore += pointsEarned;
// Show points earned with animation
var pointsText = new Text2("+" + pointsEarned, {
size: 80,
fill: 0xFFFF00
});
pointsText.anchor.set(0.5, 0.5);
pointsText.x = numberDisplay.x;
pointsText.y = numberDisplay.y - 300;
game.addChild(pointsText);
// Animate points text
tween(pointsText, {
y: pointsText.y - 200,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
pointsText.destroy();
}
});
// Update displays
scoreDisplay.updateScore(currentScore);
LK.setScore(currentScore);
// Check if new high score or highest number
if (currentNumber > (storage.highestNumber || 0)) {
storage.highestNumber = currentNumber;
scoreDisplay.updateHighestNumber(currentNumber);
}
if (currentScore > (storage.highScore || 0)) {
storage.highScore = currentScore;
scoreDisplay.updateHighScore(currentScore);
}
}
// Update number display
numberDisplay.setValue(currentNumber);
} else {
// Failed - game over
gameActive = false;
// Play game over sound
LK.getSound('gameover').play();
// Flash effect for game over
LK.effects.flashScreen(0xFF0000, 500);
// Show game over after a delay
LK.setTimeout(function () {
LK.showGameOver();
}, 800);
}
}
// Handle button press to generate number
generateButton.down = function () {
// Original button press animation
var buttonBox = generateButton.getChildAt(0);
buttonBox.alpha = 0.7;
tween(buttonBox, {
scaleX: 0.95,
scaleY: 0.95
}, {
duration: 100,
easing: tween.easeOut
});
};
generateButton.up = function () {
// Original button release animation
var buttonBox = generateButton.getChildAt(0);
buttonBox.alpha = 1.0;
tween(buttonBox, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut
});
// Try generating next number
tryGenerateNext();
};
// Game update function
game.update = function () {
// Game logic that runs every frame
// (Currently empty as our game is event-driven)
};
// Initialize the game
function initGame() {
// Reset game state
currentNumber = 0;
currentScore = 0;
gameActive = true;
highestReached = 0;
// Reset displays
numberDisplay.setValue(0);
scoreDisplay.updateScore(0);
LK.setScore(0);
// Play background music
LK.playMusic('bgMusic');
}
// Call init on game start
initGame(); ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,277 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1", {
+ highestNumber: 0,
+ highScore: 0
+});
+
+/****
+* Classes
+****/
+var GenerateButton = Container.expand(function () {
+ var self = Container.call(this);
+ // Create button background
+ var buttonBox = self.attachAsset('generateButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Create button text
+ self.buttonText = new Text2("TAP TO GENERATE", {
+ size: 70,
+ fill: 0xFFFFFF
+ });
+ self.buttonText.anchor.set(0.5, 0.5);
+ self.addChild(self.buttonText);
+ // Interactive properties
+ self.interactive = true;
+ // Handle button press
+ self.down = function () {
+ buttonBox.alpha = 0.7;
+ tween(buttonBox, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ };
+ // Handle button release
+ self.up = function () {
+ buttonBox.alpha = 1.0;
+ tween(buttonBox, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ };
+ return self;
+});
+var NumberDisplay = Container.expand(function () {
+ var self = Container.call(this);
+ // Create the background box
+ var box = self.attachAsset('numberBox', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Create text display
+ self.valueText = new Text2("0", {
+ size: 120,
+ fill: 0x333333
+ });
+ self.valueText.anchor.set(0.5, 0.5);
+ self.addChild(self.valueText);
+ // Create probability display
+ self.probabilityText = new Text2("100%", {
+ size: 40,
+ fill: 0x666666
+ });
+ self.probabilityText.anchor.set(0.5, 0.5);
+ self.probabilityText.y = 80;
+ self.addChild(self.probabilityText);
+ // Set the current value and update display
+ self.currentValue = 0;
+ // Method to update the display
+ self.setValue = function (value) {
+ self.currentValue = value;
+ self.valueText.setText(value.toString());
+ // Calculate and display probability of next number
+ var nextProbability = Math.pow(0.99, value) * 100;
+ var probabilityDisplay = nextProbability < 0.01 ? "<0.01%" : nextProbability.toFixed(2) + "%";
+ self.probabilityText.setText(probabilityDisplay);
+ // Flash effect for new number
+ LK.effects.flashObject(box, 0x00FF00, 300);
+ };
+ return self;
+});
+var ScoreDisplay = Container.expand(function () {
+ var self = Container.call(this);
+ // Create score text
+ self.scoreText = new Text2("Score: 0", {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ self.scoreText.anchor.set(0, 0);
+ self.addChild(self.scoreText);
+ // Create high score text
+ self.highScoreText = new Text2("High Score: 0", {
+ size: 40,
+ fill: 0xCCCCCC
+ });
+ self.highScoreText.anchor.set(0, 0);
+ self.highScoreText.y = 70;
+ self.addChild(self.highScoreText);
+ // Create highest number text
+ self.highestNumberText = new Text2("Highest Number: 0", {
+ size: 40,
+ fill: 0xCCCCCC
+ });
+ self.highestNumberText.anchor.set(0, 0);
+ self.highestNumberText.y = 120;
+ self.addChild(self.highestNumberText);
+ // Update methods
+ self.updateScore = function (score) {
+ self.scoreText.setText("Score: " + score);
+ };
+ self.updateHighScore = function (highScore) {
+ self.highScoreText.setText("High Score: " + highScore);
+ };
+ self.updateHighestNumber = function (highestNumber) {
+ self.highestNumberText.setText("Highest Number: " + highestNumber);
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2C3E50
+});
+
+/****
+* Game Code
+****/
+// Game state variables
+var currentNumber = 0;
+var currentScore = 0;
+var gameActive = true;
+var highestReached = 0;
+// Create main number display
+var numberDisplay = new NumberDisplay();
+numberDisplay.x = 2048 / 2;
+numberDisplay.y = 2732 / 2 - 300;
+game.addChild(numberDisplay);
+// Create generate button
+var generateButton = new GenerateButton();
+generateButton.x = 2048 / 2;
+generateButton.y = 2732 / 2 + 300;
+game.addChild(generateButton);
+// Create score display
+var scoreDisplay = new ScoreDisplay();
+scoreDisplay.x = 150;
+scoreDisplay.y = 150;
+game.addChild(scoreDisplay);
+// Initialize stored data
+scoreDisplay.updateHighScore(storage.highScore || 0);
+scoreDisplay.updateHighestNumber(storage.highestNumber || 0);
+// Function to try generating the next number
+function tryGenerateNext() {
+ if (!gameActive) {
+ return;
+ }
+ // Play sound
+ LK.getSound('generate').play();
+ // Calculate probability for next number (0.99^currentNumber)
+ var probability = Math.pow(0.99, currentNumber);
+ // Generate random number and check if we succeed
+ if (Math.random() < probability) {
+ // Success - increment number
+ currentNumber++;
+ // Update highest reached if needed
+ if (currentNumber > highestReached) {
+ highestReached = currentNumber;
+ // Play success sound
+ LK.getSound('success').play();
+ // Add points to score (higher numbers give more points)
+ var pointsEarned = Math.pow(2, currentNumber);
+ currentScore += pointsEarned;
+ // Show points earned with animation
+ var pointsText = new Text2("+" + pointsEarned, {
+ size: 80,
+ fill: 0xFFFF00
+ });
+ pointsText.anchor.set(0.5, 0.5);
+ pointsText.x = numberDisplay.x;
+ pointsText.y = numberDisplay.y - 300;
+ game.addChild(pointsText);
+ // Animate points text
+ tween(pointsText, {
+ y: pointsText.y - 200,
+ alpha: 0
+ }, {
+ duration: 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ pointsText.destroy();
+ }
+ });
+ // Update displays
+ scoreDisplay.updateScore(currentScore);
+ LK.setScore(currentScore);
+ // Check if new high score or highest number
+ if (currentNumber > (storage.highestNumber || 0)) {
+ storage.highestNumber = currentNumber;
+ scoreDisplay.updateHighestNumber(currentNumber);
+ }
+ if (currentScore > (storage.highScore || 0)) {
+ storage.highScore = currentScore;
+ scoreDisplay.updateHighScore(currentScore);
+ }
+ }
+ // Update number display
+ numberDisplay.setValue(currentNumber);
+ } else {
+ // Failed - game over
+ gameActive = false;
+ // Play game over sound
+ LK.getSound('gameover').play();
+ // Flash effect for game over
+ LK.effects.flashScreen(0xFF0000, 500);
+ // Show game over after a delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 800);
+ }
+}
+// Handle button press to generate number
+generateButton.down = function () {
+ // Original button press animation
+ var buttonBox = generateButton.getChildAt(0);
+ buttonBox.alpha = 0.7;
+ tween(buttonBox, {
+ scaleX: 0.95,
+ scaleY: 0.95
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+};
+generateButton.up = function () {
+ // Original button release animation
+ var buttonBox = generateButton.getChildAt(0);
+ buttonBox.alpha = 1.0;
+ tween(buttonBox, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ // Try generating next number
+ tryGenerateNext();
+};
+// Game update function
+game.update = function () {
+ // Game logic that runs every frame
+ // (Currently empty as our game is event-driven)
+};
+// Initialize the game
+function initGame() {
+ // Reset game state
+ currentNumber = 0;
+ currentScore = 0;
+ gameActive = true;
+ highestReached = 0;
+ // Reset displays
+ numberDisplay.setValue(0);
+ scoreDisplay.updateScore(0);
+ LK.setScore(0);
+ // Play background music
+ LK.playMusic('bgMusic');
+}
+// Call init on game start
+initGame();
\ No newline at end of file