User prompt
manual drop water bomb with tap
User prompt
drone auto move ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix music
User prompt
slowly drone moving ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix touch control ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make touch pad to control drone ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
smooth drone control ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
drone easy swipe control ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix swipe quick response
User prompt
add distance bush asset and tree asset
User prompt
add more bushes
User prompt
add more trees
User prompt
make green bush asset
User prompt
add much more tree
User prompt
add light green background
User prompt
make easy swipe control ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix swipe control, make easy swipe ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make swipe control are smooth ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
change logic. drone can move left or right by swipe
User prompt
fix drone moving automaticly to left or right
User prompt
drone automatic move left dan right ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Forest Fire Fighter
Initial prompt
game title : drone throwing water bombs. fires in forest groups game mechanics : flying drones throwing water bombs at fire points background : scattered forest areas.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Base = Container.expand(function () { var self = Container.call(this); var baseGraphics = self.attachAsset('base', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Bush = Container.expand(function () { var self = Container.call(this); var bushGraphics = self.attachAsset('bush', { anchorX: 0.5, anchorY: 1.0 }); return self; }); var DistantBush = Container.expand(function () { var self = Container.call(this); var bushGraphics = self.attachAsset('distantBush', { anchorX: 0.5, anchorY: 1.0 }); bushGraphics.alpha = 0.7; return self; }); var DistantTree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('distantTree', { anchorX: 0.5, anchorY: 1.0 }); treeGraphics.alpha = 0.6; return self; }); var Drone = Container.expand(function () { var self = Container.call(this); var droneGraphics = self.attachAsset('drone', { anchorX: 0.5, anchorY: 0.5 }); self.waterBombs = 10; self.maxWaterBombs = 10; self.refillWater = function () { if (self.waterBombs < self.maxWaterBombs) { self.waterBombs = self.maxWaterBombs; LK.getSound('refill').play(); waterBombsText.setText('Water: ' + self.waterBombs); } }; self.dropWaterBomb = function () { if (self.waterBombs > 0) { self.waterBombs--; waterBombsText.setText('Water: ' + self.waterBombs); var waterBomb = new WaterBomb(); waterBomb.x = self.x; waterBomb.y = self.y + 30; waterBombs.push(waterBomb); game.addChild(waterBomb); LK.getSound('drop').play(); } }; return self; }); var Fire = Container.expand(function () { var self = Container.call(this); var fireGraphics = self.attachAsset('fire', { anchorX: 0.5, anchorY: 0.5 }); self.extinguished = false; self.update = function () { if (!self.extinguished) { fireGraphics.alpha = 0.7 + Math.sin(LK.ticks * 0.2) * 0.3; } }; self.extinguish = function () { if (!self.extinguished) { self.extinguished = true; LK.getSound('extinguish').play(); tween(fireGraphics, { alpha: 0, scaleX: 0.1, scaleY: 0.1 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); LK.setScore(LK.getScore() + 100); scoreText.setText('Score: ' + LK.getScore()); firesExtinguished++; } }; return self; }); var Tree = Container.expand(function () { var self = Container.call(this); var treeGraphics = self.attachAsset('tree', { anchorX: 0.5, anchorY: 1.0 }); return self; }); var WaterBomb = Container.expand(function () { var self = Container.call(this); var bombGraphics = self.attachAsset('waterBomb', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.update = function () { self.y += self.speed; if (self.y > 2732 + 50) { self.destroy(); for (var i = waterBombs.length - 1; i >= 0; i--) { if (waterBombs[i] === self) { waterBombs.splice(i, 1); break; } } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x90EE90 }); /**** * Game Code ****/ var drone = game.addChild(new Drone()); drone.x = 1024; drone.y = 200; var base = game.addChild(new Base()); base.x = 1024; base.y = 100; var fires = []; var waterBombs = []; var trees = []; var bushes = []; var distantTrees = []; var distantBushes = []; var dragNode = null; var firesExtinguished = 0; var totalFires = 8; var swipeStartX = 0; var swipeStartY = 0; var isSwipeActive = false; var swipeThreshold = 15; // Even lower threshold for very responsive swipes var droneSpeed = 200; // Faster movement for quicker response // Create distant trees for background depth for (var i = 0; i < 30; i++) { var distantTree = game.addChild(new DistantTree()); distantTree.x = Math.random() * 1900 + 74; distantTree.y = Math.random() * 2100 + 300; distantTrees.push(distantTree); } // Create forest background with trees for (var i = 0; i < 80; i++) { var tree = game.addChild(new Tree()); tree.x = Math.random() * 1800 + 124; tree.y = Math.random() * 2000 + 400; trees.push(tree); } // Create distant bushes for background depth for (var i = 0; i < 40; i++) { var distantBush = game.addChild(new DistantBush()); distantBush.x = Math.random() * 1800 + 124; distantBush.y = Math.random() * 2000 + 400; distantBushes.push(distantBush); } // Create bushes throughout the forest for (var i = 0; i < 60; i++) { var bush = game.addChild(new Bush()); bush.x = Math.random() * 1700 + 174; bush.y = Math.random() * 1900 + 500; bushes.push(bush); } // Create fires scattered throughout the forest for (var i = 0; i < totalFires; i++) { var fire = game.addChild(new Fire()); fire.x = Math.random() * 1600 + 224; fire.y = Math.random() * 1800 + 600; fires.push(fire); } // UI Elements var scoreText = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); var waterBombsText = new Text2('Water: 10', { size: 50, fill: 0xFFFFFF }); waterBombsText.anchor.set(0, 0); waterBombsText.x = 150; waterBombsText.y = 50; LK.gui.topLeft.addChild(waterBombsText); var instructionText = new Text2('Use touchpad to control drone, Tap to drop water bombs', { size: 40, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0); instructionText.y = 100; LK.gui.top.addChild(instructionText); // Create touchpad for drone control var touchpadOuter = LK.getAsset('base', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); touchpadOuter.alpha = 0.3; touchpadOuter.tint = 0x666666; var touchpadInner = LK.getAsset('base', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); touchpadInner.alpha = 0.6; touchpadInner.tint = 0xFFFFFF; touchpadOuter.addChild(touchpadInner); LK.gui.bottomRight.addChild(touchpadOuter); touchpadOuter.x = -150; touchpadOuter.y = -150; var touchpadActive = false; var touchpadCenterX = 0; var touchpadCenterY = 0; // Game event handlers game.down = function (x, y, obj) { swipeStartX = x; swipeStartY = y; isSwipeActive = true; // Check if touch is in touchpad area var touchpadPos = LK.gui.bottomRight.toLocal({ x: x, y: y }); var touchpadX = touchpadPos.x - touchpadOuter.x; var touchpadY = touchpadPos.y - touchpadOuter.y; var touchpadRadius = 120; var distanceFromCenter = Math.sqrt(touchpadX * touchpadX + touchpadY * touchpadY); if (distanceFromCenter <= touchpadRadius) { touchpadActive = true; touchpadCenterX = touchpadX; touchpadCenterY = touchpadY; // Move touchpad inner circle to touch position var maxRadius = 60; var clampedX = Math.max(-maxRadius, Math.min(maxRadius, touchpadX)); var clampedY = Math.max(-maxRadius, Math.min(maxRadius, touchpadY)); touchpadInner.x = clampedX; touchpadInner.y = clampedY; } }; game.move = function (x, y, obj) { if (touchpadActive) { var touchpadPos = LK.gui.bottomRight.toLocal({ x: x, y: y }); var touchpadX = touchpadPos.x - touchpadOuter.x; var touchpadY = touchpadPos.y - touchpadOuter.y; // Move touchpad inner circle var maxRadius = 60; var clampedX = Math.max(-maxRadius, Math.min(maxRadius, touchpadX)); var clampedY = Math.max(-maxRadius, Math.min(maxRadius, touchpadY)); touchpadInner.x = clampedX; touchpadInner.y = clampedY; // Calculate drone movement based on touchpad position var moveX = clampedX / maxRadius * 12; // Increased movement speed multiplier var moveY = clampedY / maxRadius * 8; // Increased vertical movement // Apply movement to drone with bounds checking var newX = drone.x + moveX; var newY = drone.y + moveY; drone.x = Math.max(148, Math.min(1900, newX)); drone.y = Math.max(150, Math.min(2580, newY)); } }; game.up = function (x, y, obj) { if (touchpadActive) { touchpadActive = false; // Return touchpad inner to center with smooth animation tween(touchpadInner, { x: 0, y: 0 }, { duration: 200, easing: tween.easeOut }); } else if (isSwipeActive) { var swipeDistanceX = x - swipeStartX; var swipeDistanceY = y - swipeStartY; var swipeDistance = Math.sqrt(swipeDistanceX * swipeDistanceX + swipeDistanceY * swipeDistanceY); if (swipeDistance <= swipeThreshold) { // It's a tap - drop water bomb drone.dropWaterBomb(); } } dragNode = null; isSwipeActive = false; }; game.update = function () { // Check for water bomb collisions with fires for (var i = waterBombs.length - 1; i >= 0; i--) { var waterBomb = waterBombs[i]; for (var j = fires.length - 1; j >= 0; j--) { var fire = fires[j]; if (!fire.extinguished && waterBomb.intersects(fire)) { fire.extinguish(); waterBomb.destroy(); waterBombs.splice(i, 1); fires.splice(j, 1); break; } } } // Check if drone is at base for refill if (drone.intersects(base) && drone.waterBombs < drone.maxWaterBombs) { drone.refillWater(); } // Check win condition if (firesExtinguished >= totalFires) { LK.showYouWin(); } // Check lose condition (no water and fires remaining) if (drone.waterBombs === 0 && waterBombs.length === 0 && fires.length > 0) { var timeoutLose = LK.setTimeout(function () { LK.showGameOver(); }, 2000); } };
===================================================================
--- original.js
+++ change.js
@@ -253,10 +253,10 @@
var touchpadPos = LK.gui.bottomRight.toLocal({
x: x,
y: y
});
- var touchpadX = touchpadPos.x + 150;
- var touchpadY = touchpadPos.y + 150;
+ var touchpadX = touchpadPos.x - touchpadOuter.x;
+ var touchpadY = touchpadPos.y - touchpadOuter.y;
var touchpadRadius = 120;
var distanceFromCenter = Math.sqrt(touchpadX * touchpadX + touchpadY * touchpadY);
if (distanceFromCenter <= touchpadRadius) {
touchpadActive = true;
@@ -275,19 +275,19 @@
var touchpadPos = LK.gui.bottomRight.toLocal({
x: x,
y: y
});
- var touchpadX = touchpadPos.x + 150;
- var touchpadY = touchpadPos.y + 150;
+ var touchpadX = touchpadPos.x - touchpadOuter.x;
+ var touchpadY = touchpadPos.y - touchpadOuter.y;
// Move touchpad inner circle
var maxRadius = 60;
var clampedX = Math.max(-maxRadius, Math.min(maxRadius, touchpadX));
var clampedY = Math.max(-maxRadius, Math.min(maxRadius, touchpadY));
touchpadInner.x = clampedX;
touchpadInner.y = clampedY;
// Calculate drone movement based on touchpad position
- var moveX = clampedX / maxRadius * 8; // Movement speed multiplier
- var moveY = clampedY / maxRadius * 4; // Slower vertical movement
+ var moveX = clampedX / maxRadius * 12; // Increased movement speed multiplier
+ var moveY = clampedY / maxRadius * 8; // Increased vertical movement
// Apply movement to drone with bounds checking
var newX = drone.x + moveX;
var newY = drone.y + moveY;
drone.x = Math.max(148, Math.min(1900, newX));