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.autoMove = true; self.moveSpeed = 2; self.direction = 1; // 1 for right, -1 for left self.minX = 148; self.maxX = 1900; 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(); } }; self.update = function () { if (self.autoMove) { // Move drone automatically left and right self.x += self.moveSpeed * self.direction; // Change direction when hitting boundaries if (self.x >= self.maxX) { self.direction = -1; self.x = self.maxX; } else if (self.x <= self.minX) { self.direction = 1; self.x = self.minX; } } }; 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); } ; // Start background music LK.playMusic('123firefighterdrone'); // 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('Drone moves automatically - tap to drop water bombs', { size: 40, fill: 0xFFFFFF }); instructionText.anchor.set(0.5, 0); instructionText.y = 100; LK.gui.top.addChild(instructionText); // Game event handlers game.down = function (x, y, obj) { swipeStartX = x; swipeStartY = y; isSwipeActive = true; // Stop any existing movement for immediate response tween.stop(drone, { x: true }); }; // Remove move handler to prevent interference with swipe control game.up = function (x, y, obj) { if (isSwipeActive) { var swipeDistanceX = x - swipeStartX; var swipeDistanceY = y - swipeStartY; var swipeDistance = Math.sqrt(swipeDistanceX * swipeDistanceX + swipeDistanceY * swipeDistanceY); if (swipeDistance > swipeThreshold) { // It's a swipe - check if horizontal movement is dominant if (Math.abs(swipeDistanceX) > Math.abs(swipeDistanceY)) { // Stop any existing movement tween.stop(drone, { x: true }); if (swipeDistanceX > 0) { // Swipe right - move drone right by fixed distance tween(drone, { x: Math.min(1900, drone.x + droneSpeed) }, { duration: 100, easing: tween.easeOut }); } else { // Swipe left - move drone left by fixed distance tween(drone, { x: Math.max(148, drone.x - droneSpeed) }, { duration: 100, easing: tween.easeOut }); } } } else { // It's a tap - drop water bomb drone.dropWaterBomb(); } } 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
@@ -234,9 +234,9 @@
waterBombsText.anchor.set(0, 0);
waterBombsText.x = 150;
waterBombsText.y = 50;
LK.gui.topLeft.addChild(waterBombsText);
-var instructionText = new Text2('Drone moves automatically and drops water bombs', {
+var instructionText = new Text2('Drone moves automatically - tap to drop water bombs', {
size: 40,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
@@ -290,12 +290,8 @@
}
isSwipeActive = false;
};
game.update = function () {
- // Auto drop water bombs every 60 ticks (1 second) when drone has water and there are fires
- if (LK.ticks % 60 === 0 && drone.waterBombs > 0 && fires.length > 0) {
- drone.dropWaterBomb();
- }
// 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--) {