/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Circle = Container.expand(function () {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 0.1
});
self.maxScale = 3.0;
self.isExploding = false;
self.startTime = LK.ticks;
self.baseSpeed = 0.02;
// Start the expanding animation
self.startExpanding = function () {
var speedMultiplier = 1 + LK.getScore() * 0.1;
var duration = Math.max(1000, 2000 - LK.getScore() * 50);
tween(circleGraphics, {
scaleX: self.maxScale,
scaleY: self.maxScale
}, {
duration: duration / speedMultiplier,
easing: tween.easeOut,
onFinish: function onFinish() {
if (!self.isExploding) {
self.explode();
}
}
});
};
self.explode = function () {
if (self.isExploding) return;
self.isExploding = true;
LK.getSound('explosion').play();
LK.effects.flashScreen(0xff0000, 300);
LK.showGameOver();
};
self.pop = function () {
if (self.isExploding) return;
self.isExploding = true;
tween.stop(circleGraphics);
LK.getSound('pop').play();
LK.setScore(LK.getScore() + 1);
// Scale down animation before removal
tween(circleGraphics, {
scaleX: 0,
scaleY: 0,
alpha: 0
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
var index = circles.indexOf(self);
if (index > -1) {
circles.splice(index, 1);
self.destroy();
}
}
});
};
self.down = function (x, y, obj) {
self.pop();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var circles = [];
var spawnTimer = 0;
var baseSpawnRate = 120; // frames between spawns
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Position score text away from top-left menu area
scoreTxt.y = 50;
function spawnCircle() {
var circle = new Circle();
// Random position with margins to keep circles fully visible
var margin = 100;
circle.x = margin + Math.random() * (2048 - 2 * margin);
circle.y = margin + Math.random() * (2732 - 2 * margin);
circles.push(circle);
game.addChild(circle);
circle.startExpanding();
}
game.update = function () {
// Update score display
scoreTxt.setText('Score: ' + LK.getScore());
// Spawn new circles with increasing frequency
var currentSpawnRate = Math.max(30, baseSpawnRate - LK.getScore() * 2);
spawnTimer++;
if (spawnTimer >= currentSpawnRate) {
spawnCircle();
spawnTimer = 0;
}
// Spawn initial circle if none exist
if (circles.length === 0 && LK.ticks > 60) {
spawnCircle();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,120 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Circle = Container.expand(function () {
+ var self = Container.call(this);
+ var circleGraphics = self.attachAsset('circle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.1,
+ scaleY: 0.1
+ });
+ self.maxScale = 3.0;
+ self.isExploding = false;
+ self.startTime = LK.ticks;
+ self.baseSpeed = 0.02;
+ // Start the expanding animation
+ self.startExpanding = function () {
+ var speedMultiplier = 1 + LK.getScore() * 0.1;
+ var duration = Math.max(1000, 2000 - LK.getScore() * 50);
+ tween(circleGraphics, {
+ scaleX: self.maxScale,
+ scaleY: self.maxScale
+ }, {
+ duration: duration / speedMultiplier,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ if (!self.isExploding) {
+ self.explode();
+ }
+ }
+ });
+ };
+ self.explode = function () {
+ if (self.isExploding) return;
+ self.isExploding = true;
+ LK.getSound('explosion').play();
+ LK.effects.flashScreen(0xff0000, 300);
+ LK.showGameOver();
+ };
+ self.pop = function () {
+ if (self.isExploding) return;
+ self.isExploding = true;
+ tween.stop(circleGraphics);
+ LK.getSound('pop').play();
+ LK.setScore(LK.getScore() + 1);
+ // Scale down animation before removal
+ tween(circleGraphics, {
+ scaleX: 0,
+ scaleY: 0,
+ alpha: 0
+ }, {
+ duration: 150,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ var index = circles.indexOf(self);
+ if (index > -1) {
+ circles.splice(index, 1);
+ self.destroy();
+ }
+ }
+ });
+ };
+ self.down = function (x, y, obj) {
+ self.pop();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+var circles = [];
+var spawnTimer = 0;
+var baseSpawnRate = 120; // frames between spawns
+// Create score display
+var scoreTxt = new Text2('Score: 0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Position score text away from top-left menu area
+scoreTxt.y = 50;
+function spawnCircle() {
+ var circle = new Circle();
+ // Random position with margins to keep circles fully visible
+ var margin = 100;
+ circle.x = margin + Math.random() * (2048 - 2 * margin);
+ circle.y = margin + Math.random() * (2732 - 2 * margin);
+ circles.push(circle);
+ game.addChild(circle);
+ circle.startExpanding();
+}
+game.update = function () {
+ // Update score display
+ scoreTxt.setText('Score: ' + LK.getScore());
+ // Spawn new circles with increasing frequency
+ var currentSpawnRate = Math.max(30, baseSpawnRate - LK.getScore() * 2);
+ spawnTimer++;
+ if (spawnTimer >= currentSpawnRate) {
+ spawnCircle();
+ spawnTimer = 0;
+ }
+ // Spawn initial circle if none exist
+ if (circles.length === 0 && LK.ticks > 60) {
+ spawnCircle();
+ }
+};
\ No newline at end of file