User prompt
add dollar sing for all puraches price
User prompt
can you make upgrade buttons bigger, same for the text inside of them and rearaagne them
User prompt
can you add an icon to the upgrades for each ball to know which oe it is
Code edit (1 edits merged)
Please save this source code
User prompt
on new level balls and upgrades shoudl not be reseted
Code edit (1 edits merged)
Please save this source code
User prompt
Can we increase the size of the buttons for the upgrades
User prompt
more
User prompt
size of buttons is not increasing.
User prompt
Increase the size of the upgrades button, the size of the asset of the button itself, and of course the spacign between them to fit correcly.
User prompt
all progress of game should be stored in local storage ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Progress is not being savesd in local sgtoras. Allshoudl be stored, level, upgrades, balls, evertyhig ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
save points, level, balls purchased, and upgrades purchased in local storage so you continue next level from where you last playerd ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
local storage is not working
User prompt
Please fix the bug: 'storage.load is not a function' in or related to this line: 'storage.load();' Line Number: 132 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
do not reste points, level, upgrades costs on game start
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'splashBallCost')' in or related to this line: 'var splashCostText = new Text2('$' + upgrades.splashBallCost.toString(), {' Line Number: 229
User prompt
make background marine blue
User prompt
add local storage to the game ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
remove hardcoding of points
User prompt
reset points, player should start with 0 points unless they have points in storage ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
create a home screen with the game title and a start game button
User prompt
can we make bricks bigger and adjust the grid accordingly. double their size
User prompt
now some pricks are out of the screen. adjust columns and rows to adapt to thenew size of each brick
User prompt
make numbers in brick bigge
===================================================================
--- original.js
+++ change.js
@@ -126,34 +126,29 @@
var levelConfig = {
1: {
totalBricks: 50,
hitpoints: 1,
- gridSize: 200,
- shape: 'rectangle'
+ gridSize: 200
},
2: {
- totalBricks: 80,
+ totalBricks: 100,
hitpoints: 2,
- gridSize: 180,
- shape: 'circle'
+ gridSize: 180
},
3: {
- totalBricks: 120,
+ totalBricks: 150,
hitpoints: 3,
- gridSize: 160,
- shape: 'diamond'
+ gridSize: 160
},
4: {
- totalBricks: 160,
+ totalBricks: 200,
hitpoints: 4,
- gridSize: 140,
- shape: 'pyramid'
+ gridSize: 140
},
5: {
- totalBricks: 200,
+ totalBricks: 250,
hitpoints: 5,
- gridSize: 120,
- shape: 'spiral'
+ gridSize: 120
}
};
var upgrades = {
normalSpeed: 1,
@@ -281,10 +276,10 @@
if (iconType) {
button.addChild(button.attachAsset(iconType, {
anchorX: 0.5,
anchorY: -0.5,
- scaleX: 0.5,
- scaleY: 0.5
+ scaleX: 0.7,
+ scaleY: 0.7
}));
}
button.down = function () {
var cost = baseCost * upgrades[upgradeKey];
@@ -347,9 +342,8 @@
}
var buffer = BALL_RADIUS * 2;
return x >= brickGridBounds.minX - buffer && x <= brickGridBounds.maxX + buffer && y >= brickGridBounds.minY - buffer && y <= brickGridBounds.maxY + buffer;
}
-// Modified createBricks function to support different level shapes
function createBricks() {
var config = levelConfig[level] || {};
var totalBricks = config.totalBricks || 50;
var hitpoints = config.hitpoints || 1;
@@ -357,189 +351,39 @@
var spacingX = 2;
var spacingY = 2;
var cols = 10;
var rows = Math.ceil(totalBricks / cols);
- brickGrid = {};
- bricks = [];
- // Different shapes based on level
- switch (level) {
- case 1:
- // Rectangle formation (original)
- createRectangleFormation(cols, rows, spacingX, spacingY, hitpoints);
- break;
- case 2:
- // Circle formation
- createCircleFormation(totalBricks, hitpoints);
- break;
- case 3:
- // Diamond formation
- createDiamondFormation(totalBricks, spacingX, spacingY, hitpoints);
- break;
- case 4:
- // Pyramid formation
- createPyramidFormation(totalBricks, spacingX, spacingY, hitpoints);
- break;
- case 5:
- // Spiral formation
- createSpiralFormation(totalBricks, spacingX, spacingY, hitpoints);
- break;
- default:
- // Fallback to rectangle if level is not defined
- createRectangleFormation(cols, rows, spacingX, spacingY, hitpoints);
- }
- // Calculate brick grid bounds for optimization
- calculateBrickGridBounds();
-}
-// Original rectangular formation
-function createRectangleFormation(cols, rows, spacingX, spacingY, hitpoints) {
var totalWidth = cols * BRICK_WIDTH + (cols - 1) * spacingX;
var totalHeight = rows * BRICK_HEIGHT + (rows - 1) * spacingY;
var startX = (GAME_WIDTH - totalWidth) / 2 + BRICK_WIDTH / 2;
var startY = (GAME_HEIGHT - totalHeight) / 3 + BRICK_HEIGHT / 2;
+ brickGrid = {};
+ bricks = [];
for (var i = 0; i < rows; i++) {
- for (var j = 0; j < cols; j++) {
+ for (var j = 0; j < cols && i * cols + j < totalBricks; j++) {
var brick = new Brick();
brick.x = startX + j * (BRICK_WIDTH + spacingX);
brick.y = startY + i * (BRICK_HEIGHT + spacingY);
brick.health = hitpoints;
brick.maxHealth = hitpoints;
brick.healthText.setText(brick.health.toString());
brick.updateTint();
- addBrickToGame(brick);
+ bricks.push(brick);
+ game.addChild(brick);
+ var gridX = Math.floor(brick.x / gridSize);
+ var gridY = Math.floor(brick.y / gridSize);
+ var gridKey = "".concat(gridX, ",").concat(gridY);
+ if (!brickGrid[gridKey]) {
+ brickGrid[gridKey] = [];
+ }
+ brickGrid[gridKey].push(brick);
}
}
-}
-// Circle formation
-function createCircleFormation(totalBricks, hitpoints) {
- var centerX = GAME_WIDTH / 2;
- var centerY = GAME_HEIGHT / 3;
- var radius = Math.min(GAME_WIDTH, GAME_HEIGHT) / 4;
- var angleStep = 2 * Math.PI / totalBricks;
- for (var i = 0; i < totalBricks; i++) {
- var angle = i * angleStep;
- var brick = new Brick();
- brick.x = centerX + Math.cos(angle) * radius;
- brick.y = centerY + Math.sin(angle) * radius;
- brick.health = hitpoints;
- brick.maxHealth = hitpoints;
- brick.healthText.setText(brick.health.toString());
- brick.updateTint();
- // Bonus: rotate bricks to follow the circle
- brick.rotation = angle + Math.PI / 2;
- addBrickToGame(brick);
- }
-}
-// Diamond formation
-function createDiamondFormation(totalBricks, spacingX, spacingY, hitpoints) {
- var centerX = GAME_WIDTH / 2;
- var centerY = GAME_HEIGHT / 3;
- var size = Math.floor(Math.sqrt(totalBricks));
- if (size % 2 === 0) {
- size++;
- } // Ensure odd number for symmetry
- var halfSize = Math.floor(size / 2);
- var brickCount = 0;
- for (var y = -halfSize; y <= halfSize; y++) {
- var rowWidth = size - Math.abs(y * 2);
- var startX = centerX - rowWidth * (BRICK_WIDTH + spacingX) / 2;
- for (var x = 0; x < rowWidth && brickCount < totalBricks; x++) {
- var brick = new Brick();
- brick.x = startX + x * (BRICK_WIDTH + spacingX);
- brick.y = centerY + y * (BRICK_HEIGHT + spacingY);
- brick.health = hitpoints;
- brick.maxHealth = hitpoints;
- brick.healthText.setText(brick.health.toString());
- brick.updateTint();
- addBrickToGame(brick);
- brickCount++;
- }
- }
-}
-// Pyramid formation
-function createPyramidFormation(totalBricks, spacingX, spacingY, hitpoints) {
- var baseWidth = Math.ceil(Math.sqrt(totalBricks * 2));
- var rows = baseWidth;
- var centerX = GAME_WIDTH / 2;
- var startY = GAME_HEIGHT / 5;
- var brickCount = 0;
- for (var row = 0; row < rows && brickCount < totalBricks; row++) {
- var rowBricks = baseWidth - row;
- var rowStartX = centerX - rowBricks * (BRICK_WIDTH + spacingX) / 2;
- for (var col = 0; col < rowBricks && brickCount < totalBricks; col++) {
- var brick = new Brick();
- brick.x = rowStartX + col * (BRICK_WIDTH + spacingX);
- brick.y = startY + row * (BRICK_HEIGHT + spacingY);
- brick.health = hitpoints + (rows - row - 1); // Higher health for lower bricks
- brick.maxHealth = brick.health;
- brick.healthText.setText(brick.health.toString());
- brick.updateTint();
- addBrickToGame(brick);
- brickCount++;
- }
- }
-}
-// Spiral formation
-function createSpiralFormation(totalBricks, spacingX, spacingY, hitpoints) {
- var centerX = GAME_WIDTH / 2;
- var centerY = GAME_HEIGHT / 3;
- var spacing = Math.max(BRICK_WIDTH + spacingX, BRICK_HEIGHT + spacingY);
- var a = spacing / (2 * Math.PI); // Spiral constant
- var brickCount = 0;
- for (var i = 0; i < totalBricks; i++) {
- var angle = 0.5 * i;
- var radius = a * angle;
- if (radius > Math.min(GAME_WIDTH, GAME_HEIGHT) / 2.5) {
- break; // Prevent spiral from getting too large
- }
- var brick = new Brick();
- brick.x = centerX + radius * Math.cos(angle);
- brick.y = centerY + radius * Math.sin(angle);
- // Make bricks harder the further they are in the spiral
- brick.health = hitpoints + Math.floor(i / 10);
- brick.maxHealth = brick.health;
- brick.healthText.setText(brick.health.toString());
- brick.updateTint();
- // Rotate bricks to follow the spiral
- brick.rotation = angle + Math.PI / 2;
- addBrickToGame(brick);
- brickCount++;
- }
-}
-// Helper function to add brick to game and grid
-function addBrickToGame(brick) {
- bricks.push(brick);
- game.addChild(brick);
- var gridSize = levelConfig[level] ? levelConfig[level].gridSize : 200;
- var gridX = Math.floor(brick.x / gridSize);
- var gridY = Math.floor(brick.y / gridSize);
- var gridKey = "".concat(gridX, ",").concat(gridY);
- if (!brickGrid[gridKey]) {
- brickGrid[gridKey] = [];
- }
- brickGrid[gridKey].push(brick);
-}
-// Calculate the bounds of the brick grid for optimization
-function calculateBrickGridBounds() {
- if (bricks.length === 0) {
- brickGridBounds = null;
- return;
- }
- var minX = Infinity,
- maxX = -Infinity,
- minY = Infinity,
- maxY = -Infinity;
- for (var i = 0; i < bricks.length; i++) {
- var brick = bricks[i];
- minX = Math.min(minX, brick.x - brick.width / 2);
- maxX = Math.max(maxX, brick.x + brick.width / 2);
- minY = Math.min(minY, brick.y - brick.height / 2);
- maxY = Math.max(maxY, brick.y + brick.height / 2);
- }
brickGridBounds = {
- minX: minX,
- maxX: maxX,
- minY: minY,
- maxY: maxY
+ minX: startX - BRICK_WIDTH / 2,
+ maxX: startX + totalWidth - BRICK_WIDTH / 2,
+ minY: startY - BRICK_HEIGHT / 2,
+ maxY: startY + totalHeight - BRICK_HEIGHT / 2
};
}
function createBall() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'normal';
@@ -571,19 +415,14 @@
balls.splice(i, 1);
}
}
if (bricks.length === 0) {
- for (var i = balls.length - 1; i >= 0; i--) {
- balls[i].destroy();
- balls.splice(i, 1);
- }
if (level === Object.keys(levelConfig).length) {
LK.showGameOver();
} else {
level += 1;
levelTxt.setText('Level: ' + level);
createBricks();
- createBall();
}
}
if (balls.length === 0 && score >= BALL_COST) {
score -= BALL_COST;