/**** * 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; // Map of all available particle types to their assets var assetMap = { 'fire': 'fireParticle', 'core': 'fireCore', 'smoke': 'smoke', 'fireBlue': 'fireBlue', 'fireCyan': 'fireCyan', 'fireGold': 'fireGold', 'fireGreen': 'fireGreen', 'fireLightOrange': 'fireLightOrange', 'fireMagenta': 'fireMagenta', 'fireOrange': 'fireOrange', 'firePurple': 'firePurple', 'fireYellowWhite': 'fireYellowWhite', 'whiteParticle': 'whiteParticle', 'smokeGray': 'smokeGray', 'smokeLightGray': 'smokeLightGray', 'smokePurple': 'smokePurple', 'smokeTeal': 'smokeTeal', 'smokeYellow': 'smokeYellow' }; // Create asset based on type if (assetMap[type]) { self.graphics = self.attachAsset(assetMap[type], { anchorX: 0.5, anchorY: 0.5 }); // Store if this is a smoke type self.isSmokeType = type.indexOf('smoke') === 0 || type === 'smoke'; } }; // 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.isSmokeType) { 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 }); // Start playing game music LK.playMusic('GameMusic'); // Fire animation system var fireParticles = []; var fireBaseX = 1024; // Center of screen var fireBaseY = 1966; // Lowered by 600px from center (200px + 400px) // 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 using all color assets for (var i = 0; i < 8; i++) { var particle = new FireParticle(); // Use all fire color assets randomly var fireTypes = ['fire', 'fireBlue', 'fireCyan', 'fireGold', 'fireGreen', 'fireLightOrange', 'fireMagenta', 'fireOrange', 'firePurple']; var randomType = fireTypes[Math.floor(Math.random() * fireTypes.length)]; particle.setType(randomType); particle.x = fireBaseX + (Math.random() - 0.5) * 400; particle.y = fireBaseY + (Math.random() - 0.5) * 160; particle.velocityX = (Math.random() - 0.5) * 8; particle.velocityY = -Math.random() * 20 - 8; particle.life = 1.0; particle.maxLife = 1.0; // 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 floating particles that move around the fire for (var f = 0; f < 5; f++) { var floatingParticle = new FireParticle(); // Use all fire color assets randomly var floatingTypes = ['fire', 'fireBlue', 'fireCyan', 'fireGold', 'fireGreen', 'fireLightOrange', 'fireMagenta', 'fireOrange', 'firePurple']; var randomFloatingType = floatingTypes[Math.floor(Math.random() * floatingTypes.length)]; floatingParticle.setType(randomFloatingType); // Position around the fire in a much wider area var angle = Math.random() * Math.PI * 2; var distance = 500 + Math.random() * 300; floatingParticle.x = fireBaseX + Math.cos(angle) * distance; floatingParticle.y = fireBaseY + Math.sin(angle) * distance; floatingParticle.velocityX = 0; floatingParticle.velocityY = 0; floatingParticle.life = 1.0; floatingParticle.maxLife = 1.0; // Smaller floating particles floatingParticle.graphics.scaleX = 1.0 + Math.random() * 0.5; floatingParticle.graphics.scaleY = 1.0 + Math.random() * 0.5; // Create circular floating motion around the fire var radius = distance; var speed = 0.02 + Math.random() * 0.02; var startAngle = angle; tween(floatingParticle, { x: fireBaseX + Math.cos(startAngle + Math.PI * 2) * radius, y: fireBaseY + Math.sin(startAngle + Math.PI * 2) * radius }, { duration: Math.PI * 2 / speed * 16, // Complete circle easing: tween.linear, onFinish: function onFinish() { // Continue circular motion tween(floatingParticle, { x: fireBaseX + Math.cos(startAngle + Math.PI * 4) * radius, y: fireBaseY + Math.sin(startAngle + Math.PI * 4) * radius }, { duration: Math.PI * 2 / speed * 16, easing: tween.linear }); } }); fireParticles.push(floatingParticle); game.addChild(floatingParticle); } // Create core fire particles (yellow/white) for (var j = 0; j < 5; j++) { var coreParticle = new FireParticle(); // Use core and yellow/white assets var coreTypes = ['core', 'fireYellowWhite', 'whiteParticle']; var randomCoreType = coreTypes[Math.floor(Math.random() * coreTypes.length)]; coreParticle.setType(randomCoreType); coreParticle.x = fireBaseX + (Math.random() - 0.5) * 250; coreParticle.y = fireBaseY + (Math.random() - 0.5) * 120; coreParticle.velocityX = (Math.random() - 0.5) * 6; coreParticle.velocityY = -Math.random() * 18 - 10; coreParticle.life = 1.0; coreParticle.maxLife = 1.0; // 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('whiteParticle'); whiteParticle.x = fireBaseX + (Math.random() - 0.5) * 150; whiteParticle.y = fireBaseY + (Math.random() - 0.5) * 80; whiteParticle.velocityX = (Math.random() - 0.5) * 4; whiteParticle.velocityY = -Math.random() * 15 - 8; whiteParticle.life = 1.0; whiteParticle.maxLife = 1.0; // 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('whiteParticle'); whiteBaseParticle.x = fireBaseX + (Math.random() - 0.5) * 200; whiteBaseParticle.y = fireBaseY + 150 + (Math.random() - 0.5) * 100; whiteBaseParticle.velocityX = (Math.random() - 0.5) * 3; whiteBaseParticle.velocityY = -Math.random() * 5 - 2; whiteBaseParticle.life = 1.0; whiteBaseParticle.maxLife = 1.0; // 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(); // Use all smoke color assets var smokeTypes = ['smoke', 'smokeGray', 'smokeLightGray', 'smokePurple', 'smokeTeal', 'smokeYellow']; var randomSmokeType = smokeTypes[Math.floor(Math.random() * smokeTypes.length)]; smokeParticle.setType(randomSmokeType); smokeParticle.x = fireBaseX + (Math.random() - 0.5) * 320; smokeParticle.y = fireBaseY - 300 - Math.random() * 200; smokeParticle.velocityX = (Math.random() - 0.5) * 10; smokeParticle.velocityY = -Math.random() * 10 - 4; smokeParticle.life = 1.0; smokeParticle.maxLife = 1.0; // 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 () { // 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; } } // Add flickering effect to the fire base if (LK.ticks % 10 === 0) { fireBaseX = 1024 + (Math.random() - 0.5) * 120; } };
/****
* 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;
// Map of all available particle types to their assets
var assetMap = {
'fire': 'fireParticle',
'core': 'fireCore',
'smoke': 'smoke',
'fireBlue': 'fireBlue',
'fireCyan': 'fireCyan',
'fireGold': 'fireGold',
'fireGreen': 'fireGreen',
'fireLightOrange': 'fireLightOrange',
'fireMagenta': 'fireMagenta',
'fireOrange': 'fireOrange',
'firePurple': 'firePurple',
'fireYellowWhite': 'fireYellowWhite',
'whiteParticle': 'whiteParticle',
'smokeGray': 'smokeGray',
'smokeLightGray': 'smokeLightGray',
'smokePurple': 'smokePurple',
'smokeTeal': 'smokeTeal',
'smokeYellow': 'smokeYellow'
};
// Create asset based on type
if (assetMap[type]) {
self.graphics = self.attachAsset(assetMap[type], {
anchorX: 0.5,
anchorY: 0.5
});
// Store if this is a smoke type
self.isSmokeType = type.indexOf('smoke') === 0 || type === 'smoke';
}
};
// 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.isSmokeType) {
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
});
// Start playing game music
LK.playMusic('GameMusic');
// Fire animation system
var fireParticles = [];
var fireBaseX = 1024; // Center of screen
var fireBaseY = 1966; // Lowered by 600px from center (200px + 400px)
// 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 using all color assets
for (var i = 0; i < 8; i++) {
var particle = new FireParticle();
// Use all fire color assets randomly
var fireTypes = ['fire', 'fireBlue', 'fireCyan', 'fireGold', 'fireGreen', 'fireLightOrange', 'fireMagenta', 'fireOrange', 'firePurple'];
var randomType = fireTypes[Math.floor(Math.random() * fireTypes.length)];
particle.setType(randomType);
particle.x = fireBaseX + (Math.random() - 0.5) * 400;
particle.y = fireBaseY + (Math.random() - 0.5) * 160;
particle.velocityX = (Math.random() - 0.5) * 8;
particle.velocityY = -Math.random() * 20 - 8;
particle.life = 1.0;
particle.maxLife = 1.0;
// 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 floating particles that move around the fire
for (var f = 0; f < 5; f++) {
var floatingParticle = new FireParticle();
// Use all fire color assets randomly
var floatingTypes = ['fire', 'fireBlue', 'fireCyan', 'fireGold', 'fireGreen', 'fireLightOrange', 'fireMagenta', 'fireOrange', 'firePurple'];
var randomFloatingType = floatingTypes[Math.floor(Math.random() * floatingTypes.length)];
floatingParticle.setType(randomFloatingType);
// Position around the fire in a much wider area
var angle = Math.random() * Math.PI * 2;
var distance = 500 + Math.random() * 300;
floatingParticle.x = fireBaseX + Math.cos(angle) * distance;
floatingParticle.y = fireBaseY + Math.sin(angle) * distance;
floatingParticle.velocityX = 0;
floatingParticle.velocityY = 0;
floatingParticle.life = 1.0;
floatingParticle.maxLife = 1.0;
// Smaller floating particles
floatingParticle.graphics.scaleX = 1.0 + Math.random() * 0.5;
floatingParticle.graphics.scaleY = 1.0 + Math.random() * 0.5;
// Create circular floating motion around the fire
var radius = distance;
var speed = 0.02 + Math.random() * 0.02;
var startAngle = angle;
tween(floatingParticle, {
x: fireBaseX + Math.cos(startAngle + Math.PI * 2) * radius,
y: fireBaseY + Math.sin(startAngle + Math.PI * 2) * radius
}, {
duration: Math.PI * 2 / speed * 16,
// Complete circle
easing: tween.linear,
onFinish: function onFinish() {
// Continue circular motion
tween(floatingParticle, {
x: fireBaseX + Math.cos(startAngle + Math.PI * 4) * radius,
y: fireBaseY + Math.sin(startAngle + Math.PI * 4) * radius
}, {
duration: Math.PI * 2 / speed * 16,
easing: tween.linear
});
}
});
fireParticles.push(floatingParticle);
game.addChild(floatingParticle);
}
// Create core fire particles (yellow/white)
for (var j = 0; j < 5; j++) {
var coreParticle = new FireParticle();
// Use core and yellow/white assets
var coreTypes = ['core', 'fireYellowWhite', 'whiteParticle'];
var randomCoreType = coreTypes[Math.floor(Math.random() * coreTypes.length)];
coreParticle.setType(randomCoreType);
coreParticle.x = fireBaseX + (Math.random() - 0.5) * 250;
coreParticle.y = fireBaseY + (Math.random() - 0.5) * 120;
coreParticle.velocityX = (Math.random() - 0.5) * 6;
coreParticle.velocityY = -Math.random() * 18 - 10;
coreParticle.life = 1.0;
coreParticle.maxLife = 1.0;
// 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('whiteParticle');
whiteParticle.x = fireBaseX + (Math.random() - 0.5) * 150;
whiteParticle.y = fireBaseY + (Math.random() - 0.5) * 80;
whiteParticle.velocityX = (Math.random() - 0.5) * 4;
whiteParticle.velocityY = -Math.random() * 15 - 8;
whiteParticle.life = 1.0;
whiteParticle.maxLife = 1.0;
// 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('whiteParticle');
whiteBaseParticle.x = fireBaseX + (Math.random() - 0.5) * 200;
whiteBaseParticle.y = fireBaseY + 150 + (Math.random() - 0.5) * 100;
whiteBaseParticle.velocityX = (Math.random() - 0.5) * 3;
whiteBaseParticle.velocityY = -Math.random() * 5 - 2;
whiteBaseParticle.life = 1.0;
whiteBaseParticle.maxLife = 1.0;
// 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();
// Use all smoke color assets
var smokeTypes = ['smoke', 'smokeGray', 'smokeLightGray', 'smokePurple', 'smokeTeal', 'smokeYellow'];
var randomSmokeType = smokeTypes[Math.floor(Math.random() * smokeTypes.length)];
smokeParticle.setType(randomSmokeType);
smokeParticle.x = fireBaseX + (Math.random() - 0.5) * 320;
smokeParticle.y = fireBaseY - 300 - Math.random() * 200;
smokeParticle.velocityX = (Math.random() - 0.5) * 10;
smokeParticle.velocityY = -Math.random() * 10 - 4;
smokeParticle.life = 1.0;
smokeParticle.maxLife = 1.0;
// 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 () {
// 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;
}
}
// Add flickering effect to the fire base
if (LK.ticks % 10 === 0) {
fireBaseX = 1024 + (Math.random() - 0.5) * 120;
}
};