/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var BackgroundGradient = Container.expand(function () {
var self = Container.call(this);
self.gradientElements = [];
self.init = function () {
// Create gradient effect with multiple layers
for (var i = 0; i < 5; i++) {
var element = self.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 25,
scaleY: 25,
tint: 0x1a0000
});
element.x = 1024;
element.y = 1366 + i * 300;
element.alpha = 0.05 + i * 0.02;
self.gradientElements.push(element);
}
};
return self;
});
var Ball = Container.expand(function () {
var self = Container.call(this);
self.ballGraphics = null;
self.points = 5;
self.speed = 0;
self.vx = 0;
self.vy = 0;
self.behavior = 'static';
self.fleeDistance = 150;
self.collected = false;
self.init = function (level) {
// Calculate base level and difficulty tier
var baseLevel = (level - 1) % 9 + 1;
var difficultyTier = Math.floor((level - 1) / 9);
// Create ball graphic with glow effect
self.ballGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFFD700
});
// Add inner glow
var innerGlow = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.05,
scaleY: 1.05,
tint: 0xFFFFFF
});
innerGlow.alpha = 0.8;
// Add outer glow
var outerGlow = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.95,
scaleY: 1.95,
tint: 0xFF6B6B
});
outerGlow.alpha = 0.3;
// Pulsing animation
tween(outerGlow, {
scaleX: 2.25,
scaleY: 2.25,
alpha: 0.1
}, {
duration: 1000,
easing: tween.easeInOut,
loop: true,
yoyo: true
});
// Set behavior based on base level
if (baseLevel === 1) {
self.behavior = 'static';
self.x = 200 + Math.random() * 1648;
self.y = 300 + Math.random() * 2132;
// Apply difficulty modifiers
self.points = 5 + difficultyTier * 2;
} else if (baseLevel === 2) {
self.behavior = 'random';
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.speed = (1 + Math.random() * 2) * (1 + difficultyTier * 0.3);
var angle = Math.random() * Math.PI * 2;
self.vx = Math.cos(angle) * self.speed;
self.vy = Math.sin(angle) * self.speed;
self.points = 7 + difficultyTier * 3;
} else if (baseLevel === 3) {
self.behavior = 'falling';
self.x = Math.random() * 2048;
self.y = -50;
self.vy = (2 + Math.random() * 3) * (1 + difficultyTier * 0.4);
self.points = 7 + difficultyTier * 3;
} else if (baseLevel === 4) {
self.behavior = 'fleeing';
self.x = 200 + Math.random() * 1648;
self.y = 300 + Math.random() * 2132;
self.speed = 3 * (1 + difficultyTier * 0.3);
self.fleeDistance = 150 + difficultyTier * 50;
self.points = 10 + difficultyTier * 4;
} else if (baseLevel === 5) {
self.behavior = 'roaming';
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.speed = (4 + Math.random() * 2) * (1 + difficultyTier * 0.4);
var angle = Math.random() * Math.PI * 2;
self.vx = Math.cos(angle) * self.speed;
self.vy = Math.sin(angle) * self.speed;
self.points = 15 + difficultyTier * 5;
} else if (baseLevel === 6) {
// Level 6: Orbiting balls
self.behavior = 'orbiting';
self.orbitCenterX = 1024;
self.orbitCenterY = 1366;
self.orbitRadius = 200 + Math.random() * 300 - difficultyTier * 30;
self.orbitAngle = Math.random() * Math.PI * 2;
self.orbitSpeed = (0.01 + Math.random() * 0.02) * (1 + difficultyTier * 0.3);
self.points = 12 + difficultyTier * 4;
} else if (baseLevel === 7) {
// Level 7: Mix of fleeing and static balls
if (Math.random() < 0.7 + difficultyTier * 0.1) {
self.behavior = 'fleeing';
self.speed = (4 + Math.random() * 2) * (1 + difficultyTier * 0.3);
self.fleeDistance = 200 + difficultyTier * 50;
self.points = 15 + difficultyTier * 5;
} else {
self.behavior = 'static';
self.points = 5 + difficultyTier * 2;
}
self.x = 200 + Math.random() * 1648;
self.y = 300 + Math.random() * 2132;
} else if (baseLevel === 8) {
// Level 8: Phasing balls that appear and disappear
self.behavior = 'phasing';
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.phaseTimer = 0;
self.phaseInterval = Math.max(60, 120 + Math.random() * 60 - difficultyTier * 20);
self.visible = true;
self.points = 20 + difficultyTier * 6;
// Some balls are negative (decoy)
if (Math.random() < 0.3 + difficultyTier * 0.1) {
self.isNegative = true;
self.points = -(15 + difficultyTier * 5);
self.ballGraphics.tint = 0xFF4444; // Red tint for negative
}
} else if (baseLevel === 9) {
// Level 9: Chameleon balls that change color
self.behavior = 'chameleon';
self.x = Math.random() * 2048;
self.y = Math.random() * 2732;
self.speed = (3 + Math.random() * 3) * (1 + difficultyTier * 0.3);
var angle = Math.random() * Math.PI * 2;
self.vx = Math.cos(angle) * self.speed;
self.vy = Math.sin(angle) * self.speed;
self.colorTimer = 0;
self.colorInterval = Math.max(90, 180 + Math.random() * 120 - difficultyTier * 30);
self.currentColor = 0;
self.colors = [0xFFD700, 0xFF4444, 0x44FF44]; // Gold, Red, Green
self.points = 25 + difficultyTier * 7;
}
// Apply difficulty modifiers to visual effects
if (difficultyTier > 0) {
// Make balls slightly smaller at higher difficulties
var sizeModifier = 1 - difficultyTier * 0.1;
self.ballGraphics.scaleX *= sizeModifier;
self.ballGraphics.scaleY *= sizeModifier;
innerGlow.scaleX *= sizeModifier;
innerGlow.scaleY *= sizeModifier;
outerGlow.scaleX *= sizeModifier;
outerGlow.scaleY *= sizeModifier;
}
// Spawn animation with rotation and scale
self.scaleX = 0;
self.scaleY = 0;
self.rotation = Math.random() * Math.PI * 2;
tween(self, {
scaleX: 1,
scaleY: 1,
rotation: 0
}, {
duration: 800,
easing: tween.bounceOut
});
};
self.update = function () {
if (self.collected) {
return;
}
if (self.behavior === 'random') {
self.x += self.vx;
self.y += self.vy;
// Bounce off walls
if (self.x <= 40 || self.x >= 2008) {
self.vx = -self.vx;
LK.getSound('bounce').play();
}
if (self.y <= 40 || self.y >= 2692) {
self.vy = -self.vy;
LK.getSound('bounce').play();
}
} else if (self.behavior === 'falling') {
self.y += self.vy;
// Remove if off screen
if (self.y > 2782) {
self.collected = true;
for (var i = 0; i < balls.length; i++) {
if (balls[i] === self) {
balls.splice(i, 1);
break;
}
}
LK.getSound('fall').play();
self.destroy();
}
} else if (self.behavior === 'fleeing') {
// Flee from mouse position
if (mouseX !== null && mouseY !== null) {
var dx = self.x - mouseX;
var dy = self.y - mouseY;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < self.fleeDistance && dist > 0) {
// Normalize and apply flee force
dx /= dist;
dy /= dist;
self.x += dx * self.speed;
self.y += dy * self.speed;
// Keep within bounds
self.x = Math.max(40, Math.min(2008, self.x));
self.y = Math.max(40, Math.min(2692, self.y));
// Play flee sound occasionally
if (Math.random() < 0.02) {
LK.getSound('flee').play();
}
}
}
} else if (self.behavior === 'roaming') {
self.x += self.vx;
self.y += self.vy;
// Bounce off walls
if (self.x <= 40 || self.x >= 2008) {
self.vx = -self.vx;
LK.getSound('bounce').play();
}
if (self.y <= 40 || self.y >= 2692) {
self.vy = -self.vy;
LK.getSound('bounce').play();
}
// Occasionally change direction
if (Math.random() < 0.02) {
var angle = Math.random() * Math.PI * 2;
self.vx = Math.cos(angle) * self.speed;
self.vy = Math.sin(angle) * self.speed;
LK.getSound('roam').play();
}
} else if (self.behavior === 'orbiting') {
// Orbital movement around center point
self.orbitAngle += self.orbitSpeed;
self.x = self.orbitCenterX + Math.cos(self.orbitAngle) * self.orbitRadius;
self.y = self.orbitCenterY + Math.sin(self.orbitAngle) * self.orbitRadius;
self.rotation = self.orbitAngle + Math.PI / 2;
// Play orbit sound occasionally
if (Math.random() < 0.005) {
LK.getSound('orbit').play();
}
} else if (self.behavior === 'phasing') {
// Phase in and out of visibility
self.phaseTimer++;
if (self.phaseTimer >= self.phaseInterval) {
self.phaseTimer = 0;
self.visible = !self.visible;
self.alpha = self.visible ? 1 : 0.3;
// Can only be collected when fully visible
self.interactive = self.visible;
LK.getSound('phase').play();
}
} else if (self.behavior === 'chameleon') {
// Change colors periodically
self.colorTimer++;
if (self.colorTimer >= self.colorInterval) {
self.colorTimer = 0;
self.currentColor = (self.currentColor + 1) % self.colors.length;
tween(self.ballGraphics, {
tint: self.colors[self.currentColor]
}, {
duration: 500,
easing: tween.easeInOut
});
LK.getSound('colorChange').play();
}
// Roaming movement
self.x += self.vx;
self.y += self.vy;
// Bounce off walls
if (self.x <= 40 || self.x >= 2008) {
self.vx = -self.vx;
LK.getSound('bounce').play();
}
if (self.y <= 40 || self.y >= 2692) {
self.vy = -self.vy;
LK.getSound('bounce').play();
}
}
};
self.down = function () {
if (self.collected) {
return;
}
self.collected = true;
// Calculate points based on ball type
var basePoints = self.points;
// Check if ball is red (any red tint value)
if (self.ballGraphics && (self.ballGraphics.tint === 0xFF4444 || self.ballGraphics.tint === 0xFF0000 || self.ballGraphics.tint >= 0xFF0000 && self.ballGraphics.tint <= 0xFF4444)) {
basePoints = 5; // All red balls give 5 points
} else if (self.behavior === 'fleeing') {
basePoints = 10;
} else if (self.behavior === 'roaming') {
basePoints = 15;
} else if (self.behavior === 'falling') {
basePoints = 7;
} else if (self.behavior === 'orbiting') {
basePoints = 12;
} else if (self.behavior === 'phasing') {
basePoints = 20;
} else if (self.behavior === 'chameleon') {
// Level 9: Check if ball matches target color
if (currentLevel === 9 && self.ballGraphics && targetColor) {
// First check if it's red - red balls always give 5 points
if (self.ballGraphics.tint === 0xFF4444 || self.ballGraphics.tint === 0xFF0000) {
basePoints = 5;
} else if (self.ballGraphics.tint === targetColor) {
basePoints = 30; // Bonus for matching color
} else {
basePoints = 5; // Reduced points for wrong color
}
} else {
basePoints = 25;
}
}
// Handle negative balls (Level 8)
if (self.isNegative) {
basePoints = -15;
// Create warning effect
createExplosion(self.x, self.y, 0xFF0000);
screenShake(15, 400);
}
// Award points
LK.setScore(LK.getScore() + basePoints);
LK.getSound('hit').play();
// Create floating score text
var scoreFloat = game.addChild(new Container());
scoreFloat.x = self.x;
scoreFloat.y = self.y;
var floatText = new Text2('+' + basePoints, {
size: 60,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
floatText.anchor.set(0.5, 0.5);
scoreFloat.addChild(floatText);
// Animate floating score
tween(scoreFloat, {
y: self.y - 100,
alpha: 0
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
scoreFloat.destroy();
}
});
// Collection animation
tween(self.ballGraphics, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
for (var i = 0; i < balls.length; i++) {
if (balls[i] === self) {
balls.splice(i, 1);
break;
}
}
self.destroy();
}
});
// Create particle effect - bright red explosion
createExplosion(self.x, self.y, 0xFF0000);
};
return self;
});
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdPixel = self.attachAsset('birdPixel', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetX = 0;
self.targetY = 0;
self.speed = 0.02;
self.update = function () {
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
self.x += dx * self.speed;
self.y += dy * self.speed;
if (Math.abs(dx) < 5 && Math.abs(dy) < 5) {
self.findNewTarget();
}
};
self.findNewTarget = function () {
var angle = Math.random() * Math.PI * 2;
var distance = 100 + Math.random() * 200;
self.targetX = self.x + Math.cos(angle) * distance;
self.targetY = self.y + Math.sin(angle) * distance;
self.targetX = Math.max(100, Math.min(1948, self.targetX));
self.targetY = Math.max(100, Math.min(1000, self.targetY));
};
return self;
});
var FloatingElement = Container.expand(function () {
var self = Container.call(this);
self.elementGraphics = null;
self.floatSpeed = 0.5;
self.bobAmount = 2;
self.bobSpeed = 0.05;
self.initialY = 0;
self.time = 0;
self.init = function (type, x, y) {
self.x = x;
self.y = y;
self.initialY = y;
self.time = Math.random() * Math.PI * 2;
if (type === 'cloud') {
// Create cloud with multiple layers
var cloudBase = self.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 0.8,
tint: 0x2a2a2a
});
cloudBase.alpha = 0.3;
self.elementGraphics = self.attachAsset('pixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 0.6,
tint: 0x3a3a3a
});
self.floatSpeed = 0.3;
self.alpha = 0.4;
} else if (type === 'star') {
// Create sparkling star
self.elementGraphics = self.attachAsset('tinyPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
tint: 0xFFD700
});
self.floatSpeed = 0.1;
self.bobAmount = 1;
// Add twinkle animation
tween(self.elementGraphics, {
alpha: 0.3,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 1000 + Math.random() * 2000,
easing: tween.easeInOut,
loop: true,
yoyo: true
});
}
// Fade in animation
self.alpha = 0;
tween(self, {
alpha: self.alpha || 0.6
}, {
duration: 2000,
easing: tween.easeOut
});
};
self.update = function () {
self.x -= self.floatSpeed;
self.time += self.bobSpeed;
self.y = self.initialY + Math.sin(self.time) * self.bobAmount;
// Reset position when off screen
if (self.x < -100) {
self.x = 2148;
self.y = Math.random() * 1500 + 100;
self.initialY = self.y;
}
};
return self;
});
var InteractiveObject = Container.expand(function () {
var self = Container.call(this);
var objectGraphics = self.attachAsset('pixel', {
anchorX: 0.5,
anchorY: 0.5
});
self.init = function (x, y) {
self.x = x;
self.y = y;
self.visible = true;
};
self.down = function () {
self.visible = false;
};
return self;
});
var OrbitingBall = Container.expand(function () {
var self = Container.call(this);
self.ballGraphics = null;
self.points = 12;
self.orbitRadius = 200;
self.orbitSpeed = 0.02;
self.orbitAngle = 0;
self.centerX = 1024;
self.centerY = 1366;
self.collected = false;
self.init = function () {
// Create ball with orbital effect
self.ballGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.3,
scaleY: 1.3,
tint: 0x00FFFF
});
// Add orbital trail
var trail = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.8,
scaleY: 1.8,
tint: 0x00FFFF
});
trail.alpha = 0.2;
// Set random starting angle
self.orbitAngle = Math.random() * Math.PI * 2;
self.orbitRadius = 150 + Math.random() * 200;
self.orbitSpeed = 0.01 + Math.random() * 0.02;
// Spawn animation
self.scaleX = 0;
self.scaleY = 0;
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeOut
});
};
self.update = function () {
if (self.collected) {
return;
}
// Orbital movement
self.orbitAngle += self.orbitSpeed;
self.x = self.centerX + Math.cos(self.orbitAngle) * self.orbitRadius;
self.y = self.centerY + Math.sin(self.orbitAngle) * self.orbitRadius;
self.rotation = self.orbitAngle + Math.PI / 2;
};
self.down = Ball.prototype.down;
return self;
});
var Particle = Container.expand(function () {
var self = Container.call(this);
self.particleGraphics = null;
self.vx = 0;
self.vy = 0;
self.gravity = 0.2;
self.friction = 0.98;
self.lifespan = 60;
self.maxLife = 60;
self.init = function (x, y, color, size) {
self.x = x;
self.y = y;
// Choose pixel size based on size parameter for dust effect
var pixelType = 'pixel';
var baseScale = 1;
if (size < 0.3) {
pixelType = 'tinyPixel';
baseScale = 0.5 + Math.random() * 0.3; // More size variation for tiny particles
} else if (size < 0.6) {
pixelType = 'smallPixel';
baseScale = 0.7 + Math.random() * 0.4;
}
self.particleGraphics = self.attachAsset(pixelType, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: baseScale,
scaleY: baseScale,
tint: color || 0xFFFFFF
});
// Dust-like velocity patterns
var angle = Math.random() * Math.PI * 2;
var speed;
if (size < 0.3) {
// Tiny particles: slower, more floating movement
speed = 0.5 + Math.random() * 2;
self.gravity = 0.05 + Math.random() * 0.1;
self.friction = 0.995;
} else if (size < 0.6) {
// Medium particles: moderate speed
speed = 1.5 + Math.random() * 3;
self.gravity = 0.15 + Math.random() * 0.1;
self.friction = 0.98;
} else {
// Large particles: faster, more dramatic
speed = 3 + Math.random() * 5;
self.gravity = 0.2 + Math.random() * 0.15;
self.friction = 0.97;
}
self.vx = Math.cos(angle) * speed;
self.vy = Math.sin(angle) * speed - (1 + Math.random() * 2);
// Varied lifespans for dust-like effect
if (size < 0.3) {
self.lifespan = 60 + Math.random() * 40; // Tiny particles last longer
} else {
self.lifespan = 30 + Math.random() * 30; // Larger particles fade faster
}
self.maxLife = self.lifespan;
};
self.update = function () {
self.x += self.vx;
self.y += self.vy;
self.vy += self.gravity;
self.vx *= self.friction;
self.lifespan--;
self.alpha = self.lifespan / self.maxLife;
if (self.lifespan <= 0) {
self.destroy();
for (var i = 0; i < particles.length; i++) {
if (particles[i] === self) {
particles.splice(i, 1);
break;
}
}
}
};
return self;
});
var Pixel = Container.expand(function () {
var self = Container.call(this);
self.pixelType = 'trunk';
self.pixelGraphics = null;
self.init = function (type, color, size) {
self.pixelType = type;
if (self.pixelGraphics) {
self.pixelGraphics.destroy();
}
// Choose appropriate pixel asset based on size
var pixelAsset = 'pixel';
var baseScale = size || 1;
if (size && size < 0.5) {
pixelAsset = 'tinyPixel';
baseScale = 1;
} else if (size && size < 0.8) {
pixelAsset = 'smallPixel';
baseScale = 1;
}
var assetConfig = {
anchorX: 0.5,
anchorY: 0.5,
scaleX: baseScale,
scaleY: baseScale
};
if (color) {
assetConfig.tint = color;
}
if (type === 'seed') {
self.pixelGraphics = self.attachAsset('seedPixel', {});
} else if (type === 'leaf') {
self.pixelGraphics = self.attachAsset('leafPixel', {});
} else if (type === 'flower') {
self.pixelGraphics = self.attachAsset('flowerPixel', {});
} else if (type === 'bird') {
self.pixelGraphics = self.attachAsset('birdPixel', {});
} else if (type === 'root' || type === 'trunk' || type === 'branch') {
self.pixelGraphics = self.attachAsset(pixelAsset, {});
} else {
self.pixelGraphics = self.attachAsset(pixelAsset, {});
}
self.alpha = 0;
};
self.fadeIn = function (duration) {
tween(self, {
alpha: 1
}, {
duration: duration || 500,
easing: tween.easeOut
});
};
self.grow = function (targetScale, duration) {
if (self.pixelGraphics) {
tween(self.pixelGraphics, {
scaleX: targetScale,
scaleY: targetScale
}, {
duration: duration || 1000,
easing: tween.easeInOut
});
}
};
return self;
});
var ShepherdBall = Container.expand(function () {
var self = Container.call(this);
self.collected = false;
self.lifespan = 300; // 5 seconds
self.catchRadius = 300;
self.init = function () {
// Create shepherd ball with special appearance
var outerGlow = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 3,
tint: 0x00FFFF
});
outerGlow.alpha = 0.2;
var midGlow = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
tint: 0x00FFFF
});
midGlow.alpha = 0.4;
self.ballGraphics = self.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0x00FFFF
});
// Position randomly
self.x = 200 + Math.random() * 1648;
self.y = 300 + Math.random() * 2132;
// Spawn animation
self.scaleX = 0;
self.scaleY = 0;
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
// Pulsing effect
tween(outerGlow, {
scaleX: 3.5,
scaleY: 3.5,
alpha: 0.1
}, {
duration: 1000,
easing: tween.easeInOut,
loop: true,
yoyo: true
});
};
self.update = function () {
if (self.collected) {
return;
}
self.lifespan--;
// Start fading when about to disappear
if (self.lifespan < 60) {
self.alpha = self.lifespan / 60;
}
// Remove when lifespan ends
if (self.lifespan <= 0) {
self.collected = true;
self.destroy();
}
};
self.down = function () {
if (self.collected) {
return;
}
self.collected = true;
// Collect all fleeing balls in radius
var collectedCount = 0;
for (var i = balls.length - 1; i >= 0; i--) {
var ball = balls[i];
if (ball.behavior === 'fleeing' && !ball.collected) {
var dx = ball.x - self.x;
var dy = ball.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < self.catchRadius) {
ball.collected = true;
collectedCount++;
// Award points
LK.setScore(LK.getScore() + ball.points);
// Create collection effect
createExplosion(ball.x, ball.y, 0x00FFFF);
// Animate ball collection
tween(ball, {
x: self.x,
y: self.y,
scaleX: 0,
scaleY: 0,
rotation: Math.PI * 2
}, {
duration: 300,
easing: tween.easeIn,
onFinish: function onFinish() {
ball.destroy();
}
});
}
}
}
// Bonus points for multiple catches
if (collectedCount > 0) {
var bonusPoints = collectedCount * 10;
LK.setScore(LK.getScore() + bonusPoints);
// Show bonus text
var bonusText = game.addChild(new Container());
bonusText.x = self.x;
bonusText.y = self.y;
var text = new Text2('LASSO! +' + (collectedCount * 15 + bonusPoints), {
size: 80,
fill: 0x00FFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
text.anchor.set(0.5, 0.5);
bonusText.addChild(text);
tween(bonusText, {
y: self.y - 150,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
bonusText.destroy();
}
});
LK.getSound('lasso').play();
}
// Play sound
LK.getSound('hit').play();
// Remove shepherd ball with effect
tween(self, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Level-based ball collection game
game.setBackgroundColor(0x0a0a0a); // Deep black background for dramatic contrast
// GLAUD Logo Container
var glaudContainer = game.addChild(new Container());
glaudContainer.visible = false;
// Game variables
var balls = [];
var particles = [];
var floatingElements = [];
var currentLevel = 1;
var levelScore = 0;
var levelTimeLimit = 30; // Level 1 starts with 30 seconds
var levelTimer = 0;
var levelStartTime = 0;
var gameTime = 0; // Add gameTime variable
var isTransitioning = false;
var screenShakeX = 0;
var screenShakeY = 0;
var shakeIntensity = 0;
var shakeDuration = 0;
var mouseX = null;
var mouseY = null;
var ballSpawnTimer = 0;
var levelRequirements = [100, 200, 300, 400, 500, 600, 700, 800, 900]; // Score requirements per level
var highestLevel = storage.highestLevel || 1; // Load saved highest level
// Function to get level requirement for any level
function getLevelRequirement(level) {
var baseLevel = (level - 1) % 9 + 1;
var difficultyTier = Math.floor((level - 1) / 9);
var baseRequirement = levelRequirements[baseLevel - 1];
// Increase requirements by 50% for each difficulty tier
return Math.floor(baseRequirement * Math.pow(1.5, difficultyTier));
}
var targetColor = 0; // For level 9 color targeting
var targetColorIndex = 0;
var colorTargetTimer = 0;
var shepherdBalls = []; // For level 7 shepherd balls
// Score display with shadow effect
var scoreTextShadow = new Text2('Level 1 | Score: 0 | Time: 30', {
size: 62,
fill: 0x000000
});
scoreTextShadow.anchor.set(0, 0);
scoreTextShadow.x = 182;
scoreTextShadow.y = 12;
scoreTextShadow.alpha = 0.5;
LK.gui.topLeft.addChild(scoreTextShadow);
var scoreText = new Text2('Level 1 | Score: 0 | Time: 30', {
size: 60,
fill: 0xFFFFFF
});
scoreText.anchor.set(0, 0);
scoreText.x = 180;
scoreText.y = 10;
LK.gui.topLeft.addChild(scoreText);
// Highest level display
var highestLevelText = new Text2('Best: Level ' + highestLevel, {
size: 40,
fill: 0xFFA500
});
highestLevelText.anchor.set(1, 0);
highestLevelText.x = -20;
highestLevelText.y = 10;
LK.gui.topRight.addChild(highestLevelText);
highestLevelText.visible = false;
// Initialize progress bar animation variables
var lastProgressValue = 0;
var progressPulseActive = false;
// Level transition container
var transitionContainer = game.addChild(new Container());
transitionContainer.x = 1024;
transitionContainer.y = 1366;
// Level transition text with outline - modern style
var levelTransitionOutline = new Text2('', {
size: 124,
fill: 0x000000,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
levelTransitionOutline.anchor.set(0.5, 0.5);
levelTransitionOutline.x = 4;
levelTransitionOutline.y = 4;
levelTransitionOutline.alpha = 0.5;
transitionContainer.addChild(levelTransitionOutline);
var levelTransitionText = new Text2('', {
size: 120,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
levelTransitionText.anchor.set(0.5, 0.5);
transitionContainer.addChild(levelTransitionText);
// Add glow effect container
var glowContainer = new Container();
glowContainer.x = 0;
glowContainer.y = 0;
transitionContainer.addChildAt(glowContainer, 0);
// Create glow layers
for (var i = 0; i < 3; i++) {
var glowText = new Text2('', {
size: 120 + i * 8,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glowText.anchor.set(0.5, 0.5);
glowText.alpha = 0.15 - i * 0.05;
glowContainer.addChild(glowText);
}
transitionContainer.visible = false;
// Create background gradient
var bgGradient = new BackgroundGradient();
bgGradient.init();
game.addChild(bgGradient);
// Start background music
LK.playMusic('gameMusic', {
loop: true
});
// GLAUD intro function
function showGLAUDIntro() {
isTransitioning = true;
// Create intro container
var introContainer = game.addChild(new Container());
introContainer.x = 1024;
introContainer.y = 1366;
introContainer.alpha = 0;
// Create game ball shower effect
var ballShower = [];
for (var i = 0; i < 15; i++) {
var ballContainer = new Container();
var ball = ballContainer.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.5 + Math.random() * 0.5,
scaleY: 0.5 + Math.random() * 0.5,
tint: i < 5 ? 0xFFD700 : i < 10 ? 0xFF4444 : 0x44FF44
});
ballContainer.x = -800 + Math.random() * 1600;
ballContainer.y = -800 - Math.random() * 400;
ballContainer.vx = (Math.random() - 0.5) * 2;
ballContainer.vy = 5 + Math.random() * 5;
ballContainer.rotation = Math.random() * Math.PI * 2;
introContainer.addChild(ballContainer);
ballShower.push(ballContainer);
}
// Create GLAUD text with multiple layers for effect
var glaudOutline = new Text2('GLAUD', {
size: 240,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glaudOutline.anchor.set(0.5, 0.5);
glaudOutline.alpha = 0.2;
introContainer.addChild(glaudOutline);
var glaudShadow = new Text2('GLAUD', {
size: 200,
fill: 0x000000,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glaudShadow.anchor.set(0.5, 0.5);
glaudShadow.x = 8;
glaudShadow.y = 8;
glaudShadow.alpha = 0.5;
introContainer.addChild(glaudShadow);
var glaudGlow = new Text2('GLAUD', {
size: 210,
fill: 0xFF6600,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glaudGlow.anchor.set(0.5, 0.5);
glaudGlow.alpha = 0.3;
introContainer.addChild(glaudGlow);
var glaudText = new Text2('GLAUD', {
size: 180,
fill: 0xFFA500,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glaudText.anchor.set(0.5, 0.5);
introContainer.addChild(glaudText);
// Add dynamic subtitle
var subtitle = new Text2('BALL COLLECTOR', {
size: 60,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = 100;
subtitle.alpha = 0;
introContainer.addChild(subtitle);
// Create energy ring
var energyRing = introContainer.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
tint: 0xFFA500
});
energyRing.alpha = 0.8;
// Start with explosion effect
introContainer.scaleX = 0.1;
introContainer.scaleY = 0.1;
introContainer.alpha = 1;
// Explosive entrance
tween(introContainer, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(introContainer, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
// Animate energy ring
tween(energyRing, {
scaleX: 8,
scaleY: 8,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut
});
// Animate balls falling
var ballTimer = LK.setInterval(function () {
for (var i = 0; i < ballShower.length; i++) {
var ballContainer = ballShower[i];
ballContainer.x += ballContainer.vx;
ballContainer.y += ballContainer.vy;
ballContainer.rotation += 0.1;
ballContainer.vy += 0.3;
if (ballContainer.y > 800) {
ballContainer.y = -800 - Math.random() * 400;
ballContainer.x = -800 + Math.random() * 1600;
ballContainer.vy = 5 + Math.random() * 5;
}
}
}, 16);
// Quick glow pulse
tween(glaudGlow, {
scaleX: 1.15,
scaleY: 1.15,
alpha: 0.6
}, {
duration: 400,
easing: tween.easeInOut,
yoyo: true,
repeat: 1
});
// Show subtitle
LK.setTimeout(function () {
tween(subtitle, {
alpha: 1,
y: 120
}, {
duration: 300,
easing: tween.easeOut
});
}, 200);
// Create collecting effect
LK.setTimeout(function () {
// All balls converge to center
for (var i = 0; i < ballShower.length; i++) {
(function (ballContainer, index) {
tween(ballContainer, {
x: 0,
y: 0,
scaleX: 0,
scaleY: 0,
rotation: Math.PI * 4
}, {
duration: 400,
delay: index * 20,
easing: tween.easeIn
});
})(ballShower[i], i);
}
// Flash effect when balls are collected
LK.setTimeout(function () {
var flash = introContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 20,
scaleY: 20,
tint: 0xFFD700
});
flash.alpha = 0.8;
tween(flash, {
alpha: 0
}, {
duration: 300,
easing: tween.easeOut
});
// Score burst effect
var scoreText = new Text2('+1000', {
size: 100,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
scoreText.anchor.set(0.5, 0.5);
scoreText.y = -50;
scoreText.alpha = 0;
introContainer.addChild(scoreText);
tween(scoreText, {
y: -150,
alpha: 1
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(scoreText, {
alpha: 0
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}, 300);
}, 800);
// Quick transition to game
LK.setTimeout(function () {
LK.clearInterval(ballTimer);
// Create permanent GLAUD logo in top right
glaudContainer.x = 1900;
glaudContainer.y = 80;
var glaudLogo = new Text2('GLAUD', {
size: 60,
fill: 0xFFA500,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
glaudLogo.anchor.set(1, 0);
glaudContainer.addChild(glaudLogo);
// Quick fade out with rotation
tween(introContainer, {
alpha: 0,
scaleX: 0.5,
scaleY: 0.5,
rotation: 0.2
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
introContainer.destroy();
// Show GLAUD logo and highest level
glaudContainer.alpha = 0;
glaudContainer.visible = true;
tween(glaudContainer, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut
});
highestLevelText.visible = true;
isTransitioning = false;
// Start first level
startLevel(1);
}
});
}, 1500);
}
// Create GLAUD intro
showGLAUDIntro();
// Particle and effect functions
function createExplosion(x, y, color) {
// Create multi-layered explosion effect
for (var i = 0; i < 30; i++) {
var particle = new Particle();
// Mix of particle sizes for depth
var sizeVariation = 0.1 + Math.random() * 0.5;
// Vary colors for richness
var particleColor = color;
if (Math.random() < 0.3) {
particleColor = 0xFFFFFF; // White sparkles
} else if (Math.random() < 0.5) {
particleColor = 0xFFD700; // Gold accents
}
particle.init(x, y, particleColor, sizeVariation);
particles.push(particle);
game.addChild(particle);
}
// Create ring effect
var ring = game.addChild(new Container());
ring.x = x;
ring.y = y;
var ringGraphic = ring.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
tint: color
});
ringGraphic.alpha = 0.8;
tween(ringGraphic, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
ring.destroy();
}
});
}
function createTrailParticle(x, y, color) {
var particle = new Particle();
particle.init(x, y, color, 0.2);
particle.lifespan = 20;
particle.maxLife = 20;
particles.push(particle);
game.addChild(particle);
}
function screenShake(intensity, duration) {
shakeIntensity = intensity;
shakeDuration = duration;
}
function updateScreenShake() {
if (shakeDuration > 0) {
screenShakeX = (Math.random() - 0.5) * shakeIntensity;
screenShakeY = (Math.random() - 0.5) * shakeIntensity;
game.x = screenShakeX;
game.y = screenShakeY;
shakeDuration -= 16;
} else {
game.x = 0;
game.y = 0;
}
}
// Function to spawn balls based on level
function spawnBall() {
if (isTransitioning) {
return;
}
var ball = new Ball();
ball.init(currentLevel);
balls.push(ball);
game.addChild(ball);
LK.getSound('spawn').play();
}
// Function to start a new level
function startLevel(level) {
currentLevel = level;
levelScore = 0;
levelStartTime = gameTime;
// Save highest level reached
if (level > highestLevel) {
highestLevel = level;
storage.highestLevel = highestLevel;
highestLevelText.setText('Best: Level ' + highestLevel);
}
// Calculate base level and difficulty tier
var baseLevel = (level - 1) % 9 + 1;
var difficultyTier = Math.floor((level - 1) / 9);
// Set time limit for level with difficulty adjustments
if (baseLevel === 1) {
levelTimeLimit = Math.max(20, 30 - difficultyTier * 5);
} else if (baseLevel <= 5) {
levelTimeLimit = Math.max(30, 30 + (baseLevel - 1) * 20 - difficultyTier * 10);
} else {
// Harder time limits for levels 6-9
levelTimeLimit = Math.max(60, 120 + (baseLevel - 6) * 10 - difficultyTier * 15);
}
// Clear existing balls
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].destroy();
}
balls = [];
lastProgressValue = 0;
progressPulseActive = false;
// Reset score to 0 for this level
LK.setScore(0);
levelScore = 0;
// Show intro for level 1
if (level === 1 && gameTime === 0) {
isTransitioning = true;
transitionContainer.visible = true;
transitionContainer.alpha = 1;
// Clear any existing children except the main text elements
for (var i = transitionContainer.children.length - 1; i >= 0; i--) {
var child = transitionContainer.children[i];
if (child !== levelTransitionText && child !== levelTransitionOutline && child !== glowContainer) {
child.destroy();
}
}
levelTransitionText.setText('LEVEL 1');
levelTransitionOutline.setText('LEVEL 1');
levelTransitionText.size = 140;
levelTransitionOutline.size = 144;
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 0;
transitionContainer.scaleY = 0;
// Intro animation
tween(transitionContainer, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(transitionContainer, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Add subtitle
var subtitle = new Text2('Collect the Balls!', {
size: 60,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = 80;
subtitle.alpha = 0;
transitionContainer.addChild(subtitle);
tween(subtitle, {
alpha: 1,
y: 60
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
LK.setTimeout(function () {
tween(transitionContainer, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChild(subtitle);
subtitle.destroy();
isTransitioning = false;
// Spawn initial balls
var initialBalls = 5 + baseLevel * 2 + difficultyTier * 3;
for (var i = 0; i < initialBalls; i++) {
spawnBall();
}
}
});
}, 1500);
}
});
}
});
}
});
} else {
isTransitioning = false;
// Spawn initial balls based on level
var initialBalls = 5 + baseLevel * 2 + difficultyTier * 3;
for (var i = 0; i < initialBalls; i++) {
spawnBall();
}
}
}
// Function to show level transition
function showLevelTransition(nextLevel) {
isTransitioning = true;
// Clear balls
for (var i = balls.length - 1; i >= 0; i--) {
balls[i].destroy();
}
balls = [];
// Calculate base level and difficulty tier
var baseLevel = (nextLevel - 1) % 9 + 1;
var difficultyTier = Math.floor((nextLevel - 1) / 9);
// Create modern transition sequence
transitionContainer.visible = true;
transitionContainer.alpha = 1;
// First show completion message
levelTransitionText.setText('LEVEL ' + (nextLevel - 1) + ' COMPLETE');
levelTransitionOutline.setText('LEVEL ' + (nextLevel - 1) + ' COMPLETE');
levelTransitionText.size = 100;
levelTransitionOutline.size = 104;
// Clear any existing children except the main text elements
for (var i = transitionContainer.children.length - 1; i >= 0; i--) {
var child = transitionContainer.children[i];
if (child !== levelTransitionText && child !== levelTransitionOutline && child !== glowContainer) {
child.destroy();
}
}
// Start with slide in from left
transitionContainer.x = -500;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.rotation = 0;
// Slide in animation
tween(transitionContainer, {
x: 1024
}, {
duration: 600,
easing: tween.easeOut,
onFinish: function onFinish() {
// Pulse effect
tween(transitionContainer, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeInOut,
yoyo: true,
onFinish: function onFinish() {
// Wait then show next level intro
LK.setTimeout(function () {
// Show cinematic intro based on base level
if (nextLevel <= 9) {
// Original intros for levels 1-9
if (nextLevel === 2) {
showLevel2Intro(nextLevel);
} else if (nextLevel === 3) {
showLevel3Intro(nextLevel);
} else if (nextLevel === 4) {
showLevel4Intro(nextLevel);
} else if (nextLevel === 5) {
showLevel5Intro(nextLevel);
} else if (nextLevel === 6) {
showLevel6Intro(nextLevel);
} else if (nextLevel === 7) {
showLevel7Intro(nextLevel);
} else if (nextLevel === 8) {
showLevel8Intro(nextLevel);
} else if (nextLevel === 9) {
showLevel9Intro(nextLevel);
}
} else {
// For levels 10+, show level with difficulty tier
levelTransitionText.setText('LEVEL ' + nextLevel);
levelTransitionOutline.setText('LEVEL ' + nextLevel);
levelTransitionText.size = 140;
levelTransitionOutline.size = 144;
// Reset position for intro animation
transitionContainer.x = 1024;
transitionContainer.scaleX = 0;
transitionContainer.scaleY = 0;
transitionContainer.alpha = 0;
// Intro animation - expand from center
tween(transitionContainer, {
scaleX: 1.2,
scaleY: 1.2,
alpha: 1
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
// Shrink to normal size
tween(transitionContainer, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut,
onFinish: function onFinish() {
// Add subtitle showing difficulty tier
var subtitleText = 'Difficulty Tier ' + (difficultyTier + 1);
if (baseLevel === 1) {
subtitleText += ' - Static Balls';
} else if (baseLevel === 2) {
subtitleText += ' - Random Movement';
} else if (baseLevel === 3) {
subtitleText += ' - Falling Balls';
} else if (baseLevel === 4) {
subtitleText += ' - Fleeing Balls';
} else if (baseLevel === 5) {
subtitleText += ' - Roaming Chaos';
} else if (baseLevel === 6) {
subtitleText += ' - Orbital Mastery';
} else if (baseLevel === 7) {
subtitleText += ' - Fugitives & Lasso';
} else if (baseLevel === 8) {
subtitleText += ' - Phantom Echoes';
} else if (baseLevel === 9) {
subtitleText += ' - Chromatic Chaos';
}
var subtitle = new Text2(subtitleText, {
size: 60,
fill: difficultyTier >= 2 ? 0xFF4444 : 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = 80;
subtitle.alpha = 0;
transitionContainer.addChild(subtitle);
// Add difficulty warning for high tiers
if (difficultyTier >= 2) {
var warning = new Text2('EXTREME DIFFICULTY!', {
size: 50,
fill: 0xFF0000
});
warning.anchor.set(0.5, 0.5);
warning.y = 140;
warning.alpha = 0;
transitionContainer.addChild(warning);
tween(warning, {
alpha: 1,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 400,
delay: 600,
easing: tween.easeOut,
yoyo: true,
repeat: 2
});
}
// Fade in subtitle
tween(subtitle, {
alpha: 1,
y: 60
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
// Wait then fade everything out
LK.setTimeout(function () {
tween(transitionContainer, {
alpha: 0,
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 1500);
}
});
}
});
}
});
}
}, 800);
}
});
}
});
// Create celebration effects
for (var i = 0; i < 30; i++) {
LK.setTimeout(function () {
var angle = Math.random() * Math.PI * 2;
var distance = 200 + Math.random() * 300;
var x = 1024 + Math.cos(angle) * distance;
var y = 1366 + Math.sin(angle) * distance;
createExplosion(x, y, 0xFFD700);
}, i * 30);
}
// Screen shake for impact
screenShake(10, 300);
}
// Function to spawn floating background elements
function spawnFloatingElement() {
if (floatingElements.length < 8) {
var element = new FloatingElement();
var type = Math.random() < 0.7 ? 'cloud' : 'star';
element.init(type, 2148, Math.random() * 1500 + 100);
floatingElements.push(element);
game.addChild(element);
}
}
// Track mouse position
game.move = function (x, y, obj) {
mouseX = x;
mouseY = y;
};
// Enhanced update function with dynamic effects
game.update = function () {
// Update game time
gameTime++;
if (!isTransitioning) {
// Calculate remaining time
var elapsedTime = Math.floor((gameTime - levelStartTime) / 60);
var remainingTime = Math.max(0, levelTimeLimit - elapsedTime);
// Update screen shake
updateScreenShake();
// Spawn balls periodically based on level
ballSpawnTimer++;
var baseLevel = (currentLevel - 1) % 9 + 1;
var difficultyTier = Math.floor((currentLevel - 1) / 9);
var spawnRate = Math.max(20, 120 - baseLevel * 15 - difficultyTier * 10);
var maxBalls = 15 + baseLevel * 3 + difficultyTier * 5;
if (ballSpawnTimer >= spawnRate && balls.length < maxBalls) {
spawnBall();
ballSpawnTimer = 0;
}
// Spawn floating elements periodically
if (gameTime % 300 === 0) {
spawnFloatingElement();
}
// Update score display with time warning
var currentRequirement = getLevelRequirement(currentLevel);
var displayText = 'Level ' + currentLevel + ' | Score: ' + LK.getScore() + '/' + currentRequirement + ' | Time: ' + remainingTime;
scoreText.setText(displayText);
scoreTextShadow.setText(displayText);
// Time warning effect
if (remainingTime <= 10 && remainingTime > 0) {
scoreText.tint = 0xFF4444;
scoreTextShadow.tint = 0x660000;
// Pulse effect
if (gameTime % 30 === 0) {
tween(scoreText, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 300,
easing: tween.easeOut,
yoyo: true
});
}
} else {
scoreText.tint = 0xFFFFFF;
scoreTextShadow.tint = 0x000000;
}
// Update progress tracking
var progress = LK.getScore() / levelRequirements[currentLevel - 1];
lastProgressValue = progress;
// Level 7: Spawn shepherd balls occasionally
if (currentLevel === 7 && gameTime % 300 === 0) {
var shepherd = new ShepherdBall();
shepherd.init();
shepherdBalls.push(shepherd);
game.addChild(shepherd);
}
// Level 9: Update color target
if (currentLevel === 9) {
colorTargetTimer++;
if (colorTargetTimer >= 600) {
// Change target every 10 seconds
colorTargetTimer = 0;
targetColorIndex = (targetColorIndex + 1) % 3;
var colors = [0xFFD700, 0xFF4444, 0x44FF44];
targetColor = colors[targetColorIndex];
// Update UI to show current target color
scoreText.tint = targetColor;
}
}
// Update shepherd balls
for (var i = shepherdBalls.length - 1; i >= 0; i--) {
var shepherd = shepherdBalls[i];
if (shepherd.collected || shepherd.lifespan <= 0) {
shepherdBalls.splice(i, 1);
}
}
// Check level completion
if (LK.getScore() >= getLevelRequirement(currentLevel)) {
showLevelTransition(currentLevel + 1);
}
// Check time limit
if (remainingTime <= 0) {
LK.showGameOver();
}
}
};
// Cinematic intro for Level 2 - Random Moving Balls
function showLevel2Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create cinematic frame
var frameContainer = new Container();
frameContainer.scaleX = 0;
frameContainer.scaleY = 0;
transitionContainer.addChild(frameContainer);
// Create outer frame border
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 12,
scaleY: 8,
tint: 0xFFD700
});
outerFrame.alpha = 0.3;
// Create inner frame
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 11,
scaleY: 7,
tint: 0x000000
});
innerFrame.alpha = 0.9;
// Create demo container
var demoContainer = new Container();
demoContainer.y = 0;
frameContainer.addChild(demoContainer);
// Title
var title = new Text2('LEVEL 2', {
size: 180,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('Balls Move Randomly!', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -200;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create demo area background
var demoArea = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 9,
scaleY: 4,
tint: 0x1a1a1a
});
demoArea.y = 150;
demoArea.alpha = 0.5;
// Create demo balls
var demoBalls = [];
for (var i = 0; i < 4; i++) {
var ball = new Container();
// Add glow effect
var glow = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFFD700
});
glow.alpha = 0.3;
var ballGfx = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700
});
ball.x = -300 + i * 200;
ball.y = 150;
ball.vx = (Math.random() - 0.5) * 6;
ball.vy = (Math.random() - 0.5) * 6;
ball.scaleX = 0;
ball.scaleY = 0;
demoBalls.push(ball);
demoContainer.addChild(ball);
}
// Animate frame entrance
tween(frameContainer, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 600,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(frameContainer, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut
});
}
});
// Animate intro
tween(title, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(subtitle, {
alpha: 1,
y: -200
}, {
duration: 400,
easing: tween.easeOut
});
// Animate demo balls
for (var i = 0; i < demoBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
}, delay);
})(demoBalls[i], i * 100);
}
// Animate ball movement
var moveTimer = LK.setInterval(function () {
for (var i = 0; i < demoBalls.length; i++) {
var ball = demoBalls[i];
ball.x += ball.vx;
ball.y += ball.vy;
// Bounce off walls
if (ball.x < -400 || ball.x > 400) {
ball.vx = -ball.vx;
}
if (ball.y < 0 || ball.y > 300) {
ball.vy = -ball.vy;
}
}
}, 16);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(moveTimer);
tween(frameContainer, {
alpha: 0,
scaleX: 0.5,
scaleY: 0.5,
rotation: 0.1
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 3500);
}
});
}
// Cinematic intro for Level 3 - Falling Balls
function showLevel3Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create cinematic frame with vertical emphasis
var frameContainer = new Container();
frameContainer.scaleX = 0;
frameContainer.scaleY = 0;
transitionContainer.addChild(frameContainer);
// Create outer frame border - taller for falling effect
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 12,
tint: 0x4444FF
});
outerFrame.alpha = 0.3;
// Create inner frame
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 9,
scaleY: 11,
tint: 0x000000
});
innerFrame.alpha = 0.9;
// Add decorative elements
for (var i = 0; i < 4; i++) {
var deco = frameContainer.attachAsset('smallPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
tint: 0xFFD700
});
deco.x = -400 + i * 267;
deco.y = -550;
deco.alpha = 0.6;
}
// Create demo container
var demoContainer = new Container();
demoContainer.y = 0;
frameContainer.addChild(demoContainer);
// Title
var title = new Text2('LEVEL 3', {
size: 180,
fill: 0x4444FF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -450;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('Balls Fall From Above!', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -350;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create falling area indicators
var leftLine = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 8,
tint: 0x4444FF
});
leftLine.x = -380;
leftLine.y = 0;
leftLine.alpha = 0.3;
var rightLine = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 8,
tint: 0x4444FF
});
rightLine.x = 380;
rightLine.y = 0;
rightLine.alpha = 0.3;
// Create falling demo balls
var fallingBalls = [];
// Animate frame entrance - drop from above
frameContainer.y = -800;
frameContainer.scaleX = 1;
frameContainer.scaleY = 1;
tween(frameContainer, {
y: 0
}, {
duration: 800,
easing: tween.bounceOut
});
// Animate intro
LK.setTimeout(function () {
tween(title, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(subtitle, {
alpha: 1,
y: -350
}, {
duration: 400,
easing: tween.easeOut
});
// Create falling balls animation
var ballSpawnTimer = LK.setInterval(function () {
var ball = new Container();
// Add trail effect
var trail = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 2,
tint: 0x4444FF
});
trail.alpha = 0.2;
var ballGfx = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700
});
ball.x = -350 + Math.random() * 700;
ball.y = -500;
ball.rotation = Math.random() * Math.PI * 2;
ball.scaleX = 0.5 + Math.random() * 0.5;
ball.scaleY = ball.scaleX;
fallingBalls.push(ball);
demoContainer.addChild(ball);
// Falling animation with acceleration
tween(ball, {
y: 500,
rotation: ball.rotation + Math.PI * 4,
scaleX: ball.scaleX * 1.5,
scaleY: ball.scaleY * 1.5
}, {
duration: 2000,
easing: tween.easeIn,
onFinish: function onFinish() {
// Create splash effect
var splash = demoContainer.addChild(new Container());
splash.x = ball.x;
splash.y = 480;
var splashGfx = splash.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
tint: 0xFFD700
});
tween(splashGfx, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
splash.destroy();
}
});
ball.destroy();
}
});
}, 200);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(ballSpawnTimer);
tween(frameContainer, {
alpha: 0,
y: 800
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 3500);
}
});
}, 800);
}
// Cinematic intro for Level 4 - Fleeing Balls
function showLevel4Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create cinematic frame with action-movie style
var frameContainer = new Container();
frameContainer.alpha = 0;
transitionContainer.addChild(frameContainer);
// Create dynamic frame border
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: 0xFF4444
});
outerFrame.alpha = 0.4;
// Create inner frame with gradient effect
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 13,
scaleY: 9,
tint: 0x000000
});
innerFrame.alpha = 0.95;
// Add action lines
for (var i = 0; i < 6; i++) {
var line = frameContainer.attachAsset('bigPixel', {
anchorX: 0,
anchorY: 0.5,
scaleX: 8,
scaleY: 0.05,
tint: 0xFF4444
});
line.x = -650;
line.y = -400 + i * 160;
line.alpha = 0.2;
line.rotation = -0.1 + Math.random() * 0.2;
}
// Create demo container
var demoContainer = new Container();
demoContainer.y = 0;
frameContainer.addChild(demoContainer);
// Title with dramatic effect
var titleGlow = new Text2('LEVEL 4', {
size: 200,
fill: 0xFF4444,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
titleGlow.anchor.set(0.5, 0.5);
titleGlow.y = -400;
titleGlow.alpha = 0.3;
demoContainer.addChild(titleGlow);
var title = new Text2('LEVEL 4', {
size: 180,
fill: 0xFFFFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -400;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('Balls Run Away!', {
size: 80,
fill: 0xFFD700
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -280;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create demo arena
var arena = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 5,
tint: 0x1a1a1a
});
arena.y = 150;
arena.alpha = 0.3;
// Create fleeing demo with multiple balls
var fleeingBalls = [];
for (var i = 0; i < 3; i++) {
var fleeingBall = new Container();
// Add fear effect
var fearAura = fleeingBall.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFF4444
});
fearAura.alpha = 0.3;
var ballGfx = fleeingBall.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700
});
fleeingBall.x = -200 + i * 200;
fleeingBall.y = 150;
fleeingBall.scaleX = 0;
fleeingBall.scaleY = 0;
fleeingBalls.push(fleeingBall);
demoContainer.addChild(fleeingBall);
}
// Create cursor with predator effect
var cursor = new Container();
var cursorAura = cursor.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
tint: 0xFF0000
});
cursorAura.alpha = 0.2;
var cursorGfx = cursor.attachAsset('smallTarget', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFFFFF
});
cursor.x = -400;
cursor.y = 150;
cursor.alpha = 0;
cursor.scaleX = 1.5;
cursor.scaleY = 1.5;
demoContainer.addChild(cursor);
// Animate frame entrance with flash
tween(frameContainer, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut
});
// Screen flash effect
var flash = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 11,
tint: 0xFFFFFF
});
flash.alpha = 0.8;
tween(flash, {
alpha: 0
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
flash.destroy();
}
});
// Animate intro
tween(title, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(subtitle, {
alpha: 1,
y: -280
}, {
duration: 400,
easing: tween.easeOut
});
// Show balls with stagger
for (var i = 0; i < fleeingBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}, delay);
})(fleeingBalls[i], i * 150);
}
// Show cursor
LK.setTimeout(function () {
tween(cursor, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
// Animate chase sequence
tween(cursor, {
x: 0,
y: 150
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
// All balls flee in different directions
for (var i = 0; i < fleeingBalls.length; i++) {
(function (ball, index) {
var angle = index / fleeingBalls.length * Math.PI * 2;
var fleeX = Math.cos(angle) * 300;
var fleeY = 150 + Math.sin(angle) * 200;
tween(ball, {
x: fleeX,
y: fleeY,
rotation: Math.random() * Math.PI
}, {
duration: 600,
easing: tween.easeOut
});
})(fleeingBalls[i], i);
}
// Cursor spins confused
tween(cursor, {
rotation: Math.PI * 2
}, {
duration: 800,
easing: tween.easeInOut
});
}
});
}
});
}, 600);
// Transition out
LK.setTimeout(function () {
tween(frameContainer, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 4000);
}
});
}
// Cinematic intro for Level 5 - Roaming Balls
function showLevel5Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create epic cinematic frame
var frameContainer = new Container();
frameContainer.rotation = 0;
transitionContainer.addChild(frameContainer);
// Create multi-layered frame for chaos effect
var chaosFrame1 = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 16,
scaleY: 12,
tint: 0xFF0000
});
chaosFrame1.alpha = 0.2;
var chaosFrame2 = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 15,
scaleY: 11,
tint: 0xFFD700
});
chaosFrame2.alpha = 0.2;
chaosFrame2.rotation = 0.05;
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: 0xFF00FF
});
outerFrame.alpha = 0.4;
// Create inner frame
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 13,
scaleY: 9,
tint: 0x000000
});
innerFrame.alpha = 0.95;
// Add chaos particles around frame
var chaosParticles = [];
for (var i = 0; i < 12; i++) {
var particle = frameContainer.attachAsset('smallPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
tint: Math.random() < 0.5 ? 0xFF0000 : 0xFFD700
});
var angle = i / 12 * Math.PI * 2;
particle.x = Math.cos(angle) * 600;
particle.y = Math.sin(angle) * 450;
particle.alpha = 0.6;
chaosParticles.push(particle);
}
// Create demo container
var demoContainer = new Container();
demoContainer.y = 0;
frameContainer.addChild(demoContainer);
// Epic title with multiple layers
var titleBg = new Text2('LEVEL 5', {
size: 220,
fill: 0x000000,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
titleBg.anchor.set(0.5, 0.5);
titleBg.y = -350;
titleBg.x = 5;
titleBg.alpha = 0.5;
demoContainer.addChild(titleBg);
var titleGlow = new Text2('LEVEL 5', {
size: 200,
fill: 0xFF00FF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
titleGlow.anchor.set(0.5, 0.5);
titleGlow.y = -350;
titleGlow.alpha = 0.4;
demoContainer.addChild(titleGlow);
var title = new Text2('LEVEL 5', {
size: 180,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle with warning style
var subtitle = new Text2('CHAOS MODE!', {
size: 100,
fill: 0xFF0000
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -230;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create chaos arena
var arenaGlow = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 11,
scaleY: 7,
tint: 0xFF00FF
});
arenaGlow.y = 100;
arenaGlow.alpha = 0.1;
var arena = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 10,
scaleY: 6,
tint: 0x0a0a0a
});
arena.y = 100;
arena.alpha = 0.8;
// Create roaming balls with different sizes and colors
var roamingBalls = [];
for (var i = 0; i < 8; i++) {
var ball = new Container();
// Random ball type
var ballColor = i < 3 ? 0xFFD700 : i < 6 ? 0xFF0000 : 0x00FF00;
var ballSize = 0.8 + Math.random() * 0.6;
// Add trail effect
var trail = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: ballSize * 1.5,
scaleY: ballSize * 1.5,
tint: ballColor
});
trail.alpha = 0.2;
var ballGfx = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: ballSize,
scaleY: ballSize,
tint: ballColor
});
ball.x = -400 + Math.random() * 800;
ball.y = -200 + Math.random() * 400;
ball.vx = (Math.random() - 0.5) * 12;
ball.vy = (Math.random() - 0.5) * 12;
ball.scaleX = 0;
ball.scaleY = 0;
roamingBalls.push(ball);
demoContainer.addChild(ball);
}
// Animate frame entrance with rotation
frameContainer.scaleX = 0.1;
frameContainer.scaleY = 0.1;
frameContainer.rotation = Math.PI * 2;
tween(frameContainer, {
scaleX: 1,
scaleY: 1,
rotation: 0
}, {
duration: 800,
easing: tween.easeOut
});
// Animate chaos particles
for (var i = 0; i < chaosParticles.length; i++) {
(function (particle, index) {
tween(particle, {
x: particle.x * 0.8,
y: particle.y * 0.8,
rotation: Math.PI * 4
}, {
duration: 2000 + index * 100,
easing: tween.linear,
loop: true
});
})(chaosParticles[i], i);
}
// Animate intro
LK.setTimeout(function () {
// Title shake effect
var shakeTimer = LK.setInterval(function () {
title.x = -5 + Math.random() * 10;
title.y = -350 + (-5 + Math.random() * 10);
titleGlow.x = title.x;
titleGlow.y = title.y;
}, 50);
tween(title, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
LK.clearInterval(shakeTimer);
title.x = 0;
title.y = -350;
titleGlow.x = 0;
titleGlow.y = -350;
tween(subtitle, {
alpha: 1,
y: -230
}, {
duration: 400,
easing: tween.easeOut
});
// Flash effect
var flash = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 20,
scaleY: 15,
tint: 0xFFFFFF
});
flash.alpha = 0.6;
tween(flash, {
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
flash.destroy();
}
});
// Spawn balls with explosion effect
for (var i = 0; i < roamingBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeIn
});
}
});
}, delay);
})(roamingBalls[i], i * 50);
}
// Animate chaotic movement
var chaosTimer = LK.setInterval(function () {
for (var i = 0; i < roamingBalls.length; i++) {
var ball = roamingBalls[i];
ball.x += ball.vx;
ball.y += ball.vy;
ball.rotation += 0.2;
// Bounce off walls with effects
if (Math.abs(ball.x) > 450) {
ball.vx = -ball.vx * 1.2;
// Create bounce effect
var bounce = demoContainer.addChild(new Container());
bounce.x = ball.x > 0 ? 450 : -450;
bounce.y = ball.y;
var bounceGfx = bounce.attachAsset('smallPixel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFFFFF
});
tween(bounceGfx, {
scaleX: 3,
scaleY: 3,
alpha: 0
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
bounce.destroy();
}
});
}
if (Math.abs(ball.y) > 250) {
ball.vy = -ball.vy * 1.2;
}
// Random direction changes
if (Math.random() < 0.08) {
ball.vx = (Math.random() - 0.5) * 15;
ball.vy = (Math.random() - 0.5) * 15;
}
}
}, 16);
// Add warning text with flashing
LK.setTimeout(function () {
var warning = new Text2('MAXIMUM DIFFICULTY!', {
size: 70,
fill: 0xFF0000
});
warning.anchor.set(0.5, 0.5);
warning.y = 350;
warning.alpha = 0;
demoContainer.addChild(warning);
tween(warning, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.easeOut,
yoyo: true,
repeat: 4
});
}, 1500);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(chaosTimer);
// Epic exit
tween(frameContainer, {
alpha: 0,
scaleX: 2,
scaleY: 2,
rotation: -0.2
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 4500);
}
});
}, 800);
}
// Cinematic intro for Level 6 - Orbital Mastery
function showLevel6Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create cosmic frame
var frameContainer = new Container();
frameContainer.alpha = 0;
transitionContainer.addChild(frameContainer);
// Create orbital rings background
var orbitRings = [];
for (var i = 0; i < 3; i++) {
var ring = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 6 + i * 3,
scaleY: 6 + i * 3,
tint: 0x1a5d61
});
ring.alpha = 0.1 - i * 0.03;
orbitRings.push(ring);
}
// Create frame
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: 0x00FFFF
});
outerFrame.alpha = 0.4;
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 13,
scaleY: 9,
tint: 0x000000
});
innerFrame.alpha = 0.95;
// Create demo container
var demoContainer = new Container();
frameContainer.addChild(demoContainer);
// Title
var title = new Text2('LEVEL 6', {
size: 180,
fill: 0x00FFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('ORBITAL MASTERY', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -250;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create orbital center
var centerOrb = demoContainer.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2,
tint: 0xFFD700
});
centerOrb.y = 100;
// Create orbiting demo balls
var orbitingBalls = [];
for (var i = 0; i < 6; i++) {
var ball = new Container();
var ballGfx = ball.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x00FFFF
});
ball.angle = i / 6 * Math.PI * 2;
ball.radius = 200;
ball.speed = 0.02;
ball.scaleX = 0;
ball.scaleY = 0;
orbitingBalls.push(ball);
demoContainer.addChild(ball);
}
// Animate entrance
tween(frameContainer, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
// Rotate orbital rings
for (var i = 0; i < orbitRings.length; i++) {
(function (ring, index) {
tween(ring, {
rotation: Math.PI * 2
}, {
duration: 10000 + index * 2000,
easing: tween.linear,
loop: true
});
})(orbitRings[i], i);
}
// Animate title
tween(title, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(subtitle, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Show orbiting balls
for (var i = 0; i < orbitingBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}, delay);
})(orbitingBalls[i], i * 100);
}
// Animate orbital motion
var orbitTimer = LK.setInterval(function () {
for (var i = 0; i < orbitingBalls.length; i++) {
var ball = orbitingBalls[i];
ball.angle += ball.speed;
ball.x = Math.cos(ball.angle) * ball.radius;
ball.y = 100 + Math.sin(ball.angle) * ball.radius;
}
}, 16);
// Create orbital paths
LK.setTimeout(function () {
for (var i = 0; i < 3; i++) {
var path = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4 + i * 1.5,
scaleY: 4 + i * 1.5,
tint: 0x00FFFF
});
path.y = 100;
path.alpha = 0;
tween(path, {
alpha: 0.2,
scaleX: path.scaleX * 1.2,
scaleY: path.scaleY * 1.2
}, {
duration: 800,
easing: tween.easeOut
});
}
}, 1000);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(orbitTimer);
tween(frameContainer, {
alpha: 0,
scaleX: 0.5,
scaleY: 0.5,
rotation: Math.PI / 4
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 4000);
}
});
}
// Cinematic intro for Level 7 - Fugitives & Lasso
function showLevel7Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create western-themed frame
var frameContainer = new Container();
frameContainer.scaleX = 0;
frameContainer.scaleY = 0;
transitionContainer.addChild(frameContainer);
// Create frame
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: 0x8B4513
});
outerFrame.alpha = 0.4;
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 13,
scaleY: 9,
tint: 0x000000
});
innerFrame.alpha = 0.95;
// Create demo container
var demoContainer = new Container();
frameContainer.addChild(demoContainer);
// Title
var title = new Text2('LEVEL 7', {
size: 180,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('FUGITIVES & LASSO', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -250;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create fleeing balls
var fugitives = [];
for (var i = 0; i < 5; i++) {
var fugitive = new Container();
var ballGfx = fugitive.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700
});
fugitive.x = -300 + i * 150;
fugitive.y = 0;
fugitive.scaleX = 0;
fugitive.scaleY = 0;
fugitives.push(fugitive);
demoContainer.addChild(fugitive);
}
// Create shepherd ball (lasso)
var shepherdDemo = new Container();
var shepherdGlow = shepherdDemo.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 3,
tint: 0x00FFFF
});
shepherdGlow.alpha = 0.3;
var shepherdCore = shepherdDemo.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0x00FFFF
});
shepherdDemo.y = 200;
shepherdDemo.scaleX = 0;
shepherdDemo.scaleY = 0;
demoContainer.addChild(shepherdDemo);
// Animate entrance
tween(frameContainer, {
scaleX: 1,
scaleY: 1
}, {
duration: 600,
easing: tween.bounceOut
});
// Animate title
LK.setTimeout(function () {
tween(subtitle, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Show fugitives
for (var i = 0; i < fugitives.length; i++) {
(function (fugitive, delay) {
LK.setTimeout(function () {
tween(fugitive, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}, delay);
})(fugitives[i], i * 100);
}
// Show shepherd ball
LK.setTimeout(function () {
tween(shepherdDemo, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 500,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(shepherdDemo, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.easeInOut
});
// Demonstrate lasso effect
LK.setTimeout(function () {
// Create lasso ring
var lassoRing = demoContainer.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
tint: 0x00FFFF
});
lassoRing.y = 200;
lassoRing.alpha = 0.8;
tween(lassoRing, {
scaleX: 6,
scaleY: 6,
alpha: 0.2
}, {
duration: 600,
easing: tween.easeOut
});
// Collect fugitives
for (var i = 0; i < fugitives.length; i++) {
(function (fugitive) {
tween(fugitive, {
x: 0,
y: 200,
scaleX: 0,
scaleY: 0,
rotation: Math.PI * 2
}, {
duration: 500,
easing: tween.easeIn
});
})(fugitives[i]);
}
// Show bonus text
var bonusText = new Text2('LASSO BONUS!', {
size: 100,
fill: 0x00FFFF,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
bonusText.anchor.set(0.5, 0.5);
bonusText.y = 350;
bonusText.alpha = 0;
demoContainer.addChild(bonusText);
tween(bonusText, {
alpha: 1,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 400,
easing: tween.easeOut,
yoyo: true
});
}, 1000);
}
});
}, 800);
// Transition out
LK.setTimeout(function () {
tween(frameContainer, {
alpha: 0,
x: -800
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 4500);
}, 500);
}
// Cinematic intro for Level 8 - Phantom Echoes
function showLevel8Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create glitchy frame
var frameContainer = new Container();
frameContainer.alpha = 1;
transitionContainer.addChild(frameContainer);
// Create glitch layers
for (var i = 0; i < 3; i++) {
var glitchLayer = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: i === 0 ? 0xFF0000 : i === 1 ? 0x00FF00 : 0x0000FF
});
glitchLayer.alpha = 0.1;
glitchLayer.x = (Math.random() - 0.5) * 10;
glitchLayer.y = (Math.random() - 0.5) * 10;
}
// Main frame
var outerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14,
scaleY: 10,
tint: 0x800080
});
outerFrame.alpha = 0.4;
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 13,
scaleY: 9,
tint: 0x000000
});
innerFrame.alpha = 0.95;
// Create demo container
var demoContainer = new Container();
frameContainer.addChild(demoContainer);
// Title with glitch effect
var title = new Text2('LEVEL 8', {
size: 180,
fill: 0x800080,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('PHANTOM ECHOES', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -250;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create phasing balls
var phantomBalls = [];
for (var i = 0; i < 4; i++) {
var phantom = new Container();
var ballGfx = phantom.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFFD700
});
phantom.x = -400 + i * 267;
phantom.y = 0;
phantom.scaleX = 1;
phantom.scaleY = 1;
phantom.alpha = 1;
phantomBalls.push(phantom);
demoContainer.addChild(phantom);
}
// Create negative/decoy balls
var negativeBalls = [];
for (var i = 0; i < 2; i++) {
var negative = new Container();
var negGfx = negative.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0xFF4444
});
var dangerAura = negative.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
tint: 0xFF0000
});
dangerAura.alpha = 0.3;
negative.x = -200 + i * 400;
negative.y = 200;
negative.scaleX = 0;
negative.scaleY = 0;
negativeBalls.push(negative);
demoContainer.addChild(negative);
}
// Glitch animation for title
var glitchTimer = LK.setInterval(function () {
if (Math.random() < 0.3) {
title.x = (Math.random() - 0.5) * 5;
title.y = -350 + (Math.random() - 0.5) * 5;
LK.setTimeout(function () {
title.x = 0;
title.y = -350;
}, 50);
}
}, 100);
// Animate subtitle
LK.setTimeout(function () {
tween(subtitle, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Phase animation for phantom balls
var phaseTimer = LK.setInterval(function () {
for (var i = 0; i < phantomBalls.length; i++) {
(function (ball, index) {
if (Math.random() < 0.5) {
tween(ball, {
alpha: ball.alpha > 0.5 ? 0.1 : 1
}, {
duration: 300,
easing: tween.easeInOut
});
}
})(phantomBalls[i], i);
}
}, 800);
// Show negative balls
for (var i = 0; i < negativeBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}, delay);
})(negativeBalls[i], 1000 + i * 200);
}
// Warning effect
LK.setTimeout(function () {
var warning = new Text2('AVOID RED BALLS!', {
size: 70,
fill: 0xFF0000,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
warning.anchor.set(0.5, 0.5);
warning.y = 350;
warning.alpha = 0;
demoContainer.addChild(warning);
tween(warning, {
alpha: 1
}, {
duration: 300,
easing: tween.easeOut,
yoyo: true,
repeat: 3
});
}, 2000);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(glitchTimer);
LK.clearInterval(phaseTimer);
// Glitch out effect
for (var i = 0; i < 5; i++) {
(function (delay) {
LK.setTimeout(function () {
frameContainer.x = (Math.random() - 0.5) * 20;
frameContainer.y = (Math.random() - 0.5) * 20;
frameContainer.alpha = Math.random();
}, delay);
})(i * 100);
}
LK.setTimeout(function () {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}, 600);
}, 4000);
}, 500);
}
// Cinematic intro for Level 9 - Chromatic Chaos
function showLevel9Intro(nextLevel) {
// Clear transition container
transitionContainer.removeChildren();
transitionContainer.x = 1024;
transitionContainer.y = 1366;
transitionContainer.scaleX = 1;
transitionContainer.scaleY = 1;
transitionContainer.alpha = 1;
// Create rainbow frame
var frameContainer = new Container();
frameContainer.alpha = 0;
transitionContainer.addChild(frameContainer);
// Create rainbow background layers
var colors = [0xFF0000, 0xFF7F00, 0xFFFF00, 0x00FF00, 0x0000FF, 0x4B0082, 0x9400D3];
for (var i = 0; i < colors.length; i++) {
var colorLayer = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 14 - i * 0.5,
scaleY: 10 - i * 0.3,
tint: colors[i]
});
colorLayer.alpha = 0.1;
colorLayer.rotation = i * 0.05;
}
// Main frame
var innerFrame = frameContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 11,
scaleY: 8,
tint: 0x000000
});
innerFrame.alpha = 0.9;
// Create demo container
var demoContainer = new Container();
frameContainer.addChild(demoContainer);
// Title with rainbow effect
var title = new Text2('LEVEL 9', {
size: 180,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
title.anchor.set(0.5, 0.5);
title.y = -350;
demoContainer.addChild(title);
// Subtitle
var subtitle = new Text2('CHROMATIC CHAOS', {
size: 80,
fill: 0xFFFFFF
});
subtitle.anchor.set(0.5, 0.5);
subtitle.y = -250;
subtitle.alpha = 0;
demoContainer.addChild(subtitle);
// Create color target indicator
var targetIndicator = demoContainer.attachAsset('bigPixel', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 3,
scaleY: 1,
tint: 0xFFD700
});
targetIndicator.y = -150;
var targetText = new Text2('TARGET COLOR', {
size: 40,
fill: 0xFFFFFF
});
targetText.anchor.set(0.5, 0.5);
targetText.y = -150;
demoContainer.addChild(targetText);
// Create chameleon balls
var chameleonBalls = [];
var ballColors = [0xFFD700, 0xFF4444, 0x44FF44];
for (var i = 0; i < 6; i++) {
var chameleon = new Container();
var ballGfx = chameleon.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
tint: ballColors[i % 3]
});
chameleon.x = -400 + i % 3 * 400;
chameleon.y = 50 + Math.floor(i / 3) * 150;
chameleon.colorIndex = i % 3;
chameleon.scaleX = 0;
chameleon.scaleY = 0;
chameleonBalls.push(chameleon);
demoContainer.addChild(chameleon);
}
// Animate entrance
tween(frameContainer, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
// Rainbow animation for title
var titleColorIndex = 0;
var titleColorTimer = LK.setInterval(function () {
titleColorIndex = (titleColorIndex + 1) % colors.length;
tween(title, {
tint: colors[titleColorIndex]
}, {
duration: 300,
easing: tween.easeInOut
});
}, 400);
// Animate elements
LK.setTimeout(function () {
tween(subtitle, {
alpha: 1
}, {
duration: 400,
easing: tween.easeOut
});
// Show chameleon balls
for (var i = 0; i < chameleonBalls.length; i++) {
(function (ball, delay) {
LK.setTimeout(function () {
tween(ball, {
scaleX: 1,
scaleY: 1
}, {
duration: 300,
easing: tween.bounceOut
});
}, delay);
})(chameleonBalls[i], i * 100);
}
// Demonstrate color changing
var colorChangeTimer = LK.setInterval(function () {
// Change target color
var targetColorIndex = Math.floor(Math.random() * 3);
tween(targetIndicator, {
tint: ballColors[targetColorIndex]
}, {
duration: 300,
easing: tween.easeInOut
});
// Flash matching balls
for (var i = 0; i < chameleonBalls.length; i++) {
var ball = chameleonBalls[i];
if (ball.colorIndex === targetColorIndex) {
tween(ball, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
easing: tween.easeOut,
yoyo: true
});
}
}
// Change some ball colors randomly
for (var i = 0; i < chameleonBalls.length; i++) {
if (Math.random() < 0.3) {
var ball = chameleonBalls[i];
ball.colorIndex = Math.floor(Math.random() * 3);
tween(ball.children[0], {
tint: ballColors[ball.colorIndex]
}, {
duration: 500,
easing: tween.easeInOut
});
}
}
}, 1500);
// Warning text
LK.setTimeout(function () {
var warning = new Text2('MATCH THE COLOR!', {
size: 70,
fill: 0xFFD700,
font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
});
warning.anchor.set(0.5, 0.5);
warning.y = 350;
warning.alpha = 0;
demoContainer.addChild(warning);
tween(warning, {
alpha: 1,
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 400,
easing: tween.easeOut,
yoyo: true,
repeat: 2
});
}, 2500);
// Transition out
LK.setTimeout(function () {
LK.clearInterval(titleColorTimer);
LK.clearInterval(colorChangeTimer);
// Epic exit with color explosion
for (var i = 0; i < 10; i++) {
(function (index) {
var explosion = frameContainer.attachAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1,
tint: colors[index % colors.length]
});
explosion.x = (Math.random() - 0.5) * 800;
explosion.y = (Math.random() - 0.5) * 600;
tween(explosion, {
scaleX: 5,
scaleY: 5,
alpha: 0
}, {
duration: 800,
delay: index * 50,
easing: tween.easeOut
});
})(i);
}
tween(frameContainer, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 800,
easing: tween.easeIn,
onFinish: function onFinish() {
transitionContainer.visible = false;
transitionContainer.removeChildren();
startLevel(nextLevel);
}
});
}, 5000);
}, 500);
}
// Helper function to convert HSL to hex
function hslToHex(h, s, l) {
l /= 100;
var a = s * Math.min(l, 1 - l) / 100;
var f = function f(n) {
var k = (n + h / 30) % 12;
var color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
return Math.round(255 * color).toString(16).padStart(2, '0');
};
return parseInt('0x' + f(0) + f(8) + f(4));
} ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,3557 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var BackgroundGradient = Container.expand(function () {
+ var self = Container.call(this);
+ self.gradientElements = [];
+ self.init = function () {
+ // Create gradient effect with multiple layers
+ for (var i = 0; i < 5; i++) {
+ var element = self.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 25,
+ scaleY: 25,
+ tint: 0x1a0000
+ });
+ element.x = 1024;
+ element.y = 1366 + i * 300;
+ element.alpha = 0.05 + i * 0.02;
+ self.gradientElements.push(element);
+ }
+ };
+ return self;
+});
+var Ball = Container.expand(function () {
+ var self = Container.call(this);
+ self.ballGraphics = null;
+ self.points = 5;
+ self.speed = 0;
+ self.vx = 0;
+ self.vy = 0;
+ self.behavior = 'static';
+ self.fleeDistance = 150;
+ self.collected = false;
+ self.init = function (level) {
+ // Calculate base level and difficulty tier
+ var baseLevel = (level - 1) % 9 + 1;
+ var difficultyTier = Math.floor((level - 1) / 9);
+ // Create ball graphic with glow effect
+ self.ballGraphics = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0xFFD700
+ });
+ // Add inner glow
+ var innerGlow = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.05,
+ scaleY: 1.05,
+ tint: 0xFFFFFF
+ });
+ innerGlow.alpha = 0.8;
+ // Add outer glow
+ var outerGlow = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.95,
+ scaleY: 1.95,
+ tint: 0xFF6B6B
+ });
+ outerGlow.alpha = 0.3;
+ // Pulsing animation
+ tween(outerGlow, {
+ scaleX: 2.25,
+ scaleY: 2.25,
+ alpha: 0.1
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
+ });
+ // Set behavior based on base level
+ if (baseLevel === 1) {
+ self.behavior = 'static';
+ self.x = 200 + Math.random() * 1648;
+ self.y = 300 + Math.random() * 2132;
+ // Apply difficulty modifiers
+ self.points = 5 + difficultyTier * 2;
+ } else if (baseLevel === 2) {
+ self.behavior = 'random';
+ self.x = Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ self.speed = (1 + Math.random() * 2) * (1 + difficultyTier * 0.3);
+ var angle = Math.random() * Math.PI * 2;
+ self.vx = Math.cos(angle) * self.speed;
+ self.vy = Math.sin(angle) * self.speed;
+ self.points = 7 + difficultyTier * 3;
+ } else if (baseLevel === 3) {
+ self.behavior = 'falling';
+ self.x = Math.random() * 2048;
+ self.y = -50;
+ self.vy = (2 + Math.random() * 3) * (1 + difficultyTier * 0.4);
+ self.points = 7 + difficultyTier * 3;
+ } else if (baseLevel === 4) {
+ self.behavior = 'fleeing';
+ self.x = 200 + Math.random() * 1648;
+ self.y = 300 + Math.random() * 2132;
+ self.speed = 3 * (1 + difficultyTier * 0.3);
+ self.fleeDistance = 150 + difficultyTier * 50;
+ self.points = 10 + difficultyTier * 4;
+ } else if (baseLevel === 5) {
+ self.behavior = 'roaming';
+ self.x = Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ self.speed = (4 + Math.random() * 2) * (1 + difficultyTier * 0.4);
+ var angle = Math.random() * Math.PI * 2;
+ self.vx = Math.cos(angle) * self.speed;
+ self.vy = Math.sin(angle) * self.speed;
+ self.points = 15 + difficultyTier * 5;
+ } else if (baseLevel === 6) {
+ // Level 6: Orbiting balls
+ self.behavior = 'orbiting';
+ self.orbitCenterX = 1024;
+ self.orbitCenterY = 1366;
+ self.orbitRadius = 200 + Math.random() * 300 - difficultyTier * 30;
+ self.orbitAngle = Math.random() * Math.PI * 2;
+ self.orbitSpeed = (0.01 + Math.random() * 0.02) * (1 + difficultyTier * 0.3);
+ self.points = 12 + difficultyTier * 4;
+ } else if (baseLevel === 7) {
+ // Level 7: Mix of fleeing and static balls
+ if (Math.random() < 0.7 + difficultyTier * 0.1) {
+ self.behavior = 'fleeing';
+ self.speed = (4 + Math.random() * 2) * (1 + difficultyTier * 0.3);
+ self.fleeDistance = 200 + difficultyTier * 50;
+ self.points = 15 + difficultyTier * 5;
+ } else {
+ self.behavior = 'static';
+ self.points = 5 + difficultyTier * 2;
+ }
+ self.x = 200 + Math.random() * 1648;
+ self.y = 300 + Math.random() * 2132;
+ } else if (baseLevel === 8) {
+ // Level 8: Phasing balls that appear and disappear
+ self.behavior = 'phasing';
+ self.x = Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ self.phaseTimer = 0;
+ self.phaseInterval = Math.max(60, 120 + Math.random() * 60 - difficultyTier * 20);
+ self.visible = true;
+ self.points = 20 + difficultyTier * 6;
+ // Some balls are negative (decoy)
+ if (Math.random() < 0.3 + difficultyTier * 0.1) {
+ self.isNegative = true;
+ self.points = -(15 + difficultyTier * 5);
+ self.ballGraphics.tint = 0xFF4444; // Red tint for negative
+ }
+ } else if (baseLevel === 9) {
+ // Level 9: Chameleon balls that change color
+ self.behavior = 'chameleon';
+ self.x = Math.random() * 2048;
+ self.y = Math.random() * 2732;
+ self.speed = (3 + Math.random() * 3) * (1 + difficultyTier * 0.3);
+ var angle = Math.random() * Math.PI * 2;
+ self.vx = Math.cos(angle) * self.speed;
+ self.vy = Math.sin(angle) * self.speed;
+ self.colorTimer = 0;
+ self.colorInterval = Math.max(90, 180 + Math.random() * 120 - difficultyTier * 30);
+ self.currentColor = 0;
+ self.colors = [0xFFD700, 0xFF4444, 0x44FF44]; // Gold, Red, Green
+ self.points = 25 + difficultyTier * 7;
+ }
+ // Apply difficulty modifiers to visual effects
+ if (difficultyTier > 0) {
+ // Make balls slightly smaller at higher difficulties
+ var sizeModifier = 1 - difficultyTier * 0.1;
+ self.ballGraphics.scaleX *= sizeModifier;
+ self.ballGraphics.scaleY *= sizeModifier;
+ innerGlow.scaleX *= sizeModifier;
+ innerGlow.scaleY *= sizeModifier;
+ outerGlow.scaleX *= sizeModifier;
+ outerGlow.scaleY *= sizeModifier;
+ }
+ // Spawn animation with rotation and scale
+ self.scaleX = 0;
+ self.scaleY = 0;
+ self.rotation = Math.random() * Math.PI * 2;
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1,
+ rotation: 0
+ }, {
+ duration: 800,
+ easing: tween.bounceOut
+ });
+ };
+ self.update = function () {
+ if (self.collected) {
+ return;
+ }
+ if (self.behavior === 'random') {
+ self.x += self.vx;
+ self.y += self.vy;
+ // Bounce off walls
+ if (self.x <= 40 || self.x >= 2008) {
+ self.vx = -self.vx;
+ LK.getSound('bounce').play();
+ }
+ if (self.y <= 40 || self.y >= 2692) {
+ self.vy = -self.vy;
+ LK.getSound('bounce').play();
+ }
+ } else if (self.behavior === 'falling') {
+ self.y += self.vy;
+ // Remove if off screen
+ if (self.y > 2782) {
+ self.collected = true;
+ for (var i = 0; i < balls.length; i++) {
+ if (balls[i] === self) {
+ balls.splice(i, 1);
+ break;
+ }
+ }
+ LK.getSound('fall').play();
+ self.destroy();
+ }
+ } else if (self.behavior === 'fleeing') {
+ // Flee from mouse position
+ if (mouseX !== null && mouseY !== null) {
+ var dx = self.x - mouseX;
+ var dy = self.y - mouseY;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < self.fleeDistance && dist > 0) {
+ // Normalize and apply flee force
+ dx /= dist;
+ dy /= dist;
+ self.x += dx * self.speed;
+ self.y += dy * self.speed;
+ // Keep within bounds
+ self.x = Math.max(40, Math.min(2008, self.x));
+ self.y = Math.max(40, Math.min(2692, self.y));
+ // Play flee sound occasionally
+ if (Math.random() < 0.02) {
+ LK.getSound('flee').play();
+ }
+ }
+ }
+ } else if (self.behavior === 'roaming') {
+ self.x += self.vx;
+ self.y += self.vy;
+ // Bounce off walls
+ if (self.x <= 40 || self.x >= 2008) {
+ self.vx = -self.vx;
+ LK.getSound('bounce').play();
+ }
+ if (self.y <= 40 || self.y >= 2692) {
+ self.vy = -self.vy;
+ LK.getSound('bounce').play();
+ }
+ // Occasionally change direction
+ if (Math.random() < 0.02) {
+ var angle = Math.random() * Math.PI * 2;
+ self.vx = Math.cos(angle) * self.speed;
+ self.vy = Math.sin(angle) * self.speed;
+ LK.getSound('roam').play();
+ }
+ } else if (self.behavior === 'orbiting') {
+ // Orbital movement around center point
+ self.orbitAngle += self.orbitSpeed;
+ self.x = self.orbitCenterX + Math.cos(self.orbitAngle) * self.orbitRadius;
+ self.y = self.orbitCenterY + Math.sin(self.orbitAngle) * self.orbitRadius;
+ self.rotation = self.orbitAngle + Math.PI / 2;
+ // Play orbit sound occasionally
+ if (Math.random() < 0.005) {
+ LK.getSound('orbit').play();
+ }
+ } else if (self.behavior === 'phasing') {
+ // Phase in and out of visibility
+ self.phaseTimer++;
+ if (self.phaseTimer >= self.phaseInterval) {
+ self.phaseTimer = 0;
+ self.visible = !self.visible;
+ self.alpha = self.visible ? 1 : 0.3;
+ // Can only be collected when fully visible
+ self.interactive = self.visible;
+ LK.getSound('phase').play();
+ }
+ } else if (self.behavior === 'chameleon') {
+ // Change colors periodically
+ self.colorTimer++;
+ if (self.colorTimer >= self.colorInterval) {
+ self.colorTimer = 0;
+ self.currentColor = (self.currentColor + 1) % self.colors.length;
+ tween(self.ballGraphics, {
+ tint: self.colors[self.currentColor]
+ }, {
+ duration: 500,
+ easing: tween.easeInOut
+ });
+ LK.getSound('colorChange').play();
+ }
+ // Roaming movement
+ self.x += self.vx;
+ self.y += self.vy;
+ // Bounce off walls
+ if (self.x <= 40 || self.x >= 2008) {
+ self.vx = -self.vx;
+ LK.getSound('bounce').play();
+ }
+ if (self.y <= 40 || self.y >= 2692) {
+ self.vy = -self.vy;
+ LK.getSound('bounce').play();
+ }
+ }
+ };
+ self.down = function () {
+ if (self.collected) {
+ return;
+ }
+ self.collected = true;
+ // Calculate points based on ball type
+ var basePoints = self.points;
+ // Check if ball is red (any red tint value)
+ if (self.ballGraphics && (self.ballGraphics.tint === 0xFF4444 || self.ballGraphics.tint === 0xFF0000 || self.ballGraphics.tint >= 0xFF0000 && self.ballGraphics.tint <= 0xFF4444)) {
+ basePoints = 5; // All red balls give 5 points
+ } else if (self.behavior === 'fleeing') {
+ basePoints = 10;
+ } else if (self.behavior === 'roaming') {
+ basePoints = 15;
+ } else if (self.behavior === 'falling') {
+ basePoints = 7;
+ } else if (self.behavior === 'orbiting') {
+ basePoints = 12;
+ } else if (self.behavior === 'phasing') {
+ basePoints = 20;
+ } else if (self.behavior === 'chameleon') {
+ // Level 9: Check if ball matches target color
+ if (currentLevel === 9 && self.ballGraphics && targetColor) {
+ // First check if it's red - red balls always give 5 points
+ if (self.ballGraphics.tint === 0xFF4444 || self.ballGraphics.tint === 0xFF0000) {
+ basePoints = 5;
+ } else if (self.ballGraphics.tint === targetColor) {
+ basePoints = 30; // Bonus for matching color
+ } else {
+ basePoints = 5; // Reduced points for wrong color
+ }
+ } else {
+ basePoints = 25;
+ }
+ }
+ // Handle negative balls (Level 8)
+ if (self.isNegative) {
+ basePoints = -15;
+ // Create warning effect
+ createExplosion(self.x, self.y, 0xFF0000);
+ screenShake(15, 400);
+ }
+ // Award points
+ LK.setScore(LK.getScore() + basePoints);
+ LK.getSound('hit').play();
+ // Create floating score text
+ var scoreFloat = game.addChild(new Container());
+ scoreFloat.x = self.x;
+ scoreFloat.y = self.y;
+ var floatText = new Text2('+' + basePoints, {
+ size: 60,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ floatText.anchor.set(0.5, 0.5);
+ scoreFloat.addChild(floatText);
+ // Animate floating score
+ tween(scoreFloat, {
+ y: self.y - 100,
+ alpha: 0
+ }, {
+ duration: 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ scoreFloat.destroy();
+ }
+ });
+ // Collection animation
+ tween(self.ballGraphics, {
+ scaleX: 1.5,
+ scaleY: 1.5,
+ alpha: 0
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ for (var i = 0; i < balls.length; i++) {
+ if (balls[i] === self) {
+ balls.splice(i, 1);
+ break;
+ }
+ }
+ self.destroy();
+ }
+ });
+ // Create particle effect - bright red explosion
+ createExplosion(self.x, self.y, 0xFF0000);
+ };
+ return self;
+});
+var Bird = Container.expand(function () {
+ var self = Container.call(this);
+ var birdPixel = self.attachAsset('birdPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.targetX = 0;
+ self.targetY = 0;
+ self.speed = 0.02;
+ self.update = function () {
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ self.x += dx * self.speed;
+ self.y += dy * self.speed;
+ if (Math.abs(dx) < 5 && Math.abs(dy) < 5) {
+ self.findNewTarget();
+ }
+ };
+ self.findNewTarget = function () {
+ var angle = Math.random() * Math.PI * 2;
+ var distance = 100 + Math.random() * 200;
+ self.targetX = self.x + Math.cos(angle) * distance;
+ self.targetY = self.y + Math.sin(angle) * distance;
+ self.targetX = Math.max(100, Math.min(1948, self.targetX));
+ self.targetY = Math.max(100, Math.min(1000, self.targetY));
+ };
+ return self;
+});
+var FloatingElement = Container.expand(function () {
+ var self = Container.call(this);
+ self.elementGraphics = null;
+ self.floatSpeed = 0.5;
+ self.bobAmount = 2;
+ self.bobSpeed = 0.05;
+ self.initialY = 0;
+ self.time = 0;
+ self.init = function (type, x, y) {
+ self.x = x;
+ self.y = y;
+ self.initialY = y;
+ self.time = Math.random() * Math.PI * 2;
+ if (type === 'cloud') {
+ // Create cloud with multiple layers
+ var cloudBase = self.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 0.8,
+ tint: 0x2a2a2a
+ });
+ cloudBase.alpha = 0.3;
+ self.elementGraphics = self.attachAsset('pixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 0.6,
+ tint: 0x3a3a3a
+ });
+ self.floatSpeed = 0.3;
+ self.alpha = 0.4;
+ } else if (type === 'star') {
+ // Create sparkling star
+ self.elementGraphics = self.attachAsset('tinyPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 1,
+ tint: 0xFFD700
+ });
+ self.floatSpeed = 0.1;
+ self.bobAmount = 1;
+ // Add twinkle animation
+ tween(self.elementGraphics, {
+ alpha: 0.3,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 1000 + Math.random() * 2000,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
+ });
+ }
+ // Fade in animation
+ self.alpha = 0;
+ tween(self, {
+ alpha: self.alpha || 0.6
+ }, {
+ duration: 2000,
+ easing: tween.easeOut
+ });
+ };
+ self.update = function () {
+ self.x -= self.floatSpeed;
+ self.time += self.bobSpeed;
+ self.y = self.initialY + Math.sin(self.time) * self.bobAmount;
+ // Reset position when off screen
+ if (self.x < -100) {
+ self.x = 2148;
+ self.y = Math.random() * 1500 + 100;
+ self.initialY = self.y;
+ }
+ };
+ return self;
+});
+var InteractiveObject = Container.expand(function () {
+ var self = Container.call(this);
+ var objectGraphics = self.attachAsset('pixel', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.init = function (x, y) {
+ self.x = x;
+ self.y = y;
+ self.visible = true;
+ };
+ self.down = function () {
+ self.visible = false;
+ };
+ return self;
+});
+var OrbitingBall = Container.expand(function () {
+ var self = Container.call(this);
+ self.ballGraphics = null;
+ self.points = 12;
+ self.orbitRadius = 200;
+ self.orbitSpeed = 0.02;
+ self.orbitAngle = 0;
+ self.centerX = 1024;
+ self.centerY = 1366;
+ self.collected = false;
+ self.init = function () {
+ // Create ball with orbital effect
+ self.ballGraphics = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.3,
+ scaleY: 1.3,
+ tint: 0x00FFFF
+ });
+ // Add orbital trail
+ var trail = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.8,
+ scaleY: 1.8,
+ tint: 0x00FFFF
+ });
+ trail.alpha = 0.2;
+ // Set random starting angle
+ self.orbitAngle = Math.random() * Math.PI * 2;
+ self.orbitRadius = 150 + Math.random() * 200;
+ self.orbitSpeed = 0.01 + Math.random() * 0.02;
+ // Spawn animation
+ self.scaleX = 0;
+ self.scaleY = 0;
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ };
+ self.update = function () {
+ if (self.collected) {
+ return;
+ }
+ // Orbital movement
+ self.orbitAngle += self.orbitSpeed;
+ self.x = self.centerX + Math.cos(self.orbitAngle) * self.orbitRadius;
+ self.y = self.centerY + Math.sin(self.orbitAngle) * self.orbitRadius;
+ self.rotation = self.orbitAngle + Math.PI / 2;
+ };
+ self.down = Ball.prototype.down;
+ return self;
+});
+var Particle = Container.expand(function () {
+ var self = Container.call(this);
+ self.particleGraphics = null;
+ self.vx = 0;
+ self.vy = 0;
+ self.gravity = 0.2;
+ self.friction = 0.98;
+ self.lifespan = 60;
+ self.maxLife = 60;
+ self.init = function (x, y, color, size) {
+ self.x = x;
+ self.y = y;
+ // Choose pixel size based on size parameter for dust effect
+ var pixelType = 'pixel';
+ var baseScale = 1;
+ if (size < 0.3) {
+ pixelType = 'tinyPixel';
+ baseScale = 0.5 + Math.random() * 0.3; // More size variation for tiny particles
+ } else if (size < 0.6) {
+ pixelType = 'smallPixel';
+ baseScale = 0.7 + Math.random() * 0.4;
+ }
+ self.particleGraphics = self.attachAsset(pixelType, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: baseScale,
+ scaleY: baseScale,
+ tint: color || 0xFFFFFF
+ });
+ // Dust-like velocity patterns
+ var angle = Math.random() * Math.PI * 2;
+ var speed;
+ if (size < 0.3) {
+ // Tiny particles: slower, more floating movement
+ speed = 0.5 + Math.random() * 2;
+ self.gravity = 0.05 + Math.random() * 0.1;
+ self.friction = 0.995;
+ } else if (size < 0.6) {
+ // Medium particles: moderate speed
+ speed = 1.5 + Math.random() * 3;
+ self.gravity = 0.15 + Math.random() * 0.1;
+ self.friction = 0.98;
+ } else {
+ // Large particles: faster, more dramatic
+ speed = 3 + Math.random() * 5;
+ self.gravity = 0.2 + Math.random() * 0.15;
+ self.friction = 0.97;
+ }
+ self.vx = Math.cos(angle) * speed;
+ self.vy = Math.sin(angle) * speed - (1 + Math.random() * 2);
+ // Varied lifespans for dust-like effect
+ if (size < 0.3) {
+ self.lifespan = 60 + Math.random() * 40; // Tiny particles last longer
+ } else {
+ self.lifespan = 30 + Math.random() * 30; // Larger particles fade faster
+ }
+ self.maxLife = self.lifespan;
+ };
+ self.update = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.vy += self.gravity;
+ self.vx *= self.friction;
+ self.lifespan--;
+ self.alpha = self.lifespan / self.maxLife;
+ if (self.lifespan <= 0) {
+ self.destroy();
+ for (var i = 0; i < particles.length; i++) {
+ if (particles[i] === self) {
+ particles.splice(i, 1);
+ break;
+ }
+ }
+ }
+ };
+ return self;
+});
+var Pixel = Container.expand(function () {
+ var self = Container.call(this);
+ self.pixelType = 'trunk';
+ self.pixelGraphics = null;
+ self.init = function (type, color, size) {
+ self.pixelType = type;
+ if (self.pixelGraphics) {
+ self.pixelGraphics.destroy();
+ }
+ // Choose appropriate pixel asset based on size
+ var pixelAsset = 'pixel';
+ var baseScale = size || 1;
+ if (size && size < 0.5) {
+ pixelAsset = 'tinyPixel';
+ baseScale = 1;
+ } else if (size && size < 0.8) {
+ pixelAsset = 'smallPixel';
+ baseScale = 1;
+ }
+ var assetConfig = {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: baseScale,
+ scaleY: baseScale
+ };
+ if (color) {
+ assetConfig.tint = color;
+ }
+ if (type === 'seed') {
+ self.pixelGraphics = self.attachAsset('seedPixel', {});
+ } else if (type === 'leaf') {
+ self.pixelGraphics = self.attachAsset('leafPixel', {});
+ } else if (type === 'flower') {
+ self.pixelGraphics = self.attachAsset('flowerPixel', {});
+ } else if (type === 'bird') {
+ self.pixelGraphics = self.attachAsset('birdPixel', {});
+ } else if (type === 'root' || type === 'trunk' || type === 'branch') {
+ self.pixelGraphics = self.attachAsset(pixelAsset, {});
+ } else {
+ self.pixelGraphics = self.attachAsset(pixelAsset, {});
+ }
+ self.alpha = 0;
+ };
+ self.fadeIn = function (duration) {
+ tween(self, {
+ alpha: 1
+ }, {
+ duration: duration || 500,
+ easing: tween.easeOut
+ });
+ };
+ self.grow = function (targetScale, duration) {
+ if (self.pixelGraphics) {
+ tween(self.pixelGraphics, {
+ scaleX: targetScale,
+ scaleY: targetScale
+ }, {
+ duration: duration || 1000,
+ easing: tween.easeInOut
+ });
+ }
+ };
+ return self;
+});
+var ShepherdBall = Container.expand(function () {
+ var self = Container.call(this);
+ self.collected = false;
+ self.lifespan = 300; // 5 seconds
+ self.catchRadius = 300;
+ self.init = function () {
+ // Create shepherd ball with special appearance
+ var outerGlow = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 3,
+ scaleY: 3,
+ tint: 0x00FFFF
+ });
+ outerGlow.alpha = 0.2;
+ var midGlow = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2,
+ tint: 0x00FFFF
+ });
+ midGlow.alpha = 0.4;
+ self.ballGraphics = self.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0x00FFFF
+ });
+ // Position randomly
+ self.x = 200 + Math.random() * 1648;
+ self.y = 300 + Math.random() * 2132;
+ // Spawn animation
+ self.scaleX = 0;
+ self.scaleY = 0;
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.bounceOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ // Pulsing effect
+ tween(outerGlow, {
+ scaleX: 3.5,
+ scaleY: 3.5,
+ alpha: 0.1
+ }, {
+ duration: 1000,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
+ });
+ };
+ self.update = function () {
+ if (self.collected) {
+ return;
+ }
+ self.lifespan--;
+ // Start fading when about to disappear
+ if (self.lifespan < 60) {
+ self.alpha = self.lifespan / 60;
+ }
+ // Remove when lifespan ends
+ if (self.lifespan <= 0) {
+ self.collected = true;
+ self.destroy();
+ }
+ };
+ self.down = function () {
+ if (self.collected) {
+ return;
+ }
+ self.collected = true;
+ // Collect all fleeing balls in radius
+ var collectedCount = 0;
+ for (var i = balls.length - 1; i >= 0; i--) {
+ var ball = balls[i];
+ if (ball.behavior === 'fleeing' && !ball.collected) {
+ var dx = ball.x - self.x;
+ var dy = ball.y - self.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist < self.catchRadius) {
+ ball.collected = true;
+ collectedCount++;
+ // Award points
+ LK.setScore(LK.getScore() + ball.points);
+ // Create collection effect
+ createExplosion(ball.x, ball.y, 0x00FFFF);
+ // Animate ball collection
+ tween(ball, {
+ x: self.x,
+ y: self.y,
+ scaleX: 0,
+ scaleY: 0,
+ rotation: Math.PI * 2
+ }, {
+ duration: 300,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ ball.destroy();
+ }
+ });
+ }
+ }
+ }
+ // Bonus points for multiple catches
+ if (collectedCount > 0) {
+ var bonusPoints = collectedCount * 10;
+ LK.setScore(LK.getScore() + bonusPoints);
+ // Show bonus text
+ var bonusText = game.addChild(new Container());
+ bonusText.x = self.x;
+ bonusText.y = self.y;
+ var text = new Text2('LASSO! +' + (collectedCount * 15 + bonusPoints), {
+ size: 80,
+ fill: 0x00FFFF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ text.anchor.set(0.5, 0.5);
+ bonusText.addChild(text);
+ tween(bonusText, {
+ y: self.y - 150,
+ alpha: 0
+ }, {
+ duration: 1500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ bonusText.destroy();
+ }
+ });
+ LK.getSound('lasso').play();
+ }
+ // Play sound
+ LK.getSound('hit').play();
+ // Remove shepherd ball with effect
+ tween(self, {
+ scaleX: 2,
+ scaleY: 2,
+ alpha: 0
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Level-based ball collection game
+game.setBackgroundColor(0x0a0a0a); // Deep black background for dramatic contrast
+// GLAUD Logo Container
+var glaudContainer = game.addChild(new Container());
+glaudContainer.visible = false;
+// Game variables
+var balls = [];
+var particles = [];
+var floatingElements = [];
+var currentLevel = 1;
+var levelScore = 0;
+var levelTimeLimit = 30; // Level 1 starts with 30 seconds
+var levelTimer = 0;
+var levelStartTime = 0;
+var gameTime = 0; // Add gameTime variable
+var isTransitioning = false;
+var screenShakeX = 0;
+var screenShakeY = 0;
+var shakeIntensity = 0;
+var shakeDuration = 0;
+var mouseX = null;
+var mouseY = null;
+var ballSpawnTimer = 0;
+var levelRequirements = [100, 200, 300, 400, 500, 600, 700, 800, 900]; // Score requirements per level
+var highestLevel = storage.highestLevel || 1; // Load saved highest level
+// Function to get level requirement for any level
+function getLevelRequirement(level) {
+ var baseLevel = (level - 1) % 9 + 1;
+ var difficultyTier = Math.floor((level - 1) / 9);
+ var baseRequirement = levelRequirements[baseLevel - 1];
+ // Increase requirements by 50% for each difficulty tier
+ return Math.floor(baseRequirement * Math.pow(1.5, difficultyTier));
+}
+var targetColor = 0; // For level 9 color targeting
+var targetColorIndex = 0;
+var colorTargetTimer = 0;
+var shepherdBalls = []; // For level 7 shepherd balls
+// Score display with shadow effect
+var scoreTextShadow = new Text2('Level 1 | Score: 0 | Time: 30', {
+ size: 62,
+ fill: 0x000000
+});
+scoreTextShadow.anchor.set(0, 0);
+scoreTextShadow.x = 182;
+scoreTextShadow.y = 12;
+scoreTextShadow.alpha = 0.5;
+LK.gui.topLeft.addChild(scoreTextShadow);
+var scoreText = new Text2('Level 1 | Score: 0 | Time: 30', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+scoreText.anchor.set(0, 0);
+scoreText.x = 180;
+scoreText.y = 10;
+LK.gui.topLeft.addChild(scoreText);
+// Highest level display
+var highestLevelText = new Text2('Best: Level ' + highestLevel, {
+ size: 40,
+ fill: 0xFFA500
+});
+highestLevelText.anchor.set(1, 0);
+highestLevelText.x = -20;
+highestLevelText.y = 10;
+LK.gui.topRight.addChild(highestLevelText);
+highestLevelText.visible = false;
+// Initialize progress bar animation variables
+var lastProgressValue = 0;
+var progressPulseActive = false;
+// Level transition container
+var transitionContainer = game.addChild(new Container());
+transitionContainer.x = 1024;
+transitionContainer.y = 1366;
+// Level transition text with outline - modern style
+var levelTransitionOutline = new Text2('', {
+ size: 124,
+ fill: 0x000000,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+});
+levelTransitionOutline.anchor.set(0.5, 0.5);
+levelTransitionOutline.x = 4;
+levelTransitionOutline.y = 4;
+levelTransitionOutline.alpha = 0.5;
+transitionContainer.addChild(levelTransitionOutline);
+var levelTransitionText = new Text2('', {
+ size: 120,
+ fill: 0xFFFFFF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+});
+levelTransitionText.anchor.set(0.5, 0.5);
+transitionContainer.addChild(levelTransitionText);
+// Add glow effect container
+var glowContainer = new Container();
+glowContainer.x = 0;
+glowContainer.y = 0;
+transitionContainer.addChildAt(glowContainer, 0);
+// Create glow layers
+for (var i = 0; i < 3; i++) {
+ var glowText = new Text2('', {
+ size: 120 + i * 8,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glowText.anchor.set(0.5, 0.5);
+ glowText.alpha = 0.15 - i * 0.05;
+ glowContainer.addChild(glowText);
+}
+transitionContainer.visible = false;
+// Create background gradient
+var bgGradient = new BackgroundGradient();
+bgGradient.init();
+game.addChild(bgGradient);
+// Start background music
+LK.playMusic('gameMusic', {
+ loop: true
+});
+// GLAUD intro function
+function showGLAUDIntro() {
+ isTransitioning = true;
+ // Create intro container
+ var introContainer = game.addChild(new Container());
+ introContainer.x = 1024;
+ introContainer.y = 1366;
+ introContainer.alpha = 0;
+ // Create game ball shower effect
+ var ballShower = [];
+ for (var i = 0; i < 15; i++) {
+ var ballContainer = new Container();
+ var ball = ballContainer.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.5 + Math.random() * 0.5,
+ scaleY: 0.5 + Math.random() * 0.5,
+ tint: i < 5 ? 0xFFD700 : i < 10 ? 0xFF4444 : 0x44FF44
+ });
+ ballContainer.x = -800 + Math.random() * 1600;
+ ballContainer.y = -800 - Math.random() * 400;
+ ballContainer.vx = (Math.random() - 0.5) * 2;
+ ballContainer.vy = 5 + Math.random() * 5;
+ ballContainer.rotation = Math.random() * Math.PI * 2;
+ introContainer.addChild(ballContainer);
+ ballShower.push(ballContainer);
+ }
+ // Create GLAUD text with multiple layers for effect
+ var glaudOutline = new Text2('GLAUD', {
+ size: 240,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glaudOutline.anchor.set(0.5, 0.5);
+ glaudOutline.alpha = 0.2;
+ introContainer.addChild(glaudOutline);
+ var glaudShadow = new Text2('GLAUD', {
+ size: 200,
+ fill: 0x000000,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glaudShadow.anchor.set(0.5, 0.5);
+ glaudShadow.x = 8;
+ glaudShadow.y = 8;
+ glaudShadow.alpha = 0.5;
+ introContainer.addChild(glaudShadow);
+ var glaudGlow = new Text2('GLAUD', {
+ size: 210,
+ fill: 0xFF6600,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glaudGlow.anchor.set(0.5, 0.5);
+ glaudGlow.alpha = 0.3;
+ introContainer.addChild(glaudGlow);
+ var glaudText = new Text2('GLAUD', {
+ size: 180,
+ fill: 0xFFA500,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glaudText.anchor.set(0.5, 0.5);
+ introContainer.addChild(glaudText);
+ // Add dynamic subtitle
+ var subtitle = new Text2('BALL COLLECTOR', {
+ size: 60,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = 100;
+ subtitle.alpha = 0;
+ introContainer.addChild(subtitle);
+ // Create energy ring
+ var energyRing = introContainer.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ tint: 0xFFA500
+ });
+ energyRing.alpha = 0.8;
+ // Start with explosion effect
+ introContainer.scaleX = 0.1;
+ introContainer.scaleY = 0.1;
+ introContainer.alpha = 1;
+ // Explosive entrance
+ tween(introContainer, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(introContainer, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ // Animate energy ring
+ tween(energyRing, {
+ scaleX: 8,
+ scaleY: 8,
+ alpha: 0
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ // Animate balls falling
+ var ballTimer = LK.setInterval(function () {
+ for (var i = 0; i < ballShower.length; i++) {
+ var ballContainer = ballShower[i];
+ ballContainer.x += ballContainer.vx;
+ ballContainer.y += ballContainer.vy;
+ ballContainer.rotation += 0.1;
+ ballContainer.vy += 0.3;
+ if (ballContainer.y > 800) {
+ ballContainer.y = -800 - Math.random() * 400;
+ ballContainer.x = -800 + Math.random() * 1600;
+ ballContainer.vy = 5 + Math.random() * 5;
+ }
+ }
+ }, 16);
+ // Quick glow pulse
+ tween(glaudGlow, {
+ scaleX: 1.15,
+ scaleY: 1.15,
+ alpha: 0.6
+ }, {
+ duration: 400,
+ easing: tween.easeInOut,
+ yoyo: true,
+ repeat: 1
+ });
+ // Show subtitle
+ LK.setTimeout(function () {
+ tween(subtitle, {
+ alpha: 1,
+ y: 120
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }, 200);
+ // Create collecting effect
+ LK.setTimeout(function () {
+ // All balls converge to center
+ for (var i = 0; i < ballShower.length; i++) {
+ (function (ballContainer, index) {
+ tween(ballContainer, {
+ x: 0,
+ y: 0,
+ scaleX: 0,
+ scaleY: 0,
+ rotation: Math.PI * 4
+ }, {
+ duration: 400,
+ delay: index * 20,
+ easing: tween.easeIn
+ });
+ })(ballShower[i], i);
+ }
+ // Flash effect when balls are collected
+ LK.setTimeout(function () {
+ var flash = introContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 20,
+ scaleY: 20,
+ tint: 0xFFD700
+ });
+ flash.alpha = 0.8;
+ tween(flash, {
+ alpha: 0
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ // Score burst effect
+ var scoreText = new Text2('+1000', {
+ size: 100,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ scoreText.anchor.set(0.5, 0.5);
+ scoreText.y = -50;
+ scoreText.alpha = 0;
+ introContainer.addChild(scoreText);
+ tween(scoreText, {
+ y: -150,
+ alpha: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(scoreText, {
+ alpha: 0
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ }, 300);
+ }, 800);
+ // Quick transition to game
+ LK.setTimeout(function () {
+ LK.clearInterval(ballTimer);
+ // Create permanent GLAUD logo in top right
+ glaudContainer.x = 1900;
+ glaudContainer.y = 80;
+ var glaudLogo = new Text2('GLAUD', {
+ size: 60,
+ fill: 0xFFA500,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ glaudLogo.anchor.set(1, 0);
+ glaudContainer.addChild(glaudLogo);
+ // Quick fade out with rotation
+ tween(introContainer, {
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5,
+ rotation: 0.2
+ }, {
+ duration: 400,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ introContainer.destroy();
+ // Show GLAUD logo and highest level
+ glaudContainer.alpha = 0;
+ glaudContainer.visible = true;
+ tween(glaudContainer, {
+ alpha: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ highestLevelText.visible = true;
+ isTransitioning = false;
+ // Start first level
+ startLevel(1);
+ }
+ });
+ }, 1500);
+}
+// Create GLAUD intro
+showGLAUDIntro();
+// Particle and effect functions
+function createExplosion(x, y, color) {
+ // Create multi-layered explosion effect
+ for (var i = 0; i < 30; i++) {
+ var particle = new Particle();
+ // Mix of particle sizes for depth
+ var sizeVariation = 0.1 + Math.random() * 0.5;
+ // Vary colors for richness
+ var particleColor = color;
+ if (Math.random() < 0.3) {
+ particleColor = 0xFFFFFF; // White sparkles
+ } else if (Math.random() < 0.5) {
+ particleColor = 0xFFD700; // Gold accents
+ }
+ particle.init(x, y, particleColor, sizeVariation);
+ particles.push(particle);
+ game.addChild(particle);
+ }
+ // Create ring effect
+ var ring = game.addChild(new Container());
+ ring.x = x;
+ ring.y = y;
+ var ringGraphic = ring.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ tint: color
+ });
+ ringGraphic.alpha = 0.8;
+ tween(ringGraphic, {
+ scaleX: 3,
+ scaleY: 3,
+ alpha: 0
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ ring.destroy();
+ }
+ });
+}
+function createTrailParticle(x, y, color) {
+ var particle = new Particle();
+ particle.init(x, y, color, 0.2);
+ particle.lifespan = 20;
+ particle.maxLife = 20;
+ particles.push(particle);
+ game.addChild(particle);
+}
+function screenShake(intensity, duration) {
+ shakeIntensity = intensity;
+ shakeDuration = duration;
+}
+function updateScreenShake() {
+ if (shakeDuration > 0) {
+ screenShakeX = (Math.random() - 0.5) * shakeIntensity;
+ screenShakeY = (Math.random() - 0.5) * shakeIntensity;
+ game.x = screenShakeX;
+ game.y = screenShakeY;
+ shakeDuration -= 16;
+ } else {
+ game.x = 0;
+ game.y = 0;
+ }
+}
+// Function to spawn balls based on level
+function spawnBall() {
+ if (isTransitioning) {
+ return;
+ }
+ var ball = new Ball();
+ ball.init(currentLevel);
+ balls.push(ball);
+ game.addChild(ball);
+ LK.getSound('spawn').play();
+}
+// Function to start a new level
+function startLevel(level) {
+ currentLevel = level;
+ levelScore = 0;
+ levelStartTime = gameTime;
+ // Save highest level reached
+ if (level > highestLevel) {
+ highestLevel = level;
+ storage.highestLevel = highestLevel;
+ highestLevelText.setText('Best: Level ' + highestLevel);
+ }
+ // Calculate base level and difficulty tier
+ var baseLevel = (level - 1) % 9 + 1;
+ var difficultyTier = Math.floor((level - 1) / 9);
+ // Set time limit for level with difficulty adjustments
+ if (baseLevel === 1) {
+ levelTimeLimit = Math.max(20, 30 - difficultyTier * 5);
+ } else if (baseLevel <= 5) {
+ levelTimeLimit = Math.max(30, 30 + (baseLevel - 1) * 20 - difficultyTier * 10);
+ } else {
+ // Harder time limits for levels 6-9
+ levelTimeLimit = Math.max(60, 120 + (baseLevel - 6) * 10 - difficultyTier * 15);
+ }
+ // Clear existing balls
+ for (var i = balls.length - 1; i >= 0; i--) {
+ balls[i].destroy();
+ }
+ balls = [];
+ lastProgressValue = 0;
+ progressPulseActive = false;
+ // Reset score to 0 for this level
+ LK.setScore(0);
+ levelScore = 0;
+ // Show intro for level 1
+ if (level === 1 && gameTime === 0) {
+ isTransitioning = true;
+ transitionContainer.visible = true;
+ transitionContainer.alpha = 1;
+ // Clear any existing children except the main text elements
+ for (var i = transitionContainer.children.length - 1; i >= 0; i--) {
+ var child = transitionContainer.children[i];
+ if (child !== levelTransitionText && child !== levelTransitionOutline && child !== glowContainer) {
+ child.destroy();
+ }
+ }
+ levelTransitionText.setText('LEVEL 1');
+ levelTransitionOutline.setText('LEVEL 1');
+ levelTransitionText.size = 140;
+ levelTransitionOutline.size = 144;
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 0;
+ transitionContainer.scaleY = 0;
+ // Intro animation
+ tween(transitionContainer, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(transitionContainer, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ // Add subtitle
+ var subtitle = new Text2('Collect the Balls!', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = 80;
+ subtitle.alpha = 0;
+ transitionContainer.addChild(subtitle);
+ tween(subtitle, {
+ alpha: 1,
+ y: 60
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ LK.setTimeout(function () {
+ tween(transitionContainer, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChild(subtitle);
+ subtitle.destroy();
+ isTransitioning = false;
+ // Spawn initial balls
+ var initialBalls = 5 + baseLevel * 2 + difficultyTier * 3;
+ for (var i = 0; i < initialBalls; i++) {
+ spawnBall();
+ }
+ }
+ });
+ }, 1500);
+ }
+ });
+ }
+ });
+ }
+ });
+ } else {
+ isTransitioning = false;
+ // Spawn initial balls based on level
+ var initialBalls = 5 + baseLevel * 2 + difficultyTier * 3;
+ for (var i = 0; i < initialBalls; i++) {
+ spawnBall();
+ }
+ }
+}
+// Function to show level transition
+function showLevelTransition(nextLevel) {
+ isTransitioning = true;
+ // Clear balls
+ for (var i = balls.length - 1; i >= 0; i--) {
+ balls[i].destroy();
+ }
+ balls = [];
+ // Calculate base level and difficulty tier
+ var baseLevel = (nextLevel - 1) % 9 + 1;
+ var difficultyTier = Math.floor((nextLevel - 1) / 9);
+ // Create modern transition sequence
+ transitionContainer.visible = true;
+ transitionContainer.alpha = 1;
+ // First show completion message
+ levelTransitionText.setText('LEVEL ' + (nextLevel - 1) + ' COMPLETE');
+ levelTransitionOutline.setText('LEVEL ' + (nextLevel - 1) + ' COMPLETE');
+ levelTransitionText.size = 100;
+ levelTransitionOutline.size = 104;
+ // Clear any existing children except the main text elements
+ for (var i = transitionContainer.children.length - 1; i >= 0; i--) {
+ var child = transitionContainer.children[i];
+ if (child !== levelTransitionText && child !== levelTransitionOutline && child !== glowContainer) {
+ child.destroy();
+ }
+ }
+ // Start with slide in from left
+ transitionContainer.x = -500;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.rotation = 0;
+ // Slide in animation
+ tween(transitionContainer, {
+ x: 1024
+ }, {
+ duration: 600,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Pulse effect
+ tween(transitionContainer, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ yoyo: true,
+ onFinish: function onFinish() {
+ // Wait then show next level intro
+ LK.setTimeout(function () {
+ // Show cinematic intro based on base level
+ if (nextLevel <= 9) {
+ // Original intros for levels 1-9
+ if (nextLevel === 2) {
+ showLevel2Intro(nextLevel);
+ } else if (nextLevel === 3) {
+ showLevel3Intro(nextLevel);
+ } else if (nextLevel === 4) {
+ showLevel4Intro(nextLevel);
+ } else if (nextLevel === 5) {
+ showLevel5Intro(nextLevel);
+ } else if (nextLevel === 6) {
+ showLevel6Intro(nextLevel);
+ } else if (nextLevel === 7) {
+ showLevel7Intro(nextLevel);
+ } else if (nextLevel === 8) {
+ showLevel8Intro(nextLevel);
+ } else if (nextLevel === 9) {
+ showLevel9Intro(nextLevel);
+ }
+ } else {
+ // For levels 10+, show level with difficulty tier
+ levelTransitionText.setText('LEVEL ' + nextLevel);
+ levelTransitionOutline.setText('LEVEL ' + nextLevel);
+ levelTransitionText.size = 140;
+ levelTransitionOutline.size = 144;
+ // Reset position for intro animation
+ transitionContainer.x = 1024;
+ transitionContainer.scaleX = 0;
+ transitionContainer.scaleY = 0;
+ transitionContainer.alpha = 0;
+ // Intro animation - expand from center
+ tween(transitionContainer, {
+ scaleX: 1.2,
+ scaleY: 1.2,
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Shrink to normal size
+ tween(transitionContainer, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ // Add subtitle showing difficulty tier
+ var subtitleText = 'Difficulty Tier ' + (difficultyTier + 1);
+ if (baseLevel === 1) {
+ subtitleText += ' - Static Balls';
+ } else if (baseLevel === 2) {
+ subtitleText += ' - Random Movement';
+ } else if (baseLevel === 3) {
+ subtitleText += ' - Falling Balls';
+ } else if (baseLevel === 4) {
+ subtitleText += ' - Fleeing Balls';
+ } else if (baseLevel === 5) {
+ subtitleText += ' - Roaming Chaos';
+ } else if (baseLevel === 6) {
+ subtitleText += ' - Orbital Mastery';
+ } else if (baseLevel === 7) {
+ subtitleText += ' - Fugitives & Lasso';
+ } else if (baseLevel === 8) {
+ subtitleText += ' - Phantom Echoes';
+ } else if (baseLevel === 9) {
+ subtitleText += ' - Chromatic Chaos';
+ }
+ var subtitle = new Text2(subtitleText, {
+ size: 60,
+ fill: difficultyTier >= 2 ? 0xFF4444 : 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = 80;
+ subtitle.alpha = 0;
+ transitionContainer.addChild(subtitle);
+ // Add difficulty warning for high tiers
+ if (difficultyTier >= 2) {
+ var warning = new Text2('EXTREME DIFFICULTY!', {
+ size: 50,
+ fill: 0xFF0000
+ });
+ warning.anchor.set(0.5, 0.5);
+ warning.y = 140;
+ warning.alpha = 0;
+ transitionContainer.addChild(warning);
+ tween(warning, {
+ alpha: 1,
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 400,
+ delay: 600,
+ easing: tween.easeOut,
+ yoyo: true,
+ repeat: 2
+ });
+ }
+ // Fade in subtitle
+ tween(subtitle, {
+ alpha: 1,
+ y: 60
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Wait then fade everything out
+ LK.setTimeout(function () {
+ tween(transitionContainer, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 1500);
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+ }, 800);
+ }
+ });
+ }
+ });
+ // Create celebration effects
+ for (var i = 0; i < 30; i++) {
+ LK.setTimeout(function () {
+ var angle = Math.random() * Math.PI * 2;
+ var distance = 200 + Math.random() * 300;
+ var x = 1024 + Math.cos(angle) * distance;
+ var y = 1366 + Math.sin(angle) * distance;
+ createExplosion(x, y, 0xFFD700);
+ }, i * 30);
+ }
+ // Screen shake for impact
+ screenShake(10, 300);
+}
+// Function to spawn floating background elements
+function spawnFloatingElement() {
+ if (floatingElements.length < 8) {
+ var element = new FloatingElement();
+ var type = Math.random() < 0.7 ? 'cloud' : 'star';
+ element.init(type, 2148, Math.random() * 1500 + 100);
+ floatingElements.push(element);
+ game.addChild(element);
+ }
+}
+// Track mouse position
+game.move = function (x, y, obj) {
+ mouseX = x;
+ mouseY = y;
+};
+// Enhanced update function with dynamic effects
+game.update = function () {
+ // Update game time
+ gameTime++;
+ if (!isTransitioning) {
+ // Calculate remaining time
+ var elapsedTime = Math.floor((gameTime - levelStartTime) / 60);
+ var remainingTime = Math.max(0, levelTimeLimit - elapsedTime);
+ // Update screen shake
+ updateScreenShake();
+ // Spawn balls periodically based on level
+ ballSpawnTimer++;
+ var baseLevel = (currentLevel - 1) % 9 + 1;
+ var difficultyTier = Math.floor((currentLevel - 1) / 9);
+ var spawnRate = Math.max(20, 120 - baseLevel * 15 - difficultyTier * 10);
+ var maxBalls = 15 + baseLevel * 3 + difficultyTier * 5;
+ if (ballSpawnTimer >= spawnRate && balls.length < maxBalls) {
+ spawnBall();
+ ballSpawnTimer = 0;
+ }
+ // Spawn floating elements periodically
+ if (gameTime % 300 === 0) {
+ spawnFloatingElement();
+ }
+ // Update score display with time warning
+ var currentRequirement = getLevelRequirement(currentLevel);
+ var displayText = 'Level ' + currentLevel + ' | Score: ' + LK.getScore() + '/' + currentRequirement + ' | Time: ' + remainingTime;
+ scoreText.setText(displayText);
+ scoreTextShadow.setText(displayText);
+ // Time warning effect
+ if (remainingTime <= 10 && remainingTime > 0) {
+ scoreText.tint = 0xFF4444;
+ scoreTextShadow.tint = 0x660000;
+ // Pulse effect
+ if (gameTime % 30 === 0) {
+ tween(scoreText, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ yoyo: true
+ });
+ }
+ } else {
+ scoreText.tint = 0xFFFFFF;
+ scoreTextShadow.tint = 0x000000;
+ }
+ // Update progress tracking
+ var progress = LK.getScore() / levelRequirements[currentLevel - 1];
+ lastProgressValue = progress;
+ // Level 7: Spawn shepherd balls occasionally
+ if (currentLevel === 7 && gameTime % 300 === 0) {
+ var shepherd = new ShepherdBall();
+ shepherd.init();
+ shepherdBalls.push(shepherd);
+ game.addChild(shepherd);
+ }
+ // Level 9: Update color target
+ if (currentLevel === 9) {
+ colorTargetTimer++;
+ if (colorTargetTimer >= 600) {
+ // Change target every 10 seconds
+ colorTargetTimer = 0;
+ targetColorIndex = (targetColorIndex + 1) % 3;
+ var colors = [0xFFD700, 0xFF4444, 0x44FF44];
+ targetColor = colors[targetColorIndex];
+ // Update UI to show current target color
+ scoreText.tint = targetColor;
+ }
+ }
+ // Update shepherd balls
+ for (var i = shepherdBalls.length - 1; i >= 0; i--) {
+ var shepherd = shepherdBalls[i];
+ if (shepherd.collected || shepherd.lifespan <= 0) {
+ shepherdBalls.splice(i, 1);
+ }
+ }
+ // Check level completion
+ if (LK.getScore() >= getLevelRequirement(currentLevel)) {
+ showLevelTransition(currentLevel + 1);
+ }
+ // Check time limit
+ if (remainingTime <= 0) {
+ LK.showGameOver();
+ }
+ }
+};
+// Cinematic intro for Level 2 - Random Moving Balls
+function showLevel2Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create cinematic frame
+ var frameContainer = new Container();
+ frameContainer.scaleX = 0;
+ frameContainer.scaleY = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create outer frame border
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 12,
+ scaleY: 8,
+ tint: 0xFFD700
+ });
+ outerFrame.alpha = 0.3;
+ // Create inner frame
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 11,
+ scaleY: 7,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.9;
+ // Create demo container
+ var demoContainer = new Container();
+ demoContainer.y = 0;
+ frameContainer.addChild(demoContainer);
+ // Title
+ var title = new Text2('LEVEL 2', {
+ size: 180,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('Balls Move Randomly!', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -200;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create demo area background
+ var demoArea = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 9,
+ scaleY: 4,
+ tint: 0x1a1a1a
+ });
+ demoArea.y = 150;
+ demoArea.alpha = 0.5;
+ // Create demo balls
+ var demoBalls = [];
+ for (var i = 0; i < 4; i++) {
+ var ball = new Container();
+ // Add glow effect
+ var glow = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0xFFD700
+ });
+ glow.alpha = 0.3;
+ var ballGfx = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFD700
+ });
+ ball.x = -300 + i * 200;
+ ball.y = 150;
+ ball.vx = (Math.random() - 0.5) * 6;
+ ball.vy = (Math.random() - 0.5) * 6;
+ ball.scaleX = 0;
+ ball.scaleY = 0;
+ demoBalls.push(ball);
+ demoContainer.addChild(ball);
+ }
+ // Animate frame entrance
+ tween(frameContainer, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 600,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(frameContainer, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ // Animate intro
+ tween(title, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(subtitle, {
+ alpha: 1,
+ y: -200
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Animate demo balls
+ for (var i = 0; i < demoBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 300,
+ easing: tween.bounceOut,
+ onFinish: function onFinish() {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ }, delay);
+ })(demoBalls[i], i * 100);
+ }
+ // Animate ball movement
+ var moveTimer = LK.setInterval(function () {
+ for (var i = 0; i < demoBalls.length; i++) {
+ var ball = demoBalls[i];
+ ball.x += ball.vx;
+ ball.y += ball.vy;
+ // Bounce off walls
+ if (ball.x < -400 || ball.x > 400) {
+ ball.vx = -ball.vx;
+ }
+ if (ball.y < 0 || ball.y > 300) {
+ ball.vy = -ball.vy;
+ }
+ }
+ }, 16);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(moveTimer);
+ tween(frameContainer, {
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5,
+ rotation: 0.1
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 3500);
+ }
+ });
+}
+// Cinematic intro for Level 3 - Falling Balls
+function showLevel3Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create cinematic frame with vertical emphasis
+ var frameContainer = new Container();
+ frameContainer.scaleX = 0;
+ frameContainer.scaleY = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create outer frame border - taller for falling effect
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 10,
+ scaleY: 12,
+ tint: 0x4444FF
+ });
+ outerFrame.alpha = 0.3;
+ // Create inner frame
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 9,
+ scaleY: 11,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.9;
+ // Add decorative elements
+ for (var i = 0; i < 4; i++) {
+ var deco = frameContainer.attachAsset('smallPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2,
+ tint: 0xFFD700
+ });
+ deco.x = -400 + i * 267;
+ deco.y = -550;
+ deco.alpha = 0.6;
+ }
+ // Create demo container
+ var demoContainer = new Container();
+ demoContainer.y = 0;
+ frameContainer.addChild(demoContainer);
+ // Title
+ var title = new Text2('LEVEL 3', {
+ size: 180,
+ fill: 0x4444FF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -450;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('Balls Fall From Above!', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -350;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create falling area indicators
+ var leftLine = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 8,
+ tint: 0x4444FF
+ });
+ leftLine.x = -380;
+ leftLine.y = 0;
+ leftLine.alpha = 0.3;
+ var rightLine = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 8,
+ tint: 0x4444FF
+ });
+ rightLine.x = 380;
+ rightLine.y = 0;
+ rightLine.alpha = 0.3;
+ // Create falling demo balls
+ var fallingBalls = [];
+ // Animate frame entrance - drop from above
+ frameContainer.y = -800;
+ frameContainer.scaleX = 1;
+ frameContainer.scaleY = 1;
+ tween(frameContainer, {
+ y: 0
+ }, {
+ duration: 800,
+ easing: tween.bounceOut
+ });
+ // Animate intro
+ LK.setTimeout(function () {
+ tween(title, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(subtitle, {
+ alpha: 1,
+ y: -350
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Create falling balls animation
+ var ballSpawnTimer = LK.setInterval(function () {
+ var ball = new Container();
+ // Add trail effect
+ var trail = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 2,
+ tint: 0x4444FF
+ });
+ trail.alpha = 0.2;
+ var ballGfx = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFD700
+ });
+ ball.x = -350 + Math.random() * 700;
+ ball.y = -500;
+ ball.rotation = Math.random() * Math.PI * 2;
+ ball.scaleX = 0.5 + Math.random() * 0.5;
+ ball.scaleY = ball.scaleX;
+ fallingBalls.push(ball);
+ demoContainer.addChild(ball);
+ // Falling animation with acceleration
+ tween(ball, {
+ y: 500,
+ rotation: ball.rotation + Math.PI * 4,
+ scaleX: ball.scaleX * 1.5,
+ scaleY: ball.scaleY * 1.5
+ }, {
+ duration: 2000,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ // Create splash effect
+ var splash = demoContainer.addChild(new Container());
+ splash.x = ball.x;
+ splash.y = 480;
+ var splashGfx = splash.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ tint: 0xFFD700
+ });
+ tween(splashGfx, {
+ scaleX: 3,
+ scaleY: 3,
+ alpha: 0
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ splash.destroy();
+ }
+ });
+ ball.destroy();
+ }
+ });
+ }, 200);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(ballSpawnTimer);
+ tween(frameContainer, {
+ alpha: 0,
+ y: 800
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 3500);
+ }
+ });
+ }, 800);
+}
+// Cinematic intro for Level 4 - Fleeing Balls
+function showLevel4Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create cinematic frame with action-movie style
+ var frameContainer = new Container();
+ frameContainer.alpha = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create dynamic frame border
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: 0xFF4444
+ });
+ outerFrame.alpha = 0.4;
+ // Create inner frame with gradient effect
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 13,
+ scaleY: 9,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.95;
+ // Add action lines
+ for (var i = 0; i < 6; i++) {
+ var line = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0,
+ anchorY: 0.5,
+ scaleX: 8,
+ scaleY: 0.05,
+ tint: 0xFF4444
+ });
+ line.x = -650;
+ line.y = -400 + i * 160;
+ line.alpha = 0.2;
+ line.rotation = -0.1 + Math.random() * 0.2;
+ }
+ // Create demo container
+ var demoContainer = new Container();
+ demoContainer.y = 0;
+ frameContainer.addChild(demoContainer);
+ // Title with dramatic effect
+ var titleGlow = new Text2('LEVEL 4', {
+ size: 200,
+ fill: 0xFF4444,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ titleGlow.anchor.set(0.5, 0.5);
+ titleGlow.y = -400;
+ titleGlow.alpha = 0.3;
+ demoContainer.addChild(titleGlow);
+ var title = new Text2('LEVEL 4', {
+ size: 180,
+ fill: 0xFFFFFF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -400;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('Balls Run Away!', {
+ size: 80,
+ fill: 0xFFD700
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -280;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create demo arena
+ var arena = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 10,
+ scaleY: 5,
+ tint: 0x1a1a1a
+ });
+ arena.y = 150;
+ arena.alpha = 0.3;
+ // Create fleeing demo with multiple balls
+ var fleeingBalls = [];
+ for (var i = 0; i < 3; i++) {
+ var fleeingBall = new Container();
+ // Add fear effect
+ var fearAura = fleeingBall.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0xFF4444
+ });
+ fearAura.alpha = 0.3;
+ var ballGfx = fleeingBall.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFD700
+ });
+ fleeingBall.x = -200 + i * 200;
+ fleeingBall.y = 150;
+ fleeingBall.scaleX = 0;
+ fleeingBall.scaleY = 0;
+ fleeingBalls.push(fleeingBall);
+ demoContainer.addChild(fleeingBall);
+ }
+ // Create cursor with predator effect
+ var cursor = new Container();
+ var cursorAura = cursor.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2,
+ tint: 0xFF0000
+ });
+ cursorAura.alpha = 0.2;
+ var cursorGfx = cursor.attachAsset('smallTarget', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFFFFF
+ });
+ cursor.x = -400;
+ cursor.y = 150;
+ cursor.alpha = 0;
+ cursor.scaleX = 1.5;
+ cursor.scaleY = 1.5;
+ demoContainer.addChild(cursor);
+ // Animate frame entrance with flash
+ tween(frameContainer, {
+ alpha: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ // Screen flash effect
+ var flash = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 15,
+ scaleY: 11,
+ tint: 0xFFFFFF
+ });
+ flash.alpha = 0.8;
+ tween(flash, {
+ alpha: 0
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ flash.destroy();
+ }
+ });
+ // Animate intro
+ tween(title, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(subtitle, {
+ alpha: 1,
+ y: -280
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Show balls with stagger
+ for (var i = 0; i < fleeingBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ }, delay);
+ })(fleeingBalls[i], i * 150);
+ }
+ // Show cursor
+ LK.setTimeout(function () {
+ tween(cursor, {
+ alpha: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ // Animate chase sequence
+ tween(cursor, {
+ x: 0,
+ y: 150
+ }, {
+ duration: 800,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ // All balls flee in different directions
+ for (var i = 0; i < fleeingBalls.length; i++) {
+ (function (ball, index) {
+ var angle = index / fleeingBalls.length * Math.PI * 2;
+ var fleeX = Math.cos(angle) * 300;
+ var fleeY = 150 + Math.sin(angle) * 200;
+ tween(ball, {
+ x: fleeX,
+ y: fleeY,
+ rotation: Math.random() * Math.PI
+ }, {
+ duration: 600,
+ easing: tween.easeOut
+ });
+ })(fleeingBalls[i], i);
+ }
+ // Cursor spins confused
+ tween(cursor, {
+ rotation: Math.PI * 2
+ }, {
+ duration: 800,
+ easing: tween.easeInOut
+ });
+ }
+ });
+ }
+ });
+ }, 600);
+ // Transition out
+ LK.setTimeout(function () {
+ tween(frameContainer, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 4000);
+ }
+ });
+}
+// Cinematic intro for Level 5 - Roaming Balls
+function showLevel5Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create epic cinematic frame
+ var frameContainer = new Container();
+ frameContainer.rotation = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create multi-layered frame for chaos effect
+ var chaosFrame1 = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 16,
+ scaleY: 12,
+ tint: 0xFF0000
+ });
+ chaosFrame1.alpha = 0.2;
+ var chaosFrame2 = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 15,
+ scaleY: 11,
+ tint: 0xFFD700
+ });
+ chaosFrame2.alpha = 0.2;
+ chaosFrame2.rotation = 0.05;
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: 0xFF00FF
+ });
+ outerFrame.alpha = 0.4;
+ // Create inner frame
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 13,
+ scaleY: 9,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.95;
+ // Add chaos particles around frame
+ var chaosParticles = [];
+ for (var i = 0; i < 12; i++) {
+ var particle = frameContainer.attachAsset('smallPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 1,
+ tint: Math.random() < 0.5 ? 0xFF0000 : 0xFFD700
+ });
+ var angle = i / 12 * Math.PI * 2;
+ particle.x = Math.cos(angle) * 600;
+ particle.y = Math.sin(angle) * 450;
+ particle.alpha = 0.6;
+ chaosParticles.push(particle);
+ }
+ // Create demo container
+ var demoContainer = new Container();
+ demoContainer.y = 0;
+ frameContainer.addChild(demoContainer);
+ // Epic title with multiple layers
+ var titleBg = new Text2('LEVEL 5', {
+ size: 220,
+ fill: 0x000000,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ titleBg.anchor.set(0.5, 0.5);
+ titleBg.y = -350;
+ titleBg.x = 5;
+ titleBg.alpha = 0.5;
+ demoContainer.addChild(titleBg);
+ var titleGlow = new Text2('LEVEL 5', {
+ size: 200,
+ fill: 0xFF00FF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ titleGlow.anchor.set(0.5, 0.5);
+ titleGlow.y = -350;
+ titleGlow.alpha = 0.4;
+ demoContainer.addChild(titleGlow);
+ var title = new Text2('LEVEL 5', {
+ size: 180,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle with warning style
+ var subtitle = new Text2('CHAOS MODE!', {
+ size: 100,
+ fill: 0xFF0000
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -230;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create chaos arena
+ var arenaGlow = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 11,
+ scaleY: 7,
+ tint: 0xFF00FF
+ });
+ arenaGlow.y = 100;
+ arenaGlow.alpha = 0.1;
+ var arena = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 10,
+ scaleY: 6,
+ tint: 0x0a0a0a
+ });
+ arena.y = 100;
+ arena.alpha = 0.8;
+ // Create roaming balls with different sizes and colors
+ var roamingBalls = [];
+ for (var i = 0; i < 8; i++) {
+ var ball = new Container();
+ // Random ball type
+ var ballColor = i < 3 ? 0xFFD700 : i < 6 ? 0xFF0000 : 0x00FF00;
+ var ballSize = 0.8 + Math.random() * 0.6;
+ // Add trail effect
+ var trail = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: ballSize * 1.5,
+ scaleY: ballSize * 1.5,
+ tint: ballColor
+ });
+ trail.alpha = 0.2;
+ var ballGfx = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: ballSize,
+ scaleY: ballSize,
+ tint: ballColor
+ });
+ ball.x = -400 + Math.random() * 800;
+ ball.y = -200 + Math.random() * 400;
+ ball.vx = (Math.random() - 0.5) * 12;
+ ball.vy = (Math.random() - 0.5) * 12;
+ ball.scaleX = 0;
+ ball.scaleY = 0;
+ roamingBalls.push(ball);
+ demoContainer.addChild(ball);
+ }
+ // Animate frame entrance with rotation
+ frameContainer.scaleX = 0.1;
+ frameContainer.scaleY = 0.1;
+ frameContainer.rotation = Math.PI * 2;
+ tween(frameContainer, {
+ scaleX: 1,
+ scaleY: 1,
+ rotation: 0
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ // Animate chaos particles
+ for (var i = 0; i < chaosParticles.length; i++) {
+ (function (particle, index) {
+ tween(particle, {
+ x: particle.x * 0.8,
+ y: particle.y * 0.8,
+ rotation: Math.PI * 4
+ }, {
+ duration: 2000 + index * 100,
+ easing: tween.linear,
+ loop: true
+ });
+ })(chaosParticles[i], i);
+ }
+ // Animate intro
+ LK.setTimeout(function () {
+ // Title shake effect
+ var shakeTimer = LK.setInterval(function () {
+ title.x = -5 + Math.random() * 10;
+ title.y = -350 + (-5 + Math.random() * 10);
+ titleGlow.x = title.x;
+ titleGlow.y = title.y;
+ }, 50);
+ tween(title, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ LK.clearInterval(shakeTimer);
+ title.x = 0;
+ title.y = -350;
+ titleGlow.x = 0;
+ titleGlow.y = -350;
+ tween(subtitle, {
+ alpha: 1,
+ y: -230
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Flash effect
+ var flash = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 20,
+ scaleY: 15,
+ tint: 0xFFFFFF
+ });
+ flash.alpha = 0.6;
+ tween(flash, {
+ alpha: 0
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ flash.destroy();
+ }
+ });
+ // Spawn balls with explosion effect
+ for (var i = 0; i < roamingBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ }, delay);
+ })(roamingBalls[i], i * 50);
+ }
+ // Animate chaotic movement
+ var chaosTimer = LK.setInterval(function () {
+ for (var i = 0; i < roamingBalls.length; i++) {
+ var ball = roamingBalls[i];
+ ball.x += ball.vx;
+ ball.y += ball.vy;
+ ball.rotation += 0.2;
+ // Bounce off walls with effects
+ if (Math.abs(ball.x) > 450) {
+ ball.vx = -ball.vx * 1.2;
+ // Create bounce effect
+ var bounce = demoContainer.addChild(new Container());
+ bounce.x = ball.x > 0 ? 450 : -450;
+ bounce.y = ball.y;
+ var bounceGfx = bounce.attachAsset('smallPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFFFFF
+ });
+ tween(bounceGfx, {
+ scaleX: 3,
+ scaleY: 3,
+ alpha: 0
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ bounce.destroy();
+ }
+ });
+ }
+ if (Math.abs(ball.y) > 250) {
+ ball.vy = -ball.vy * 1.2;
+ }
+ // Random direction changes
+ if (Math.random() < 0.08) {
+ ball.vx = (Math.random() - 0.5) * 15;
+ ball.vy = (Math.random() - 0.5) * 15;
+ }
+ }
+ }, 16);
+ // Add warning text with flashing
+ LK.setTimeout(function () {
+ var warning = new Text2('MAXIMUM DIFFICULTY!', {
+ size: 70,
+ fill: 0xFF0000
+ });
+ warning.anchor.set(0.5, 0.5);
+ warning.y = 350;
+ warning.alpha = 0;
+ demoContainer.addChild(warning);
+ tween(warning, {
+ alpha: 1,
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ yoyo: true,
+ repeat: 4
+ });
+ }, 1500);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(chaosTimer);
+ // Epic exit
+ tween(frameContainer, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2,
+ rotation: -0.2
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 4500);
+ }
+ });
+ }, 800);
+}
+// Cinematic intro for Level 6 - Orbital Mastery
+function showLevel6Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create cosmic frame
+ var frameContainer = new Container();
+ frameContainer.alpha = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create orbital rings background
+ var orbitRings = [];
+ for (var i = 0; i < 3; i++) {
+ var ring = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 6 + i * 3,
+ scaleY: 6 + i * 3,
+ tint: 0x1a5d61
+ });
+ ring.alpha = 0.1 - i * 0.03;
+ orbitRings.push(ring);
+ }
+ // Create frame
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: 0x00FFFF
+ });
+ outerFrame.alpha = 0.4;
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 13,
+ scaleY: 9,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.95;
+ // Create demo container
+ var demoContainer = new Container();
+ frameContainer.addChild(demoContainer);
+ // Title
+ var title = new Text2('LEVEL 6', {
+ size: 180,
+ fill: 0x00FFFF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('ORBITAL MASTERY', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -250;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create orbital center
+ var centerOrb = demoContainer.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2,
+ tint: 0xFFD700
+ });
+ centerOrb.y = 100;
+ // Create orbiting demo balls
+ var orbitingBalls = [];
+ for (var i = 0; i < 6; i++) {
+ var ball = new Container();
+ var ballGfx = ball.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0x00FFFF
+ });
+ ball.angle = i / 6 * Math.PI * 2;
+ ball.radius = 200;
+ ball.speed = 0.02;
+ ball.scaleX = 0;
+ ball.scaleY = 0;
+ orbitingBalls.push(ball);
+ demoContainer.addChild(ball);
+ }
+ // Animate entrance
+ tween(frameContainer, {
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ // Rotate orbital rings
+ for (var i = 0; i < orbitRings.length; i++) {
+ (function (ring, index) {
+ tween(ring, {
+ rotation: Math.PI * 2
+ }, {
+ duration: 10000 + index * 2000,
+ easing: tween.linear,
+ loop: true
+ });
+ })(orbitRings[i], i);
+ }
+ // Animate title
+ tween(title, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(subtitle, {
+ alpha: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Show orbiting balls
+ for (var i = 0; i < orbitingBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ }, delay);
+ })(orbitingBalls[i], i * 100);
+ }
+ // Animate orbital motion
+ var orbitTimer = LK.setInterval(function () {
+ for (var i = 0; i < orbitingBalls.length; i++) {
+ var ball = orbitingBalls[i];
+ ball.angle += ball.speed;
+ ball.x = Math.cos(ball.angle) * ball.radius;
+ ball.y = 100 + Math.sin(ball.angle) * ball.radius;
+ }
+ }, 16);
+ // Create orbital paths
+ LK.setTimeout(function () {
+ for (var i = 0; i < 3; i++) {
+ var path = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4 + i * 1.5,
+ scaleY: 4 + i * 1.5,
+ tint: 0x00FFFF
+ });
+ path.y = 100;
+ path.alpha = 0;
+ tween(path, {
+ alpha: 0.2,
+ scaleX: path.scaleX * 1.2,
+ scaleY: path.scaleY * 1.2
+ }, {
+ duration: 800,
+ easing: tween.easeOut
+ });
+ }
+ }, 1000);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(orbitTimer);
+ tween(frameContainer, {
+ alpha: 0,
+ scaleX: 0.5,
+ scaleY: 0.5,
+ rotation: Math.PI / 4
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 4000);
+ }
+ });
+}
+// Cinematic intro for Level 7 - Fugitives & Lasso
+function showLevel7Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create western-themed frame
+ var frameContainer = new Container();
+ frameContainer.scaleX = 0;
+ frameContainer.scaleY = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create frame
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: 0x8B4513
+ });
+ outerFrame.alpha = 0.4;
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 13,
+ scaleY: 9,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.95;
+ // Create demo container
+ var demoContainer = new Container();
+ frameContainer.addChild(demoContainer);
+ // Title
+ var title = new Text2('LEVEL 7', {
+ size: 180,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('FUGITIVES & LASSO', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -250;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create fleeing balls
+ var fugitives = [];
+ for (var i = 0; i < 5; i++) {
+ var fugitive = new Container();
+ var ballGfx = fugitive.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFD700
+ });
+ fugitive.x = -300 + i * 150;
+ fugitive.y = 0;
+ fugitive.scaleX = 0;
+ fugitive.scaleY = 0;
+ fugitives.push(fugitive);
+ demoContainer.addChild(fugitive);
+ }
+ // Create shepherd ball (lasso)
+ var shepherdDemo = new Container();
+ var shepherdGlow = shepherdDemo.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 3,
+ scaleY: 3,
+ tint: 0x00FFFF
+ });
+ shepherdGlow.alpha = 0.3;
+ var shepherdCore = shepherdDemo.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0x00FFFF
+ });
+ shepherdDemo.y = 200;
+ shepherdDemo.scaleX = 0;
+ shepherdDemo.scaleY = 0;
+ demoContainer.addChild(shepherdDemo);
+ // Animate entrance
+ tween(frameContainer, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 600,
+ easing: tween.bounceOut
+ });
+ // Animate title
+ LK.setTimeout(function () {
+ tween(subtitle, {
+ alpha: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Show fugitives
+ for (var i = 0; i < fugitives.length; i++) {
+ (function (fugitive, delay) {
+ LK.setTimeout(function () {
+ tween(fugitive, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ }, delay);
+ })(fugitives[i], i * 100);
+ }
+ // Show shepherd ball
+ LK.setTimeout(function () {
+ tween(shepherdDemo, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 500,
+ easing: tween.bounceOut,
+ onFinish: function onFinish() {
+ tween(shepherdDemo, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ // Demonstrate lasso effect
+ LK.setTimeout(function () {
+ // Create lasso ring
+ var lassoRing = demoContainer.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ tint: 0x00FFFF
+ });
+ lassoRing.y = 200;
+ lassoRing.alpha = 0.8;
+ tween(lassoRing, {
+ scaleX: 6,
+ scaleY: 6,
+ alpha: 0.2
+ }, {
+ duration: 600,
+ easing: tween.easeOut
+ });
+ // Collect fugitives
+ for (var i = 0; i < fugitives.length; i++) {
+ (function (fugitive) {
+ tween(fugitive, {
+ x: 0,
+ y: 200,
+ scaleX: 0,
+ scaleY: 0,
+ rotation: Math.PI * 2
+ }, {
+ duration: 500,
+ easing: tween.easeIn
+ });
+ })(fugitives[i]);
+ }
+ // Show bonus text
+ var bonusText = new Text2('LASSO BONUS!', {
+ size: 100,
+ fill: 0x00FFFF,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ bonusText.anchor.set(0.5, 0.5);
+ bonusText.y = 350;
+ bonusText.alpha = 0;
+ demoContainer.addChild(bonusText);
+ tween(bonusText, {
+ alpha: 1,
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ yoyo: true
+ });
+ }, 1000);
+ }
+ });
+ }, 800);
+ // Transition out
+ LK.setTimeout(function () {
+ tween(frameContainer, {
+ alpha: 0,
+ x: -800
+ }, {
+ duration: 600,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 4500);
+ }, 500);
+}
+// Cinematic intro for Level 8 - Phantom Echoes
+function showLevel8Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create glitchy frame
+ var frameContainer = new Container();
+ frameContainer.alpha = 1;
+ transitionContainer.addChild(frameContainer);
+ // Create glitch layers
+ for (var i = 0; i < 3; i++) {
+ var glitchLayer = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: i === 0 ? 0xFF0000 : i === 1 ? 0x00FF00 : 0x0000FF
+ });
+ glitchLayer.alpha = 0.1;
+ glitchLayer.x = (Math.random() - 0.5) * 10;
+ glitchLayer.y = (Math.random() - 0.5) * 10;
+ }
+ // Main frame
+ var outerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14,
+ scaleY: 10,
+ tint: 0x800080
+ });
+ outerFrame.alpha = 0.4;
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 13,
+ scaleY: 9,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.95;
+ // Create demo container
+ var demoContainer = new Container();
+ frameContainer.addChild(demoContainer);
+ // Title with glitch effect
+ var title = new Text2('LEVEL 8', {
+ size: 180,
+ fill: 0x800080,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('PHANTOM ECHOES', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -250;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create phasing balls
+ var phantomBalls = [];
+ for (var i = 0; i < 4; i++) {
+ var phantom = new Container();
+ var ballGfx = phantom.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFFD700
+ });
+ phantom.x = -400 + i * 267;
+ phantom.y = 0;
+ phantom.scaleX = 1;
+ phantom.scaleY = 1;
+ phantom.alpha = 1;
+ phantomBalls.push(phantom);
+ demoContainer.addChild(phantom);
+ }
+ // Create negative/decoy balls
+ var negativeBalls = [];
+ for (var i = 0; i < 2; i++) {
+ var negative = new Container();
+ var negGfx = negative.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0xFF4444
+ });
+ var dangerAura = negative.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ tint: 0xFF0000
+ });
+ dangerAura.alpha = 0.3;
+ negative.x = -200 + i * 400;
+ negative.y = 200;
+ negative.scaleX = 0;
+ negative.scaleY = 0;
+ negativeBalls.push(negative);
+ demoContainer.addChild(negative);
+ }
+ // Glitch animation for title
+ var glitchTimer = LK.setInterval(function () {
+ if (Math.random() < 0.3) {
+ title.x = (Math.random() - 0.5) * 5;
+ title.y = -350 + (Math.random() - 0.5) * 5;
+ LK.setTimeout(function () {
+ title.x = 0;
+ title.y = -350;
+ }, 50);
+ }
+ }, 100);
+ // Animate subtitle
+ LK.setTimeout(function () {
+ tween(subtitle, {
+ alpha: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Phase animation for phantom balls
+ var phaseTimer = LK.setInterval(function () {
+ for (var i = 0; i < phantomBalls.length; i++) {
+ (function (ball, index) {
+ if (Math.random() < 0.5) {
+ tween(ball, {
+ alpha: ball.alpha > 0.5 ? 0.1 : 1
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ }
+ })(phantomBalls[i], i);
+ }
+ }, 800);
+ // Show negative balls
+ for (var i = 0; i < negativeBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ }, delay);
+ })(negativeBalls[i], 1000 + i * 200);
+ }
+ // Warning effect
+ LK.setTimeout(function () {
+ var warning = new Text2('AVOID RED BALLS!', {
+ size: 70,
+ fill: 0xFF0000,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ warning.anchor.set(0.5, 0.5);
+ warning.y = 350;
+ warning.alpha = 0;
+ demoContainer.addChild(warning);
+ tween(warning, {
+ alpha: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ yoyo: true,
+ repeat: 3
+ });
+ }, 2000);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(glitchTimer);
+ LK.clearInterval(phaseTimer);
+ // Glitch out effect
+ for (var i = 0; i < 5; i++) {
+ (function (delay) {
+ LK.setTimeout(function () {
+ frameContainer.x = (Math.random() - 0.5) * 20;
+ frameContainer.y = (Math.random() - 0.5) * 20;
+ frameContainer.alpha = Math.random();
+ }, delay);
+ })(i * 100);
+ }
+ LK.setTimeout(function () {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }, 600);
+ }, 4000);
+ }, 500);
+}
+// Cinematic intro for Level 9 - Chromatic Chaos
+function showLevel9Intro(nextLevel) {
+ // Clear transition container
+ transitionContainer.removeChildren();
+ transitionContainer.x = 1024;
+ transitionContainer.y = 1366;
+ transitionContainer.scaleX = 1;
+ transitionContainer.scaleY = 1;
+ transitionContainer.alpha = 1;
+ // Create rainbow frame
+ var frameContainer = new Container();
+ frameContainer.alpha = 0;
+ transitionContainer.addChild(frameContainer);
+ // Create rainbow background layers
+ var colors = [0xFF0000, 0xFF7F00, 0xFFFF00, 0x00FF00, 0x0000FF, 0x4B0082, 0x9400D3];
+ for (var i = 0; i < colors.length; i++) {
+ var colorLayer = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 14 - i * 0.5,
+ scaleY: 10 - i * 0.3,
+ tint: colors[i]
+ });
+ colorLayer.alpha = 0.1;
+ colorLayer.rotation = i * 0.05;
+ }
+ // Main frame
+ var innerFrame = frameContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 11,
+ scaleY: 8,
+ tint: 0x000000
+ });
+ innerFrame.alpha = 0.9;
+ // Create demo container
+ var demoContainer = new Container();
+ frameContainer.addChild(demoContainer);
+ // Title with rainbow effect
+ var title = new Text2('LEVEL 9', {
+ size: 180,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ title.anchor.set(0.5, 0.5);
+ title.y = -350;
+ demoContainer.addChild(title);
+ // Subtitle
+ var subtitle = new Text2('CHROMATIC CHAOS', {
+ size: 80,
+ fill: 0xFFFFFF
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.y = -250;
+ subtitle.alpha = 0;
+ demoContainer.addChild(subtitle);
+ // Create color target indicator
+ var targetIndicator = demoContainer.attachAsset('bigPixel', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 3,
+ scaleY: 1,
+ tint: 0xFFD700
+ });
+ targetIndicator.y = -150;
+ var targetText = new Text2('TARGET COLOR', {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ targetText.anchor.set(0.5, 0.5);
+ targetText.y = -150;
+ demoContainer.addChild(targetText);
+ // Create chameleon balls
+ var chameleonBalls = [];
+ var ballColors = [0xFFD700, 0xFF4444, 0x44FF44];
+ for (var i = 0; i < 6; i++) {
+ var chameleon = new Container();
+ var ballGfx = chameleon.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: ballColors[i % 3]
+ });
+ chameleon.x = -400 + i % 3 * 400;
+ chameleon.y = 50 + Math.floor(i / 3) * 150;
+ chameleon.colorIndex = i % 3;
+ chameleon.scaleX = 0;
+ chameleon.scaleY = 0;
+ chameleonBalls.push(chameleon);
+ demoContainer.addChild(chameleon);
+ }
+ // Animate entrance
+ tween(frameContainer, {
+ alpha: 1
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ // Rainbow animation for title
+ var titleColorIndex = 0;
+ var titleColorTimer = LK.setInterval(function () {
+ titleColorIndex = (titleColorIndex + 1) % colors.length;
+ tween(title, {
+ tint: colors[titleColorIndex]
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ }, 400);
+ // Animate elements
+ LK.setTimeout(function () {
+ tween(subtitle, {
+ alpha: 1
+ }, {
+ duration: 400,
+ easing: tween.easeOut
+ });
+ // Show chameleon balls
+ for (var i = 0; i < chameleonBalls.length; i++) {
+ (function (ball, delay) {
+ LK.setTimeout(function () {
+ tween(ball, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.bounceOut
+ });
+ }, delay);
+ })(chameleonBalls[i], i * 100);
+ }
+ // Demonstrate color changing
+ var colorChangeTimer = LK.setInterval(function () {
+ // Change target color
+ var targetColorIndex = Math.floor(Math.random() * 3);
+ tween(targetIndicator, {
+ tint: ballColors[targetColorIndex]
+ }, {
+ duration: 300,
+ easing: tween.easeInOut
+ });
+ // Flash matching balls
+ for (var i = 0; i < chameleonBalls.length; i++) {
+ var ball = chameleonBalls[i];
+ if (ball.colorIndex === targetColorIndex) {
+ tween(ball, {
+ scaleX: 1.3,
+ scaleY: 1.3
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ yoyo: true
+ });
+ }
+ }
+ // Change some ball colors randomly
+ for (var i = 0; i < chameleonBalls.length; i++) {
+ if (Math.random() < 0.3) {
+ var ball = chameleonBalls[i];
+ ball.colorIndex = Math.floor(Math.random() * 3);
+ tween(ball.children[0], {
+ tint: ballColors[ball.colorIndex]
+ }, {
+ duration: 500,
+ easing: tween.easeInOut
+ });
+ }
+ }
+ }, 1500);
+ // Warning text
+ LK.setTimeout(function () {
+ var warning = new Text2('MATCH THE COLOR!', {
+ size: 70,
+ fill: 0xFFD700,
+ font: "'GillSans-Bold',Impact,'Arial Black',Tahoma"
+ });
+ warning.anchor.set(0.5, 0.5);
+ warning.y = 350;
+ warning.alpha = 0;
+ demoContainer.addChild(warning);
+ tween(warning, {
+ alpha: 1,
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ yoyo: true,
+ repeat: 2
+ });
+ }, 2500);
+ // Transition out
+ LK.setTimeout(function () {
+ LK.clearInterval(titleColorTimer);
+ LK.clearInterval(colorChangeTimer);
+ // Epic exit with color explosion
+ for (var i = 0; i < 10; i++) {
+ (function (index) {
+ var explosion = frameContainer.attachAsset('target', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1,
+ tint: colors[index % colors.length]
+ });
+ explosion.x = (Math.random() - 0.5) * 800;
+ explosion.y = (Math.random() - 0.5) * 600;
+ tween(explosion, {
+ scaleX: 5,
+ scaleY: 5,
+ alpha: 0
+ }, {
+ duration: 800,
+ delay: index * 50,
+ easing: tween.easeOut
+ });
+ })(i);
+ }
+ tween(frameContainer, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 800,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ transitionContainer.visible = false;
+ transitionContainer.removeChildren();
+ startLevel(nextLevel);
+ }
+ });
+ }, 5000);
+ }, 500);
+}
+// Helper function to convert HSL to hex
+function hslToHex(h, s, l) {
+ l /= 100;
+ var a = s * Math.min(l, 1 - l) / 100;
+ var f = function f(n) {
+ var k = (n + h / 30) % 12;
+ var color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
+ return Math.round(255 * color).toString(16).padStart(2, '0');
+ };
+ return parseInt('0x' + f(0) + f(8) + f(4));
+}
\ No newline at end of file