Code edit (1 edits merged)
Please save this source code
User prompt
In the top right corner of the screen it should say little orange “Glaud”.
User prompt
top her türlü geldiği yönde devam etsin
User prompt
ilk baştai top sekme mekaniğini getir
User prompt
ortaya çarpsa bile geldiği yönün yansıması şeklinde gşştsin
User prompt
top sekerken geldiği yönün yansıması yönünde yoluna devam etsin
User prompt
her yerdeki sekmede ekl esesi
User prompt
top her sektiğinde sekme sesi çalsın
User prompt
geldiği yönün yansımasına göre seksin
User prompt
top geldği yönün zıttı yönde seksin
User prompt
topun geliş yönüne göre panddle den seksin
User prompt
topun hızını arttır
User prompt
topun hızını arttır
User prompt
bu en son eklenen özelliği topun geliş yönününde etkisi olsun.
User prompt
paddle hangi tarafına daha yakınsa top o yöne doğru gitsin ortadaysa dirak yukarı gitsin
User prompt
her yeni levelde ekranda 3 saniye kalacak şekilde ortalayaral yelevel kaç olduğu yazsın
User prompt
ilk baştaki blok yapısını her oluşumda koru
User prompt
şimdide 15 pikcel sola kaydır
User prompt
şimdi tüm blokları aynı andan x ekseninde 35 blok sağ kaydır.
User prompt
en sağdaki son sırayı sil
User prompt
en sağdaki son sırayı sil
User prompt
bloklar yatay eksende bir biri üzerine binmesin bitişik olsun ama üst üste denk gelmesin
User prompt
bloklar üst üste geliyor şekli bozmadan bunu düzelt
User prompt
şimdi sol daki y bakarsak iki sutun kalacak şekilde diğer tüm blokları sağ dogru bloklar üst üste olma drumu gideseye kadar kaydır
User prompt
soldaki blokları 30 piksel daha sola kaydır
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Ball class to handle ball behavior var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.attachAsset('ball', { anchorX: 0.5, anchorY: 0.5 }); self.speedX = 5; self.speedY = 5; self.update = function () { if (ballOnPaddle) { // If the ball is on the paddle, update the ball's position to follow the paddle self.x = paddle.x; self.y = paddle.y - paddle.height / 2 - self.height / 2; } else { self.x += self.speedX; self.y += self.speedY; // Bounce off walls if (self.x <= 0 || self.x >= 2048) { self.speedX *= -1; } if (self.y <= 0) { self.speedY *= -1; } } }; }); // Block class to handle block behavior var Block = Container.expand(function (color) { var self = Container.call(this); var blockGraphics = self.attachAsset(color, { anchorX: 0.5, anchorY: 0.5, width: 200, height: 100 }); self["break"] = function () { // Logic for breaking the block self.destroy(); }; }); // Paddle class to handle paddle behavior var Paddle = Container.expand(function () { var self = Container.call(this); var paddleGraphics = self.attachAsset('paddle', { width: 400, height: 50, color: 0xFFFFFF, anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Paddle follows mouse or ball based on the value of paddleFollowsBall if (paddleFollowsBall && balls.length > 0) { self.x = balls[0].x; } else { self.x = game.mouseX; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize score text // Function to generate blocks function generateBlocks() { var colors = ['block1', 'block2', 'block3', 'block4', 'block5']; for (var i = 0; i < 5; i++) { for (var j = 0; j < 10; j++) { var block; var color = colors[(i + j) % colors.length]; block = game.addChild(new Block(color)); block.x = initialBlockPositions[i * 10 + j].x; block.y = initialBlockPositions[i * 10 + j].y; blocks.push(block); game.addChild(block); } } // Update the level text levelTxt.setText('Level: ' + level); // Reset the ball position balls[0].x = 1024; // Center horizontally balls[0].y = 1366; // Position at the center of the screen balls[0].speedX = 5; balls[0].speedY = 5; } var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Initialize level text var levelTxt = new Text2('Level: ' + level, { size: 50, fill: 0xFFFFFF }); levelTxt.anchor.set(1, 0); LK.gui.topRight.addChild(levelTxt); // Initialize game elements var balls = []; var blocks = []; var paddle = game.addChild(new Paddle()); paddle.y = 2500; // Position paddle near the bottom // Initialize level var level = 1; // Create initial ball var initialBall = new Ball(); initialBall.x = 1024; // Center horizontally initialBall.y = 1366; // Position at the center of the screen balls.push(initialBall); game.addChild(initialBall); // Add a boolean variable to track if the ball is on the paddle var ballOnPaddle = true; // Add a boolean variable to track if the paddle is following the ball var paddleFollowsBall = false; // Create blocks var colors = ['block1', 'block2', 'block3', 'block4', 'block5']; var initialBlockPositions = []; for (var i = 0; i < 5; i++) { for (var j = 0; j < 10; j++) { var block; var color = colors[(i + j) % colors.length]; block = game.addChild(new Block(color)); var blockPosition = { x: 140 + j * 200, y: 400 + i * 100 }; block.x = blockPosition.x; // Increase the horizontal gap between blocks block.y = blockPosition.y; // Decrease the vertical gap between blocks blocks.push(block); initialBlockPositions.push(blockPosition); game.addChild(block); } } // Game update loop game.update = function () { // Update paddle paddle.update(); // Update balls for (var i = balls.length - 1; i >= 0; i--) { var ball = balls[i]; ball.update(); // Check collision with paddle if (ball.intersects(paddle)) { ball.speedY *= -1; } // Check collision with blocks for (var j = blocks.length - 1; j >= 0; j--) { var block = blocks[j]; if (ball.intersects(block)) { block["break"](); ball.speedY *= -1; blocks.splice(j, 1); // Update score LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); } } // Remove ball if it goes below the paddle if (ball.y > 2732) { ball.destroy(); balls.splice(i, 1); } } // Check if all blocks are destroyed if (blocks.length === 0) { // Increment the level level++; // Generate new blocks generateBlocks(); } // Check for game over if (balls.length === 0) { LK.showGameOver(); } }; // Mouse move event to control paddle game.move = function (x, y, obj) { game.mouseX = x; }; game.down = function (x, y, obj) { var currentTime = Date.now(); if (game.lastClickTime && currentTime - game.lastClickTime < 1000) { game.clickCount = (game.clickCount || 0) + 1; } else { game.clickCount = 1; } game.lastClickTime = currentTime; if (game.clickCount === 2) { for (var i = blocks.length - 1; i >= 0; i--) { blocks[i]["break"](); blocks.splice(i, 1); } game.clickCount = 0; } // If the ball is on the paddle, launch the ball when the game is clicked if (ballOnPaddle) { ballOnPaddle = false; } // Toggle the value of paddleFollowsBall on click only if mouse position is on the paddle if (x >= paddle.x - paddle.width / 2 && x <= paddle.x + paddle.width / 2 && y >= paddle.y - paddle.height / 2 && y <= paddle.y + paddle.height / 2) { paddleFollowsBall = !paddleFollowsBall; } };
===================================================================
--- original.js
+++ change.js
@@ -82,10 +82,10 @@
for (var j = 0; j < 10; j++) {
var block;
var color = colors[(i + j) % colors.length];
block = game.addChild(new Block(color));
- block.x = 140 + j * 180; // Increase the horizontal gap between blocks
- block.y = 400 + i * 100; // Decrease the vertical gap between blocks
+ block.x = initialBlockPositions[i * 10 + j].x;
+ block.y = initialBlockPositions[i * 10 + j].y;
blocks.push(block);
game.addChild(block);
}
}
@@ -128,16 +128,22 @@
// Add a boolean variable to track if the paddle is following the ball
var paddleFollowsBall = false;
// Create blocks
var colors = ['block1', 'block2', 'block3', 'block4', 'block5'];
+var initialBlockPositions = [];
for (var i = 0; i < 5; i++) {
for (var j = 0; j < 10; j++) {
var block;
var color = colors[(i + j) % colors.length];
block = game.addChild(new Block(color));
- block.x = 140 + j * 200; // Increase the horizontal gap between blocks
- block.y = 400 + i * 100; // Decrease the vertical gap between blocks
+ var blockPosition = {
+ x: 140 + j * 200,
+ y: 400 + i * 100
+ };
+ block.x = blockPosition.x; // Increase the horizontal gap between blocks
+ block.y = blockPosition.y; // Decrease the vertical gap between blocks
blocks.push(block);
+ initialBlockPositions.push(blockPosition);
game.addChild(block);
}
}
// Game update loop