User prompt
Arka plan olarak assetlerle uzay teması oluştur
User prompt
İlk top cube temas ettikten sonra daha hızlı düşmeye başlasınlar
User prompt
When the ball touches the cube, it should turn into a new asset. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Yukarıdan düşen toplar gibi 2. Asset oluştur
User prompt
Şarkı ilk top yakalandıktan sonra başlasın
User prompt
Toplar çok daha hızlı düşmeli şarkıyla uyumlu olması gerekiyor ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Ball Catcher Symphony
Initial prompt
Yukarıdan toplar düşecek aşağıda bir kup topları yakalayabilirse oyun devam edecek. Arkada şarkı çalacak. Toplar yakalanamazsa şarkı biter oyun biter.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BackgroundStar = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('backgroundStar', { anchorX: 0.5, anchorY: 0.5 }); self.twinkleTimer = 0; self.twinkleSpeed = Math.random() * 60 + 30; // Random twinkling speed self.baseAlpha = 0.3 + Math.random() * 0.5; // Random base brightness self.update = function () { self.twinkleTimer++; // Create twinkling effect self.alpha = self.baseAlpha + Math.sin(self.twinkleTimer / self.twinkleSpeed) * 0.3; }; return self; }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 12; // Much faster initial speed self.lastY = undefined; self.update = function () { self.y += self.speed; }; return self; }); var Ball2 = Container.expand(function () { var self = Container.call(this); var ball2Graphics = self.attachAsset('Ball2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 14; // Slightly different speed than Ball self.lastY = undefined; self.update = function () { self.y += self.speed; }; return self; }); var Cube = Container.expand(function () { var self = Container.call(this); var cubeGraphics = self.attachAsset('cube', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var Nebula = Container.expand(function () { var self = Container.call(this); var nebulaGraphics = self.attachAsset('nebula', { anchorX: 0.5, anchorY: 0.5 }); self.pulseTimer = 0; self.pulseSpeed = 0.02; // Slow pulsing self.baseAlpha = 0.15; self.update = function () { self.pulseTimer += self.pulseSpeed; // Create pulsing effect self.alpha = self.baseAlpha + Math.sin(self.pulseTimer) * 0.1; }; return self; }); var Planet = Container.expand(function () { var self = Container.call(this); var planetGraphics = self.attachAsset('planet', { anchorX: 0.5, anchorY: 0.5 }); self.rotationSpeed = 0.005 + Math.random() * 0.01; // Slow rotation self.update = function () { self.rotation += self.rotationSpeed; }; return self; }); var Star = Container.expand(function () { var self = Container.call(this); var starGraphics = self.attachAsset('star', { anchorX: 0.5, anchorY: 0.5 }); self.lifeTime = 0; self.maxLifeTime = 30; // 0.5 seconds at 60fps self.update = function () { self.lifeTime++; // Fade out effect self.alpha = 1 - self.lifeTime / self.maxLifeTime; // Scale up effect var scale = 1 + self.lifeTime / self.maxLifeTime * 0.5; self.scaleX = scale; self.scaleY = scale; // Remove when lifetime exceeded if (self.lifeTime >= self.maxLifeTime) { self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x1a1a2e }); /**** * Game Code ****/ // Create space background elements var backgroundStars = []; var planets = []; var nebulas = []; // Create twinkling stars background for (var i = 0; i < 80; i++) { var bgStar = game.addChild(new BackgroundStar()); bgStar.x = Math.random() * 2048; bgStar.y = Math.random() * 2732; backgroundStars.push(bgStar); } // Create planets in background for (var p = 0; p < 3; p++) { var planet = game.addChild(new Planet()); planet.x = Math.random() * 2048; planet.y = Math.random() * 2732; planet.scaleX = 0.5 + Math.random() * 1.5; // Random size planet.scaleY = planet.scaleX; planet.alpha = 0.6; // Semi-transparent // Randomize planet colors var planetColors = [0x8B4513, 0xFF6347, 0x4169E1, 0x32CD32, 0xFFD700]; planet.tint = planetColors[Math.floor(Math.random() * planetColors.length)]; planets.push(planet); } // Create nebula clouds for (var n = 0; n < 2; n++) { var nebula = game.addChild(new Nebula()); nebula.x = Math.random() * 2048; nebula.y = Math.random() * 2732; nebula.scaleX = 1 + Math.random() * 2; // Random size nebula.scaleY = 0.5 + Math.random() * 1; // Randomize nebula colors var nebulaColors = [0x4B0082, 0x8A2BE2, 0x9400D3, 0x6A5ACD]; nebula.tint = nebulaColors[Math.floor(Math.random() * nebulaColors.length)]; nebulas.push(nebula); } var cube = game.addChild(new Cube()); cube.x = 2048 / 2; cube.y = 2732 - 200; var balls = []; var balls2 = []; var stars = []; var ballTypeCounter = 0; var ballSpawnTimer = 0; var ballSpawnInterval = 20; // Spawn ball every 20 frames (faster for music sync) var difficultyTimer = 0; var gameStarted = false; // Score display var scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Music will start when first ball is caught gameStarted = false; // Touch controls for cube movement var isDragging = false; game.down = function (x, y, obj) { isDragging = true; cube.x = x; }; game.move = function (x, y, obj) { if (isDragging) { cube.x = Math.max(75, Math.min(2048 - 75, x)); // Keep cube within screen bounds } }; game.up = function (x, y, obj) { isDragging = false; }; game.update = function () { // Spawn balls ballSpawnTimer++; if (ballSpawnTimer >= ballSpawnInterval) { ballTypeCounter++; if (ballTypeCounter % 2 === 0) { // Spawn Ball type var newBall = new Ball(); newBall.x = Math.random() * (2048 - 160) + 80; // Random x position within screen bounds newBall.y = -40; newBall.lastY = newBall.y; // Add subtle scale animation for musical sync feeling newBall.scaleX = 0.3; newBall.scaleY = 0.3; tween(newBall, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeOut }); balls.push(newBall); game.addChild(newBall); } else { // Spawn Ball2 type var newBall2 = new Ball2(); newBall2.x = Math.random() * (2048 - 160) + 80; // Random x position within screen bounds newBall2.y = -40; newBall2.lastY = newBall2.y; // Add subtle scale animation for musical sync feeling newBall2.scaleX = 0.3; newBall2.scaleY = 0.3; tween(newBall2, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeOut }); balls2.push(newBall2); game.addChild(newBall2); } ballSpawnTimer = 0; } // Update difficulty - increase ball speed and spawn rate over time difficultyTimer++; if (difficultyTimer % 600 === 0) { // Every 10 seconds ballSpawnInterval = Math.max(10, ballSpawnInterval - 2); // Spawn much faster, minimum 10 frames for (var i = 0; i < balls.length; i++) { balls[i].speed = Math.min(18, balls[i].speed + 0.5); // Increase speed more aggressively, higher maximum } for (var j = 0; j < balls2.length; j++) { balls2[j].speed = Math.min(18, balls2[j].speed + 0.5); // Increase speed for Ball2 as well } } // Check ball collisions and cleanup for (var i = balls.length - 1; i >= 0; i--) { var ball = balls[i]; // Check if ball was caught by cube if (ball.intersects(cube)) { // Start music on first ball catch if (!gameStarted) { LK.playMusic('backgroundMusic'); gameStarted = true; } // Ball caught - increase score LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Play catch sound LK.getSound('catch').play(); // Create star transformation effect at ball position var newStar = new Star(); newStar.x = ball.x; newStar.y = ball.y; stars.push(newStar); game.addChild(newStar); // Add tween effect to star creation tween(newStar, { scaleX: 1.5, scaleY: 1.5 }, { duration: 300, easing: tween.bounceOut }); // Remove ball ball.destroy(); balls.splice(i, 1); continue; } // Check if ball hit the ground (missed) if (ball.lastY < 2732 && ball.y >= 2732) { // Ball missed - stop music and end game LK.stopMusic(); LK.showGameOver(); return; } // Update last position for ground detection ball.lastY = ball.y; // Remove balls that are way off screen if (ball.y > 2800) { ball.destroy(); balls.splice(i, 1); } } // Check Ball2 collisions and cleanup for (var k = balls2.length - 1; k >= 0; k--) { var ball2 = balls2[k]; // Check if ball2 was caught by cube if (ball2.intersects(cube)) { // Start music on first ball catch if (!gameStarted) { LK.playMusic('backgroundMusic'); gameStarted = true; } // Ball2 caught - increase score LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Play catch sound LK.getSound('catch').play(); // Create star transformation effect at ball2 position var newStar = new Star(); newStar.x = ball2.x; newStar.y = ball2.y; stars.push(newStar); game.addChild(newStar); // Add tween effect to star creation tween(newStar, { scaleX: 1.5, scaleY: 1.5 }, { duration: 300, easing: tween.bounceOut }); // Remove ball2 ball2.destroy(); balls2.splice(k, 1); continue; } // Check if ball2 hit the ground (missed) if (ball2.lastY < 2732 && ball2.y >= 2732) { // Ball2 missed - stop music and end game LK.stopMusic(); LK.showGameOver(); return; } // Update last position for ground detection ball2.lastY = ball2.y; // Remove balls2 that are way off screen if (ball2.y > 2800) { ball2.destroy(); balls2.splice(k, 1); } } // Cleanup expired stars for (var s = stars.length - 1; s >= 0; s--) { var star = stars[s]; if (star.lifeTime >= star.maxLifeTime) { stars.splice(s, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,24 @@
/****
* Classes
****/
+var BackgroundStar = Container.expand(function () {
+ var self = Container.call(this);
+ var starGraphics = self.attachAsset('backgroundStar', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.twinkleTimer = 0;
+ self.twinkleSpeed = Math.random() * 60 + 30; // Random twinkling speed
+ self.baseAlpha = 0.3 + Math.random() * 0.5; // Random base brightness
+ self.update = function () {
+ self.twinkleTimer++;
+ // Create twinkling effect
+ self.alpha = self.baseAlpha + Math.sin(self.twinkleTimer / self.twinkleSpeed) * 0.3;
+ };
+ return self;
+});
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
@@ -39,8 +55,36 @@
anchorY: 0.5
});
return self;
});
+var Nebula = Container.expand(function () {
+ var self = Container.call(this);
+ var nebulaGraphics = self.attachAsset('nebula', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.pulseTimer = 0;
+ self.pulseSpeed = 0.02; // Slow pulsing
+ self.baseAlpha = 0.15;
+ self.update = function () {
+ self.pulseTimer += self.pulseSpeed;
+ // Create pulsing effect
+ self.alpha = self.baseAlpha + Math.sin(self.pulseTimer) * 0.1;
+ };
+ return self;
+});
+var Planet = Container.expand(function () {
+ var self = Container.call(this);
+ var planetGraphics = self.attachAsset('planet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.rotationSpeed = 0.005 + Math.random() * 0.01; // Slow rotation
+ self.update = function () {
+ self.rotation += self.rotationSpeed;
+ };
+ return self;
+});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
@@ -73,8 +117,44 @@
/****
* Game Code
****/
+// Create space background elements
+var backgroundStars = [];
+var planets = [];
+var nebulas = [];
+// Create twinkling stars background
+for (var i = 0; i < 80; i++) {
+ var bgStar = game.addChild(new BackgroundStar());
+ bgStar.x = Math.random() * 2048;
+ bgStar.y = Math.random() * 2732;
+ backgroundStars.push(bgStar);
+}
+// Create planets in background
+for (var p = 0; p < 3; p++) {
+ var planet = game.addChild(new Planet());
+ planet.x = Math.random() * 2048;
+ planet.y = Math.random() * 2732;
+ planet.scaleX = 0.5 + Math.random() * 1.5; // Random size
+ planet.scaleY = planet.scaleX;
+ planet.alpha = 0.6; // Semi-transparent
+ // Randomize planet colors
+ var planetColors = [0x8B4513, 0xFF6347, 0x4169E1, 0x32CD32, 0xFFD700];
+ planet.tint = planetColors[Math.floor(Math.random() * planetColors.length)];
+ planets.push(planet);
+}
+// Create nebula clouds
+for (var n = 0; n < 2; n++) {
+ var nebula = game.addChild(new Nebula());
+ nebula.x = Math.random() * 2048;
+ nebula.y = Math.random() * 2732;
+ nebula.scaleX = 1 + Math.random() * 2; // Random size
+ nebula.scaleY = 0.5 + Math.random() * 1;
+ // Randomize nebula colors
+ var nebulaColors = [0x4B0082, 0x8A2BE2, 0x9400D3, 0x6A5ACD];
+ nebula.tint = nebulaColors[Math.floor(Math.random() * nebulaColors.length)];
+ nebulas.push(nebula);
+}
var cube = game.addChild(new Cube());
cube.x = 2048 / 2;
cube.y = 2732 - 200;
var balls = [];
@@ -84,9 +164,8 @@
var ballSpawnTimer = 0;
var ballSpawnInterval = 20; // Spawn ball every 20 frames (faster for music sync)
var difficultyTimer = 0;
var gameStarted = false;
-var speedIncreased = false;
// Score display
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
@@ -116,12 +195,8 @@
ballTypeCounter++;
if (ballTypeCounter % 2 === 0) {
// Spawn Ball type
var newBall = new Ball();
- // Set higher speed if game has started
- if (speedIncreased) {
- newBall.speed = 20;
- }
newBall.x = Math.random() * (2048 - 160) + 80; // Random x position within screen bounds
newBall.y = -40;
newBall.lastY = newBall.y;
// Add subtle scale animation for musical sync feeling
@@ -138,12 +213,8 @@
game.addChild(newBall);
} else {
// Spawn Ball2 type
var newBall2 = new Ball2();
- // Set higher speed if game has started
- if (speedIncreased) {
- newBall2.speed = 22;
- }
newBall2.x = Math.random() * (2048 - 160) + 80; // Random x position within screen bounds
newBall2.y = -40;
newBall2.lastY = newBall2.y;
// Add subtle scale animation for musical sync feeling
@@ -182,19 +253,8 @@
if (!gameStarted) {
LK.playMusic('backgroundMusic');
gameStarted = true;
}
- // Increase all ball speeds after first catch
- if (!speedIncreased) {
- speedIncreased = true;
- // Increase speed of all existing balls
- for (var m = 0; m < balls.length; m++) {
- balls[m].speed = Math.min(25, balls[m].speed + 8);
- }
- for (var n = 0; n < balls2.length; n++) {
- balls2[n].speed = Math.min(25, balls2[n].speed + 8);
- }
- }
// Ball caught - increase score
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
// Play catch sound
@@ -242,19 +302,8 @@
if (!gameStarted) {
LK.playMusic('backgroundMusic');
gameStarted = true;
}
- // Increase all ball speeds after first catch
- if (!speedIncreased) {
- speedIncreased = true;
- // Increase speed of all existing balls
- for (var m = 0; m < balls.length; m++) {
- balls[m].speed = Math.min(25, balls[m].speed + 8);
- }
- for (var n = 0; n < balls2.length; n++) {
- balls2[n].speed = Math.min(25, balls2[n].speed + 8);
- }
- }
// Ball2 caught - increase score
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
// Play catch sound
Yuvarlak bir top içinde nota simgesi olucak. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Çift kollu elektro gitar. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Mavi renkli top. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
3 kollu şimşek. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat