User prompt
Let the text above the person be the same as the text next to growth, and then distance will be erased.
User prompt
Now we will bring a level system to this game. We are making the first level, which can be selected from the menu. The goal is to write 30 seconds above the first level and reach 10000 growth in these 30 seconds. The seconds and growth number will be written above as a scoreboard.
User prompt
The numbers on the hamburger should be more visible and proportionate to the inside of the hamburger.
User prompt
Let's continue writing the same numbers in these boxes, but let's say these boxes are hamburgers. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When it becomes x, it should not shrink and increase by the number next to it. When it becomes +, it should increase and increase by the number next to it. When it becomes -, it should decrease by the number next to it. Add another box and divide it and let it be a random number next to it. Make a loop and divide and decrease by the number next to this divide sign. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Whatever number is written next to x, it should increase by the multiple of that number. What number next to + should increase by that number, in other words, x should multiply + and increase by one.
User prompt
When you press x and +, the man will gradually grow. When you press -, he will shrink. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make this game a little more realistic, make real human models and backgrounds beautiful
User prompt
As it progresses, the speed will increase and it will become a little more difficult.
Code edit (1 edits merged)
Please save this source code
User prompt
Number Runner: Multiply & Add
Initial prompt
Let's say there are 2 boxes in front of a man running on a straight road, let's say x2 is written in one of the boxes and +5 is written in the other, and this becomes a loop, but the numbers change and as he passes through these boxes, the man's number doubles with the x written in it, let's say the number increases with the + written in it, and as he goes on, let's say - in the boxes and let's say this number increases
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MathBox = Container.expand(function (operation, value, lane) { var self = Container.call(this); self.operation = operation; self.value = value; self.lane = lane; self.speed = gameSpeed; // Choose asset based on operation var assetId = 'addBox'; if (operation === 'multiply') assetId = 'multiplyBox';else if (operation === 'subtract') assetId = 'subtractBox'; var boxGraphics = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // Create operation text var operationText = ''; if (operation === 'multiply') operationText = '×' + value;else if (operation === 'add') operationText = '+' + value;else if (operation === 'subtract') operationText = '-' + value; var textDisplay = new Text2(operationText, { size: 36, fill: 0xFFFFFF }); textDisplay.anchor.set(0.5, 0.5); self.addChild(textDisplay); self.update = function () { self.y += self.speed; }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1.0 }); self.targetX = 1024; // Center position self.moveSpeed = 8; self.update = function () { // Smooth movement towards target position var diff = self.targetX - self.x; if (Math.abs(diff) > 2) { self.x += diff * 0.15; } else { self.x = self.targetX; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var player; var playerNumber = 10; var gameSpeed = 6; var mathBoxes = []; var lanes = [600, 1024, 1448]; // Left, center, right lanes var currentLane = 1; // Start in center var spawnTimer = 0; var spawnInterval = 120; // Spawn every 2 seconds at 60fps var gameDistance = 0; var speedIncreaseTimer = 0; // Create ground var ground = game.addChild(LK.getAsset('ground', { anchorX: 0.5, anchorY: 1.0, x: 1024, y: 2732 })); // Create player player = game.addChild(new Player()); player.x = lanes[currentLane]; player.y = 2400; // UI Elements var numberDisplay = new Text2(playerNumber.toString(), { size: 80, fill: 0xFFFFFF }); numberDisplay.anchor.set(0.5, 0.5); numberDisplay.x = 1024; numberDisplay.y = 300; game.addChild(numberDisplay); var scoreDisplay = new Text2('Distance: 0', { size: 40, fill: 0xFFFFFF }); scoreDisplay.anchor.set(0.5, 0); LK.gui.top.addChild(scoreDisplay); // Generate random math operations with progressive difficulty function generateOperation() { var difficultyLevel = Math.floor(gameDistance / 1200); // Difficulty increases every 20 seconds var operations = ['multiply', 'add', 'subtract']; // At higher difficulty, increase chance of subtract operations if (difficultyLevel > 3) { operations.push('subtract', 'subtract'); // More subtract operations } var operation = operations[Math.floor(Math.random() * operations.length)]; var value; if (operation === 'multiply') { value = Math.floor(Math.random() * (2 + difficultyLevel)) + 2; // 2-4 initially, grows with difficulty value = Math.min(value, 6); // Cap at 6x } else if (operation === 'add') { var baseAdd = 5 + Math.floor(difficultyLevel * 2); value = Math.floor(Math.random() * 15) + baseAdd; // Starting from 5-19, increases with difficulty } else if (operation === 'subtract') { var baseSub = 2 + Math.floor(difficultyLevel * 1.5); value = Math.floor(Math.random() * 8) + baseSub; // Starting from 2-9, increases with difficulty value = Math.min(value, 15); // Cap subtract at 15 } return { operation: operation, value: value }; } // Spawn math boxes function spawnMathBoxes() { // Spawn 2-3 boxes across different lanes var numBoxes = Math.floor(Math.random() * 2) + 2; // 2 or 3 boxes var usedLanes = []; for (var i = 0; i < numBoxes; i++) { var laneIndex; do { laneIndex = Math.floor(Math.random() * 3); } while (usedLanes.indexOf(laneIndex) !== -1); usedLanes.push(laneIndex); var operation = generateOperation(); var mathBox = new MathBox(operation.operation, operation.value, laneIndex); mathBox.x = lanes[laneIndex]; mathBox.y = -100; mathBoxes.push(mathBox); game.addChild(mathBox); } } // Handle player movement game.down = function (x, y, obj) { if (x < 1024 && currentLane > 0) { // Move left currentLane--; player.targetX = lanes[currentLane]; } else if (x >= 1024 && currentLane < 2) { // Move right currentLane++; player.targetX = lanes[currentLane]; } }; // Main game update game.update = function () { gameDistance++; scoreDisplay.setText('Distance: ' + Math.floor(gameDistance / 60)); // Increase speed and difficulty more aggressively speedIncreaseTimer++; if (speedIncreaseTimer >= 300) { // Every 5 seconds instead of 10 var speedIncrease = 0.3 + gameDistance / 6000; // Gradually increase the increment gameSpeed += speedIncrease; speedIncreaseTimer = 0; // Visual feedback for speed increase LK.effects.flashScreen(0x00FF00, 200); // Quick green flash } // Spawn math boxes spawnTimer++; if (spawnTimer >= spawnInterval) { spawnMathBoxes(); spawnTimer = 0; // Aggressively decrease spawn interval for more difficulty if (spawnInterval > 45) { // Faster decrease rate based on distance traveled var decreaseRate = Math.max(1, Math.floor(gameDistance / 1800)); spawnInterval -= decreaseRate; spawnInterval = Math.max(45, spawnInterval); // Minimum interval of 45 frames } } // Update math boxes and check collisions for (var i = mathBoxes.length - 1; i >= 0; i--) { var box = mathBoxes[i]; if (box.lastY === undefined) box.lastY = box.y; // Remove boxes that are off screen if (box.lastY <= 2732 && box.y > 2732) { box.destroy(); mathBoxes.splice(i, 1); continue; } // Check collision with player if (box.intersects(player)) { // Apply operation var newNumber = playerNumber; if (box.operation === 'multiply') { newNumber = playerNumber * box.value; } else if (box.operation === 'add') { newNumber = playerNumber + box.value; } else if (box.operation === 'subtract') { newNumber = playerNumber - box.value; } // Update player number playerNumber = newNumber; numberDisplay.setText(playerNumber.toString()); // Check game over condition if (playerNumber <= 0) { LK.getSound('gameOver').play(); LK.setScore(Math.floor(gameDistance / 60)); LK.showGameOver(); return; } // Play collect sound and remove box LK.getSound('collect').play(); LK.effects.flashObject(box, 0xFFFFFF, 300); box.destroy(); mathBoxes.splice(i, 1); continue; } box.lastY = box.y; } // Update speed for all boxes for (var j = 0; j < mathBoxes.length; j++) { mathBoxes[j].speed = gameSpeed; } // Update number display position numberDisplay.y = player.y - 150; numberDisplay.x = player.x; };
===================================================================
--- original.js
+++ change.js
@@ -99,19 +99,28 @@
fill: 0xFFFFFF
});
scoreDisplay.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreDisplay);
-// Generate random math operations
+// Generate random math operations with progressive difficulty
function generateOperation() {
+ var difficultyLevel = Math.floor(gameDistance / 1200); // Difficulty increases every 20 seconds
var operations = ['multiply', 'add', 'subtract'];
+ // At higher difficulty, increase chance of subtract operations
+ if (difficultyLevel > 3) {
+ operations.push('subtract', 'subtract'); // More subtract operations
+ }
var operation = operations[Math.floor(Math.random() * operations.length)];
var value;
if (operation === 'multiply') {
- value = Math.floor(Math.random() * 3) + 2; // 2-4
+ value = Math.floor(Math.random() * (2 + difficultyLevel)) + 2; // 2-4 initially, grows with difficulty
+ value = Math.min(value, 6); // Cap at 6x
} else if (operation === 'add') {
- value = Math.floor(Math.random() * 15) + 5; // 5-19
+ var baseAdd = 5 + Math.floor(difficultyLevel * 2);
+ value = Math.floor(Math.random() * 15) + baseAdd; // Starting from 5-19, increases with difficulty
} else if (operation === 'subtract') {
- value = Math.floor(Math.random() * 8) + 2; // 2-9
+ var baseSub = 2 + Math.floor(difficultyLevel * 1.5);
+ value = Math.floor(Math.random() * 8) + baseSub; // Starting from 2-9, increases with difficulty
+ value = Math.min(value, 15); // Cap subtract at 15
}
return {
operation: operation,
value: value
@@ -151,23 +160,29 @@
// Main game update
game.update = function () {
gameDistance++;
scoreDisplay.setText('Distance: ' + Math.floor(gameDistance / 60));
- // Increase speed gradually
+ // Increase speed and difficulty more aggressively
speedIncreaseTimer++;
- if (speedIncreaseTimer >= 600) {
- // Every 10 seconds
- gameSpeed += 0.5;
+ if (speedIncreaseTimer >= 300) {
+ // Every 5 seconds instead of 10
+ var speedIncrease = 0.3 + gameDistance / 6000; // Gradually increase the increment
+ gameSpeed += speedIncrease;
speedIncreaseTimer = 0;
+ // Visual feedback for speed increase
+ LK.effects.flashScreen(0x00FF00, 200); // Quick green flash
}
// Spawn math boxes
spawnTimer++;
if (spawnTimer >= spawnInterval) {
spawnMathBoxes();
spawnTimer = 0;
- // Gradually decrease spawn interval for more difficulty
- if (spawnInterval > 60) {
- spawnInterval -= 1;
+ // Aggressively decrease spawn interval for more difficulty
+ if (spawnInterval > 45) {
+ // Faster decrease rate based on distance traveled
+ var decreaseRate = Math.max(1, Math.floor(gameDistance / 1800));
+ spawnInterval -= decreaseRate;
+ spawnInterval = Math.max(45, spawnInterval); // Minimum interval of 45 frames
}
}
// Update math boxes and check collisions
for (var i = mathBoxes.length - 1; i >= 0; i--) {