User prompt
Zor kırılan blokları bu kırmızı yeşil mordan farklı bir renk yap
User prompt
Bölüm seçme sayfasını oyundan ayrı olsun
User prompt
Top hızını dokunmadan daha zorlayıcı 10 bölüm daha ekle
User prompt
Blok sayısını arttır her bölümde
User prompt
Daha zorlayıcı bölümler olsun
User prompt
Please fix the bug: 'TypeError: tween.add is not a function. (In 'tween.add(asset, { alpha: 1, scaleX: 1.25, scaleY: 1.25 }, 600, { yoyo: true, repeat: Infinity, ease: "sineInOut" })', 'tween.add' is undefined)' in or related to this line: 'tween.add(asset, {' Line Number: 125 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: tween.to is not a function. (In 'tween.to(asset, { alpha: 1, scaleX: 1.25, scaleY: 1.25 }, 600, { yoyo: true, repeat: Infinity, ease: "sineInOut" })', 'tween.to' is undefined)' in or related to this line: 'tween.to(asset, {' Line Number: 125
User prompt
Düşen özelliklerin görüntüsünü güzelleştir
User prompt
Topun açısını kenarlara çarptığında daha dik olacak şekilde ayarlamak gerekir. Böylece top sadece sağa-sola değil, yukarı-aşağı da daha fazla hareket eder. - Topun hızını artırmak veya sabit yüksek bir hızda tutmak gerekir. Böylece oyun daha akıcı ve eğlenceli olur
User prompt
Bloklar kırılınca farklı güçlendirmeler düşsün
User prompt
Zor kırılan bloklarda çizgi olsun
User prompt
Belli olsun zor kırılan bloklar farklı bir renkte olsun
User prompt
Bazı bloklar 2 yada 3 defada kırılsın
User prompt
Sürekli hzlanöasın sabit bir hız olsun
User prompt
Kenarlardan daha hızlı seksin
User prompt
Bölümleri zorlaştır
User prompt
Özellik çeşitllilğini arttırır ve lenarlardan birazda hızlı seksin
User prompt
Düşen özellikleri yakalayınca aktif etsin
User prompt
Bazı bloklar geliştirme özellikleri düşürsün
User prompt
Blokların renkleri farklı farklı olsun
User prompt
Bölümleri seçim sayfası olsun önce
User prompt
10 tane bölüm ekle farklı farklı desenler olsun bloklar hepsinde
User prompt
Farklı özellikler düşsün blok kırınca
User prompt
Tıpun hızını biraz düşür
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Ball Class var Ball = Container.expand(function () { var self = Container.call(this); var ball = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.radius = ball.width / 2; // Ball velocity self.vx = 0; self.vy = 0; self.update = function () { self.x += self.vx; self.y += self.vy; }; return self; }); // Block Class var Block = Container.expand(function () { var self = Container.call(this); // Pick a color for variety var colorId = 'block'; if (self.blockType === 2) colorId = 'block2'; if (self.blockType === 3) colorId = 'block3'; var block = self.attachAsset(colorId, { anchorX: 0.5, anchorY: 0.5 }); self.width = block.width; self.height = block.height; return self; }); // Platform (Paddle) Class var Platform = Container.expand(function () { var self = Container.call(this); var plat = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5 }); self.width = plat.width; self.height = plat.height; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x222222 }); /**** * Game Code ****/ // Block (third color for variety) // Block (second color for variety) // Block // Ball // Platform (paddle) // Game constants var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; var PLATFORM_Y = GAME_HEIGHT - 200; var BALL_START_Y = PLATFORM_Y - 80; var BALL_SPEED = 18; var BALL_MIN_ANGLE = Math.PI / 8; // ~22.5deg, to avoid too shallow var BALL_MAX_ANGLE = Math.PI - Math.PI / 8; var PLATFORM_SPEED = 60; // Not used, as platform is dragged directly var BLOCK_ROWS = 5; var BLOCK_COLS = 7; var BLOCK_MARGIN_X = 30; var BLOCK_MARGIN_Y = 30; var BLOCK_TOP_OFFSET = 350; var BLOCK_TYPES = [1, 2, 3]; // Game state var platform; var ball; var blocks = []; var score = 0; var lives = 3; var isBallLaunched = false; var dragPlatform = false; var lastTouchX = 0; var scoreTxt; var livesTxt; // Helper: Reset ball to platform function resetBall() { ball.x = platform.x; ball.y = BALL_START_Y; ball.vx = 0; ball.vy = 0; isBallLaunched = false; } // Helper: Launch ball function launchBall() { if (!isBallLaunched) { // Randomize initial angle between 45 and 135 degrees (upwards) var angle = Math.PI / 4 + Math.random() * (Math.PI / 2); ball.vx = BALL_SPEED * Math.cos(angle); ball.vy = -BALL_SPEED * Math.sin(angle); isBallLaunched = true; } } // Helper: Clamp value function clamp(val, min, max) { if (val < min) return min; if (val > max) return max; return val; } // Level patterns: 10 unique block layouts (1: block, 0: empty, 2/3: alt color) var LEVEL_PATTERNS = [ // Level 1: Full grid [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]], // Level 2: Checkerboard [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]], // Level 3: Pyramid [[0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]], // Level 4: Hollow rectangle [[2, 2, 2, 2, 2, 2, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 0, 0, 0, 0, 2], [2, 2, 2, 2, 2, 2, 2]], // Level 5: Diagonal [[3, 0, 0, 0, 0, 0, 3], [0, 3, 0, 0, 0, 3, 0], [0, 0, 3, 0, 3, 0, 0], [0, 0, 0, 3, 0, 0, 0], [0, 0, 3, 0, 3, 0, 0]], // Level 6: Two triangles [[1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 1, 1, 1], [1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1]], // Level 7: Alternating rows [[1, 2, 1, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1]], // Level 8: Center cross [[0, 0, 3, 3, 3, 0, 0], [0, 0, 3, 3, 3, 0, 0], [3, 3, 3, 3, 3, 3, 3], [0, 0, 3, 3, 3, 0, 0], [0, 0, 3, 3, 3, 0, 0]], // Level 9: Edges only [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]], // Level 10: Zigzag [[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]]; var currentLevel = 0; var MAX_LEVEL = LEVEL_PATTERNS.length; // Helper: Create blocks function createBlocks() { // Remove old blocks for (var i = 0; i < blocks.length; i++) { blocks[i].destroy(); } blocks = []; // Calculate block size and spacing var blockAsset = LK.getAsset('block', { anchorX: 0.5, anchorY: 0.5 }); var blockW = blockAsset.width; var blockH = blockAsset.height; var totalW = BLOCK_COLS * blockW + (BLOCK_COLS - 1) * BLOCK_MARGIN_X; var startX = (GAME_WIDTH - totalW) / 2 + blockW / 2; // Use pattern for current level var pattern = LEVEL_PATTERNS[currentLevel % LEVEL_PATTERNS.length]; for (var row = 0; row < BLOCK_ROWS; row++) { for (var col = 0; col < BLOCK_COLS; col++) { var type = pattern[row] && pattern[row][col] ? pattern[row][col] : 0; if (type === 0) continue; var b = new Block(); b.blockType = type; // Re-attach correct color b.removeChildren(); var colorId = 'block'; if (b.blockType === 2) colorId = 'block2'; if (b.blockType === 3) colorId = 'block3'; b.attachAsset(colorId, { anchorX: 0.5, anchorY: 0.5 }); b.x = startX + col * (blockW + BLOCK_MARGIN_X); b.y = BLOCK_TOP_OFFSET + row * (blockH + BLOCK_MARGIN_Y); game.addChild(b); blocks.push(b); } } } // Helper: Reset game state function resetGame() { score = 0; lives = 3; currentLevel = 0; LK.setScore(0); if (scoreTxt) scoreTxt.setText('0'); if (livesTxt) livesTxt.setText('♥♥♥'); createBlocks(); resetBall(); } // Helper: Update lives display function updateLives() { var s = ''; for (var i = 0; i < lives; i++) s += '♥'; livesTxt.setText(s); } // Helper: Ball-Block collision function ballBlockCollision(ball, block) { // AABB collision var dx = Math.abs(ball.x - block.x); var dy = Math.abs(ball.y - block.y); var bw = block.width / 2; var bh = block.height / 2; var br = ball.radius; if (dx > bw + br) return false; if (dy > bh + br) return false; // Find overlap var overlapX = bw + br - dx; var overlapY = bh + br - dy; if (overlapX > 0 && overlapY > 0) { // Determine collision side: reflect ball accordingly if (overlapX < overlapY) { ball.vx = -ball.vx; } else { ball.vy = -ball.vy; } return true; } return false; } // Helper: Ball-Platform collision function ballPlatformCollision(ball, platform) { // AABB collision var dx = Math.abs(ball.x - platform.x); var dy = Math.abs(ball.y - platform.y); var pw = platform.width / 2; var ph = platform.height / 2; var br = ball.radius; if (dx > pw + br) return false; if (dy > ph + br) return false; // Only reflect if ball is moving down if (ball.vy > 0) { // Calculate hit position (-1 left, 0 center, 1 right) var hit = (ball.x - platform.x) / pw; // Clamp hit hit = clamp(hit, -1, 1); // Reflect angle: 150deg (left) to 30deg (right) var angle = Math.PI - Math.PI / 3 * (hit + 1) / 2; // 150 to 30 deg ball.vx = BALL_SPEED * Math.cos(angle); ball.vy = -BALL_SPEED * Math.sin(angle); } return true; } // Helper: Ball-Wall collision function ballWallCollision(ball) { // Left wall if (ball.x - ball.radius < 0) { ball.x = ball.radius; ball.vx = -ball.vx; } // Right wall if (ball.x + ball.radius > GAME_WIDTH) { ball.x = GAME_WIDTH - ball.radius; ball.vx = -ball.vx; } // Top wall if (ball.y - ball.radius < 0) { ball.y = ball.radius; ball.vy = -ball.vy; } } // Helper: Ball out of bounds function ballOutOfBounds(ball) { return ball.y - ball.radius > GAME_HEIGHT; } // GUI: Score scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // GUI: Lives livesTxt = new Text2('♥♥♥', { size: 100, fill: 0xE74C3C }); livesTxt.anchor.set(1, 0); LK.gui.topRight.addChild(livesTxt); // Create platform platform = new Platform(); platform.x = GAME_WIDTH / 2; platform.y = PLATFORM_Y; game.addChild(platform); // Create ball ball = new Ball(); resetBall(); game.addChild(ball); // Create blocks createBlocks(); // Input: Drag platform game.down = function (x, y, obj) { // Only allow drag if touch is near platform if (Math.abs(y - platform.y) < 200) { dragPlatform = true; lastTouchX = x; // If ball not launched, move ball with platform if (!isBallLaunched) { ball.x = platform.x; } } }; game.move = function (x, y, obj) { if (dragPlatform) { // Move platform horizontally, clamp to screen platform.x = clamp(x, platform.width / 2, GAME_WIDTH - platform.width / 2); // If ball not launched, move ball with platform if (!isBallLaunched) { ball.x = platform.x; } } }; game.up = function (x, y, obj) { if (dragPlatform) { // On release, if ball not launched, launch it if (!isBallLaunched) { launchBall(); } dragPlatform = false; } }; // Main game loop game.update = function () { // Ball movement if (isBallLaunched) { ball.update(); ballWallCollision(ball); // Platform collision ballPlatformCollision(ball, platform); // Block collisions for (var i = blocks.length - 1; i >= 0; i--) { if (ballBlockCollision(ball, blocks[i])) { blocks[i].destroy(); blocks.splice(i, 1); score += 10; LK.setScore(score); scoreTxt.setText(score); break; // Only one block per frame } } // Win condition: all blocks destroyed if (blocks.length === 0) { currentLevel++; if (currentLevel >= MAX_LEVEL) { LK.showYouWin(); return; } else { createBlocks(); resetBall(); return; } } // Ball out of bounds if (ballOutOfBounds(ball)) { lives--; updateLives(); if (lives <= 0) { LK.showGameOver(); return; } resetBall(); } } }; // Reset game on start resetGame();
===================================================================
--- original.js
+++ change.js
@@ -114,8 +114,32 @@
if (val < min) return min;
if (val > max) return max;
return val;
}
+// Level patterns: 10 unique block layouts (1: block, 0: empty, 2/3: alt color)
+var LEVEL_PATTERNS = [
+// Level 1: Full grid
+[[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],
+// Level 2: Checkerboard
+[[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],
+// Level 3: Pyramid
+[[0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]],
+// Level 4: Hollow rectangle
+[[2, 2, 2, 2, 2, 2, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 0, 0, 0, 0, 2], [2, 0, 0, 0, 0, 0, 2], [2, 2, 2, 2, 2, 2, 2]],
+// Level 5: Diagonal
+[[3, 0, 0, 0, 0, 0, 3], [0, 3, 0, 0, 0, 3, 0], [0, 0, 3, 0, 3, 0, 0], [0, 0, 0, 3, 0, 0, 0], [0, 0, 3, 0, 3, 0, 0]],
+// Level 6: Two triangles
+[[1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 1, 1, 1], [1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1]],
+// Level 7: Alternating rows
+[[1, 2, 1, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1], [2, 1, 2, 1, 2, 1, 2], [1, 2, 1, 2, 1, 2, 1]],
+// Level 8: Center cross
+[[0, 0, 3, 3, 3, 0, 0], [0, 0, 3, 3, 3, 0, 0], [3, 3, 3, 3, 3, 3, 3], [0, 0, 3, 3, 3, 0, 0], [0, 0, 3, 3, 3, 0, 0]],
+// Level 9: Edges only
+[[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],
+// Level 10: Zigzag
+[[1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1]]];
+var currentLevel = 0;
+var MAX_LEVEL = LEVEL_PATTERNS.length;
// Helper: Create blocks
function createBlocks() {
// Remove old blocks
for (var i = 0; i < blocks.length; i++) {
@@ -130,12 +154,16 @@
var blockW = blockAsset.width;
var blockH = blockAsset.height;
var totalW = BLOCK_COLS * blockW + (BLOCK_COLS - 1) * BLOCK_MARGIN_X;
var startX = (GAME_WIDTH - totalW) / 2 + blockW / 2;
+ // Use pattern for current level
+ var pattern = LEVEL_PATTERNS[currentLevel % LEVEL_PATTERNS.length];
for (var row = 0; row < BLOCK_ROWS; row++) {
for (var col = 0; col < BLOCK_COLS; col++) {
+ var type = pattern[row] && pattern[row][col] ? pattern[row][col] : 0;
+ if (type === 0) continue;
var b = new Block();
- b.blockType = BLOCK_TYPES[(row + col) % BLOCK_TYPES.length];
+ b.blockType = type;
// Re-attach correct color
b.removeChildren();
var colorId = 'block';
if (b.blockType === 2) colorId = 'block2';
@@ -154,8 +182,9 @@
// Helper: Reset game state
function resetGame() {
score = 0;
lives = 3;
+ currentLevel = 0;
LK.setScore(0);
if (scoreTxt) scoreTxt.setText('0');
if (livesTxt) livesTxt.setText('♥♥♥');
createBlocks();
@@ -312,10 +341,17 @@
}
}
// Win condition: all blocks destroyed
if (blocks.length === 0) {
- LK.showYouWin();
- return;
+ currentLevel++;
+ if (currentLevel >= MAX_LEVEL) {
+ LK.showYouWin();
+ return;
+ } else {
+ createBlocks();
+ resetBall();
+ return;
+ }
}
// Ball out of bounds
if (ballOutOfBounds(ball)) {
lives--;