User prompt
Change coin collection to award 1 points instead of 49 point
Code edit (4 edits merged)
Please save this source code
User prompt
make score 49
Code edit (7 edits merged)
Please save this source code
User prompt
There is a problem with the score section. When you pass through the range, it should count the score. For this, add coins to the ranges and only increase the score as you get coins. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (3 edits merged)
Please save this source code
User prompt
make obstacle.x = 2048 + 300;
Code edit (1 edits merged)
Please save this source code
User prompt
make vertical space 450 pixels
User prompt
make vertical space 500 pixels
User prompt
You need to increase the distance between the obstacles and the distance between the obstacles a little more more more.
User prompt
You need to increase the distance between the obstacles and the distance between the obstacles a little more.
User prompt
Redo the start part. Let the drone stay in the air. When you touch the screen, the game starts. If you notice, the drone moves and falls before starting, when you press start, the game is over, this unwanted situation is fixed.
Initial prompt
1- You need to increase the distance between the obstacles a little more 2 - Gravity should be activated when you touch the screen on the home screen
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Drone = Container.expand(function () { var self = Container.call(this); // Current drone graphics self.droneGraphics = null; self.velocity = 0; self.gravity = 0.99; self.jumpPower = -12; // Set drone type based on current section self.setDroneType = function (section) { if (self.droneGraphics) { self.removeChild(self.droneGraphics); } var droneType = 'natureDrone'; if (section === 1) { droneType = 'militaryDrone'; } else if (section === 2) { droneType = 'futuristicDrone'; } else if (section === 3) { droneType = 'archeologicalDrone'; } self.droneGraphics = self.attachAsset(droneType, { anchorX: 0.5, anchorY: 0.5 }); }; self.flap = function () { self.velocity = self.jumpPower; LK.getSound('flap').play(); // Flap animation tween(self, { rotation: -0.3 }, { duration: 200 }); tween(self, { rotation: 0.3 }, { duration: 300, onFinish: function onFinish() { tween(self, { rotation: 0 }, { duration: 200 }); } }); }; self.update = function () { // Only apply physics if game has started if (gameStarted) { self.velocity += self.gravity; self.y += self.velocity; // Rotation based on velocity self.rotation = Math.min(Math.max(self.velocity * 0.05, -0.5), 0.8); } }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); self.topObstacle = null; self.bottomObstacle = null; self.gapHeight = 390; self.speed = 5; self.scored = false; self.createObstacle = function (section, gapY) { var obstacleType = 'treeObstacle'; if (section === 1) { obstacleType = 'barbedWireObstacle'; } else if (section === 2) { obstacleType = 'neonPoleObstacle'; } else if (section === 3) { obstacleType = 'stoneColumnObstacle'; } // Top obstacle self.topObstacle = self.attachAsset(obstacleType, { anchorX: 0.5, anchorY: 1 }); self.topObstacle.x = 0; self.topObstacle.y = gapY - self.gapHeight / 2; // Bottom obstacle self.bottomObstacle = self.attachAsset(obstacleType, { anchorX: 0.5, anchorY: 0 }); self.bottomObstacle.x = 0; self.bottomObstacle.y = gapY + self.gapHeight / 2; }; self.update = function () { self.x -= self.speed; // Check scoring if (!self.scored && self.x < drone.x) { self.scored = true; LK.setScore(LK.getScore() + 1); LK.getSound('score').play(); scoreTxt.setText(LK.getScore()); // Check if section should change updateGameSection(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Sounds // Background shapes for each section // Obstacle assets for each section // Drone assets for each section // Game state variables var gameStarted = false; var gameSection = 0; // 0-3 for the four sections var obstacles = []; var obstacleSpawnTimer = 0; var backgroundGraphics = null; // Create drone var drone = game.addChild(new Drone()); drone.x = 400; drone.y = 1366; drone.velocity = 0; // Start with no velocity // Create background function updateBackground() { if (backgroundGraphics) { game.removeChild(backgroundGraphics); } var bgType = 'mountainBg'; if (gameSection === 1) { bgType = 'battlefieldBg'; } else if (gameSection === 2) { bgType = 'cyberpunkBg'; } else if (gameSection === 3) { bgType = 'desertBg'; } backgroundGraphics = LK.getAsset(bgType, { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChildAt(backgroundGraphics, 0); } // Initialize background and drone updateBackground(); drone.setDroneType(gameSection); // Create UI var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var startPrompt = new Text2('TAP TO START', { size: 80, fill: 0xFFFFFF }); startPrompt.anchor.set(0.5, 0.5); LK.gui.center.addChild(startPrompt); // Game section management function updateGameSection() { var score = LK.getScore(); var newSection = Math.floor(score / 50) % 4; if (newSection !== gameSection) { gameSection = newSection; updateBackground(); drone.setDroneType(gameSection); // Increase difficulty slightly for (var i = 0; i < obstacles.length; i++) { obstacles[i].speed = 4 + Math.floor(score / 100) * 0.5; } } } // Obstacle spawning function spawnObstacle() { var obstacle = new Obstacle(); var gapY = 400 + Math.random() * (2732 - 800); obstacle.createObstacle(gameSection, gapY); obstacle.x = 2048 + 300; obstacle.speed = 4 + Math.floor(LK.getScore() / 100) * 0.5; obstacles.push(obstacle); game.addChild(obstacle); } // Input handling game.down = function (x, y, obj) { if (!gameStarted) { gameStarted = true; startPrompt.visible = false; // Start with a flap to begin movement drone.flap(); return; } drone.flap(); }; // Main game loop game.update = function () { if (!gameStarted) { return; } // Check bounds collision if (drone.y < 0 || drone.y > 2732) { LK.getSound('crash').play(); LK.showGameOver(); return; } // Spawn obstacles obstacleSpawnTimer++; if (obstacleSpawnTimer >= 300) { // Spawn every 5 seconds at 60fps spawnObstacle(); obstacleSpawnTimer = 0; } // Update and check obstacle collisions for (var i = obstacles.length - 1; i >= 0; i--) { var obstacle = obstacles[i]; // Check collision with drone if (drone.intersects(obstacle.topObstacle) || drone.intersects(obstacle.bottomObstacle)) { LK.getSound('crash').play(); LK.showGameOver(); return; } // Remove off-screen obstacles if (obstacle.x < -200) { obstacle.destroy(); obstacles.splice(i, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -68,9 +68,9 @@
var self = Container.call(this);
self.topObstacle = null;
self.bottomObstacle = null;
self.gapHeight = 390;
- self.speed = 4;
+ self.speed = 5;
self.scored = false;
self.createObstacle = function (section, gapY) {
var obstacleType = 'treeObstacle';
if (section === 1) {
@@ -119,13 +119,13 @@
/****
* Game Code
****/
-// Game state variables
-// Drone assets for each section
-// Obstacle assets for each section
-// Background shapes for each section
// Sounds
+// Background shapes for each section
+// Obstacle assets for each section
+// Drone assets for each section
+// Game state variables
var gameStarted = false;
var gameSection = 0; // 0-3 for the four sections
var obstacles = [];
var obstacleSpawnTimer = 0;
drone side view. In-Game asset. 2d. High contrast. No shadows
light brown mountain background. In-Game asset. 2d. High contrast. No shadows
barbed iron pole. In-Game asset. 2d. High contrast. No shadows
column pillar belonging to ancient Egypt. the top and bottom are the same. symmetrical. In-Game asset. 2d. High contrast. No shadows
neon turquoise pole. covered with neon pink frame. In-Game asset. 2d. High contrast. No shadows
World War II, gloomy weather, just ground. In-Game asset. 2d. High contrast. No shadows
cyberpunk city for back ground. Dark blue In-Game asset. 2d. High contrast. No shadows
ancient egypt for background. In-Game asset. 2d. High contrast. No shadows
wood pole rectangular flat. In-Game asset. 2d. High contrast. No shadows
drone side view military drone. light camouflage In-Game asset. 2d. High contrast. No shadows
drone side view drone. Silver Color. In-Game asset. 2d. High contrast. No shadows
drone side view drone. cyberpunk theme, has yellow light. neon green color In-Game asset. 2d. High contrast. No shadows
flat black framed silver coin In-Game asset. 2d. High contrast. No shadows