User prompt
The size didn't go smaller till disappeared make it go smaller smoothly and slowly! ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Start decreasing size of fire when game is started to reach 0 and play gameover. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
let any wood can be dragged to placed again in fire if didn't burned from first time
User prompt
Add assets of the other added colors to list of assets
User prompt
make the wood destroyed after 10 sec and start decreasing the size of fire to 0 to disappeared ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Let the fire size can be reduced to 0x0 size to play game over if player didn't put wood on it.
User prompt
Let the fire size redused each 10sec if no wood placed on it ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
More wood on fire more increasing its size by 10x10 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the fire small 30x30 and not going bigger by time.
User prompt
Burn it only when it is placed on the fire area not when i click on it by cursor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The wood asset is hidden behind the background!
User prompt
duplicate a wood asset teleport it to cursor and when touch fire with it let it burn ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
If i click on woodbutton duplicate one wood of the wood asset from it. if i touch the fire do fire on it on the touched side and make it burning. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Rotate the image of woodbutton by 90° right
User prompt
Move it to the right bottom corner by space area of 100x100
User prompt
The button is hidding behind background or not added to the game screen maybe!
User prompt
Add wood button asset to the game code.
User prompt
Make it start from 10x10 to 150 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the fire small and go bigger by time from 100x100 to 200x200 smoothly and slowly ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Make the fire sound repeated
User prompt
Add firesound to fire animation
User prompt
Add more colors ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
make the background invisible
User prompt
reorder it to be after fire
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FireParticle = Container.expand(function () {
var self = Container.call(this);
// Create particle graphics based on type
var graphics;
self.particleType = 'fire'; // default type
self.setType = function (type) {
if (self.graphics) {
self.removeChild(self.graphics);
}
self.particleType = type;
if (type === 'fire') {
self.graphics = self.attachAsset('fireParticle', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (type === 'core') {
self.graphics = self.attachAsset('fireCore', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (type === 'smoke') {
self.graphics = self.attachAsset('smoke', {
anchorX: 0.5,
anchorY: 0.5
});
}
};
// Initialize with default type
self.setType('fire');
// Particle properties
self.velocityX = 0;
self.velocityY = 0;
self.life = 1.0;
self.maxLife = 1.0;
self.update = function () {
// Move particle
self.x += self.velocityX;
self.y += self.velocityY;
// Reduce life
self.life -= 0.02;
// Update appearance based on life
if (self.graphics) {
self.graphics.alpha = Math.max(0, self.life);
self.graphics.scaleX = self.life;
self.graphics.scaleY = self.life;
}
// Add some randomness to movement
self.velocityX += (Math.random() - 0.5) * 0.5;
self.velocityY += (Math.random() - 0.5) * 0.3;
// Gravity effect for smoke
if (self.particleType === 'smoke') {
self.velocityY -= 0.1;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x51ff00
});
/****
* Game Code
****/
// Add background image fullscreen
var background = game.attachAsset('background1', {
x: 0,
y: 0,
width: 2048,
height: 2732
});
// Fire animation system
var fireParticles = [];
var fireBaseX = 1024; // Center of screen
var fireBaseY = 1800; // Center of screen vertically
var baseFireScale = 0.3; // Base scale factor for fire size (30x30)
var fireScale = baseFireScale; // Current fire scale (will increase with burning wood)
var burningWoodCount = 0; // Track number of burning wood pieces
var lastWoodPlacedTime = LK.ticks; // Track when wood was last placed on fire
var fireReductionTimer = 10 * 60; // 10 seconds at 60fps
// Play fire sound repeatedly
var fireSoundTimer = LK.setInterval(function () {
LK.getSound('Firesound').play();
}, 2000); // Play every 2 seconds
// Create fire particles continuously
var fireTimer = LK.setInterval(function () {
// Create main fire particles
for (var i = 0; i < 8; i++) {
var particle = new FireParticle();
particle.setType('fire');
particle.x = fireBaseX + (Math.random() - 0.5) * 400 * fireScale;
particle.y = fireBaseY + (Math.random() - 0.5) * 160 * fireScale;
particle.velocityX = (Math.random() - 0.5) * 8;
particle.velocityY = -Math.random() * 20 - 8;
particle.life = 1.0;
particle.maxLife = 1.0;
// Add color variation with tween
var colors = [0xff4500, 0xff6500, 0xff8500, 0xffa500, 0x0066ff, 0x00ff66, 0xff00ff, 0x66ffff];
var randomColor = colors[Math.floor(Math.random() * colors.length)];
particle.graphics.tint = randomColor;
// Scale animation - much bigger particles
particle.graphics.scaleX = 2.0 + Math.random() * 2.0;
particle.graphics.scaleY = 2.0 + Math.random() * 2.0;
tween(particle.graphics, {
scaleX: particle.graphics.scaleX * 3.0,
scaleY: particle.graphics.scaleY * 3.0
}, {
duration: 500 + Math.random() * 500,
easing: tween.easeOut
});
fireParticles.push(particle);
game.addChild(particle);
}
// Create core fire particles (yellow/white)
for (var j = 0; j < 5; j++) {
var coreParticle = new FireParticle();
coreParticle.setType('core');
coreParticle.x = fireBaseX + (Math.random() - 0.5) * 250 * fireScale;
coreParticle.y = fireBaseY + (Math.random() - 0.5) * 120 * fireScale;
coreParticle.velocityX = (Math.random() - 0.5) * 6;
coreParticle.velocityY = -Math.random() * 18 - 10;
coreParticle.life = 1.0;
coreParticle.maxLife = 1.0;
// Bright core colors with more white and new colors
var coreColors = [0xffff00, 0xffff88, 0xffffff, 0xffffff, 0xffffff, 0xff66ff, 0x66ffff, 0xffaa00];
var randomCoreColor = coreColors[Math.floor(Math.random() * coreColors.length)];
coreParticle.graphics.tint = randomCoreColor;
// Much bigger core particles
coreParticle.graphics.scaleX = 2.5;
coreParticle.graphics.scaleY = 2.5;
fireParticles.push(coreParticle);
game.addChild(coreParticle);
}
// Create bright white hot center particles
for (var k = 0; k < 3; k++) {
var whiteParticle = new FireParticle();
whiteParticle.setType('core');
whiteParticle.x = fireBaseX + (Math.random() - 0.5) * 150 * fireScale;
whiteParticle.y = fireBaseY + (Math.random() - 0.5) * 80 * fireScale;
whiteParticle.velocityX = (Math.random() - 0.5) * 4;
whiteParticle.velocityY = -Math.random() * 15 - 8;
whiteParticle.life = 1.0;
whiteParticle.maxLife = 1.0;
// Pure white color
whiteParticle.graphics.tint = 0xffffff;
// Intense white hot center particles
whiteParticle.graphics.scaleX = 1.8;
whiteParticle.graphics.scaleY = 1.8;
// Add white glow effect with tween
tween(whiteParticle.graphics, {
scaleX: whiteParticle.graphics.scaleX * 2.5,
scaleY: whiteParticle.graphics.scaleY * 2.5
}, {
duration: 400 + Math.random() * 300,
easing: tween.easeOut
});
fireParticles.push(whiteParticle);
game.addChild(whiteParticle);
}
// Create white base particles at the bottom of the fire
for (var m = 0; m < 6; m++) {
var whiteBaseParticle = new FireParticle();
whiteBaseParticle.setType('core');
whiteBaseParticle.x = fireBaseX + (Math.random() - 0.5) * 200 * fireScale;
whiteBaseParticle.y = fireBaseY + 150 * fireScale + (Math.random() - 0.5) * 100 * fireScale;
whiteBaseParticle.velocityX = (Math.random() - 0.5) * 3;
whiteBaseParticle.velocityY = -Math.random() * 5 - 2;
whiteBaseParticle.life = 1.0;
whiteBaseParticle.maxLife = 1.0;
// Pure white color for base
whiteBaseParticle.graphics.tint = 0xffffff;
// Base white particles same size as other fire particles
whiteBaseParticle.graphics.scaleX = 2.0 + Math.random() * 1.0;
whiteBaseParticle.graphics.scaleY = 2.0 + Math.random() * 1.0;
// Add gentle scaling animation
tween(whiteBaseParticle.graphics, {
scaleX: whiteBaseParticle.graphics.scaleX * 2.0,
scaleY: whiteBaseParticle.graphics.scaleY * 2.0
}, {
duration: 600 + Math.random() * 400,
easing: tween.easeOut
});
fireParticles.push(whiteBaseParticle);
game.addChild(whiteBaseParticle);
// Move white base particles to back (behind fire)
game.setChildIndex(whiteBaseParticle, 1);
}
// Create smoke particles (black/dark)
if (Math.random() < 0.5) {
var smokeParticle = new FireParticle();
smokeParticle.setType('smoke');
smokeParticle.x = fireBaseX + (Math.random() - 0.5) * 320 * fireScale;
smokeParticle.y = fireBaseY - 300 * fireScale - Math.random() * 200 * fireScale;
smokeParticle.velocityX = (Math.random() - 0.5) * 10;
smokeParticle.velocityY = -Math.random() * 10 - 4;
smokeParticle.life = 1.0;
smokeParticle.maxLife = 1.0;
// Dark smoke colors with new colorful variants
var smokeColors = [0x333333, 0x555555, 0x777777, 0x004455, 0x440055, 0x554400];
var randomSmokeColor = smokeColors[Math.floor(Math.random() * smokeColors.length)];
smokeParticle.graphics.tint = randomSmokeColor;
// Smoke grows as it rises - much bigger smoke
tween(smokeParticle.graphics, {
scaleX: 5,
scaleY: 5
}, {
duration: 2000,
easing: tween.easeOut
});
fireParticles.push(smokeParticle);
game.addChild(smokeParticle);
}
}, 80);
// Update fire system
game.update = function () {
// Count burning wood pieces and update fire scale
burningWoodCount = 0;
for (var w = 0; w < woodPieces.length; w++) {
if (woodPieces[w].isBurning) {
burningWoodCount++;
}
}
// Check if 10 seconds have passed since last wood placement
if (LK.ticks - lastWoodPlacedTime >= fireReductionTimer) {
// Reduce fire scale if it's above base scale
if (fireScale > baseFireScale) {
fireScale = Math.max(baseFireScale, fireScale - 10.0 / 100.0); // Reduce by 10x10 pixels worth
}
// Reset timer for next reduction cycle
lastWoodPlacedTime = LK.ticks;
}
// Update fire scale: base scale + 10x10 pixels worth of scale per burning wood
// 10x10 pixels at base resolution translates to scale increase
var scaleIncrease = burningWoodCount * (10.0 / 100.0); // 10 pixels out of 100 pixel base asset
fireScale = Math.max(baseFireScale, fireScale + scaleIncrease);
// Update and clean up particles
for (var i = fireParticles.length - 1; i >= 0; i--) {
var particle = fireParticles[i];
// Remove dead particles
if (particle.life <= 0) {
particle.destroy();
fireParticles.splice(i, 1);
continue;
}
}
// Update wood burning particles
for (var w = 0; w < woodPieces.length; w++) {
var wood = woodPieces[w];
if (wood.isBurning) {
// Clean up dead burn particles
for (var b = wood.burnParticles.length - 1; b >= 0; b--) {
var burnParticle = wood.burnParticles[b];
if (burnParticle.life <= 0) {
wood.burnParticles.splice(b, 1);
}
}
}
}
// Add flickering effect to the fire base
if (LK.ticks % 10 === 0) {
fireBaseX = 1024 + (Math.random() - 0.5) * 120 * fireScale;
}
};
// Array to track wood pieces
var woodPieces = [];
var draggedWood = null; // Track currently dragged wood
var woodButton = game.attachAsset('woodButton', {
x: 2048 - 100 - 100,
y: 2732 - 100 - 50,
// Adjusted Y to account for button height
anchorX: 0.5,
anchorY: 0.5
});
// Ensure wood button is visible on top of background
game.setChildIndex(woodButton, game.children.length - 1);
// Wood button click handler
woodButton.down = function (x, y, obj) {
// Create new wood piece at button position
var newWood = game.attachAsset('Wood', {
x: woodButton.x,
y: woodButton.y,
anchorX: 0.5,
anchorY: 0.5
});
// Add wood piece properties
newWood.isBurning = false;
newWood.burnParticles = [];
newWood.isDragging = true; // Mark as dragging
woodPieces.push(newWood);
// Ensure wood piece is visible on top of background
game.setChildIndex(newWood, game.children.length - 1);
// Set as active dragged wood
draggedWood = newWood;
};
// Game move handler for dragging wood
game.move = function (x, y, obj) {
if (draggedWood) {
draggedWood.x = x;
draggedWood.y = y;
}
};
// Game touch handler - no click-to-burn functionality
game.down = function (x, y, obj) {
// No action needed - wood only burns when placed on fire area
};
// Game up handler to stop dragging and check for fire placement
game.up = function (x, y, obj) {
if (draggedWood) {
// Check if wood is placed on fire area when released
var fireDistance = Math.sqrt(Math.pow(draggedWood.x - fireBaseX, 2) + Math.pow(draggedWood.y - fireBaseY, 2));
if (fireDistance < 200 * fireScale && !draggedWood.isBurning) {
draggedWood.isBurning = true;
lastWoodPlacedTime = LK.ticks; // Update last wood placement time
startWoodBurning(draggedWood, draggedWood.x, draggedWood.y);
}
draggedWood.isDragging = false;
draggedWood = null;
}
};
// Function to start wood burning at touch position
function startWoodBurning(wood, touchX, touchY) {
// Create fire particles on the touched side of the wood
var fireTimer = LK.setInterval(function () {
for (var j = 0; j < 3; j++) {
var burnParticle = new FireParticle();
burnParticle.setType('fire');
burnParticle.x = touchX + (Math.random() - 0.5) * 60;
burnParticle.y = touchY + (Math.random() - 0.5) * 30;
burnParticle.velocityX = (Math.random() - 0.5) * 4;
burnParticle.velocityY = -Math.random() * 8 - 2;
burnParticle.life = 1.0;
burnParticle.maxLife = 1.0;
var burnColors = [0xff4500, 0xff6500, 0xffa500];
var randomBurnColor = burnColors[Math.floor(Math.random() * burnColors.length)];
burnParticle.graphics.tint = randomBurnColor;
burnParticle.graphics.scaleX = 0.5 + Math.random() * 0.5;
burnParticle.graphics.scaleY = 0.5 + Math.random() * 0.5;
wood.burnParticles.push(burnParticle);
fireParticles.push(burnParticle);
game.addChild(burnParticle);
}
}, 200);
wood.fireTimer = fireTimer;
} ===================================================================
--- original.js
+++ change.js
@@ -86,8 +86,10 @@
var fireBaseY = 1800; // Center of screen vertically
var baseFireScale = 0.3; // Base scale factor for fire size (30x30)
var fireScale = baseFireScale; // Current fire scale (will increase with burning wood)
var burningWoodCount = 0; // Track number of burning wood pieces
+var lastWoodPlacedTime = LK.ticks; // Track when wood was last placed on fire
+var fireReductionTimer = 10 * 60; // 10 seconds at 60fps
// Play fire sound repeatedly
var fireSoundTimer = LK.setInterval(function () {
LK.getSound('Firesound').play();
}, 2000); // Play every 2 seconds
@@ -228,12 +230,21 @@
if (woodPieces[w].isBurning) {
burningWoodCount++;
}
}
+ // Check if 10 seconds have passed since last wood placement
+ if (LK.ticks - lastWoodPlacedTime >= fireReductionTimer) {
+ // Reduce fire scale if it's above base scale
+ if (fireScale > baseFireScale) {
+ fireScale = Math.max(baseFireScale, fireScale - 10.0 / 100.0); // Reduce by 10x10 pixels worth
+ }
+ // Reset timer for next reduction cycle
+ lastWoodPlacedTime = LK.ticks;
+ }
// Update fire scale: base scale + 10x10 pixels worth of scale per burning wood
// 10x10 pixels at base resolution translates to scale increase
var scaleIncrease = burningWoodCount * (10.0 / 100.0); // 10 pixels out of 100 pixel base asset
- fireScale = baseFireScale + scaleIncrease;
+ fireScale = Math.max(baseFireScale, fireScale + scaleIncrease);
// Update and clean up particles
for (var i = fireParticles.length - 1; i >= 0; i--) {
var particle = fireParticles[i];
// Remove dead particles
@@ -309,8 +320,9 @@
// Check if wood is placed on fire area when released
var fireDistance = Math.sqrt(Math.pow(draggedWood.x - fireBaseX, 2) + Math.pow(draggedWood.y - fireBaseY, 2));
if (fireDistance < 200 * fireScale && !draggedWood.isBurning) {
draggedWood.isBurning = true;
+ lastWoodPlacedTime = LK.ticks; // Update last wood placement time
startWoodBurning(draggedWood, draggedWood.x, draggedWood.y);
}
draggedWood.isDragging = false;
draggedWood = null;