User prompt
add a main menu screen with the game title and a game start button. game should not start until game start is touched. main menu should cover the whole screen and the game should not be displayed.
Code edit (1 edits merged)
Please save this source code
User prompt
add local storage module ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
add a button to delete local storage ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
local storage button delete sholuld be next to the points ↪💡 Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Import of asset
User prompt
lets add somoe particle effect when a block is destroyed
User prompt
use a new asset for particle effect, not splash ball
Code edit (2 edits merged)
Please save this source code
User prompt
move points to 200 pixels to the right
User prompt
move level below points
User prompt
move level 100 pixels to the left
User prompt
sorry I meant to the right
User prompt
move points and level 200 pixles ot the right
User prompt
move points 50 pixels to the right
User prompt
normal ball should start unlocked
Code edit (1 edits merged)
Please save this source code
User prompt
upgrade buttons and text should be the same size as ball purchase buttons, and have the same space between each ther
User prompt
rename buyball50 to button
User prompt
increase the size parameter of the buttons for the upgrades to be the same as the buy balls ones
User prompt
create a new button for powerup buttons
User prompt
Powerup are using an asset for their background button. create a new asset to be used by all of them. should be powerupbutton
User prompt
powerups should use powerup asset
User prompt
upgrade buttons should have a little moroe space between them
===================================================================
--- original.js
+++ change.js
@@ -120,42 +120,80 @@
/****
* Game Code
****/
// Constants
-// Import the storage module
+function _toConsumableArray(r) {
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
+}
+function _nonIterableSpread() {
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
+}
+function _unsupportedIterableToArray(r, a) {
+ if (r) {
+ if ("string" == typeof r) {
+ return _arrayLikeToArray(r, a);
+ }
+ var t = {}.toString.call(r).slice(8, -1);
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
+ }
+}
+function _iterableToArray(r) {
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) {
+ return Array.from(r);
+ }
+}
+function _arrayWithoutHoles(r) {
+ if (Array.isArray(r)) {
+ return _arrayLikeToArray(r);
+ }
+}
+function _arrayLikeToArray(r, a) {
+ (null == a || a > r.length) && (a = r.length);
+ for (var e = 0, n = Array(a); e < a; e++) {
+ n[e] = r[e];
+ }
+ return n;
+}
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2632;
var BALL_RADIUS = 50;
var BRICK_WIDTH = 300;
-var BRICK_HEIGHT = 100;
+var BRICK_HEIGHT = 99; // Adjusted to match asset definition
var BALL_COST = 50;
var LEVEL_COLORS = [0xff00ff, 0x00ffcc, 0xccff00, 0xff6600, 0x66ffff, 0xff3366, 0xffcc00, 0x9966ff, 0x33cc33, 0xff0000];
// Game Variables
var levelConfig = {
1: {
- totalBricks: 50,
+ totalBricks: 30,
+ // Fewer bricks for mobile visibility
hitpoints: 1,
- gridSize: 400
+ gridSize: 400,
+ // Larger grid for simpler collision
+ pattern: 'grid' // Standard grid layout
},
2: {
- totalBricks: 100,
+ totalBricks: 50,
hitpoints: 2,
- gridSize: 360
+ gridSize: 360,
+ pattern: 'staggered' // Offset rows for a "zigzag" feel
},
3: {
- totalBricks: 150,
+ totalBricks: 70,
hitpoints: 3,
- gridSize: 320
+ gridSize: 320,
+ pattern: 'clustered' // Tighter clusters of bricks
},
4: {
- totalBricks: 200,
+ totalBricks: 90,
hitpoints: 4,
- gridSize: 280
+ gridSize: 280,
+ pattern: 'diagonal' // Diagonal line pattern
},
5: {
- totalBricks: 250,
+ totalBricks: 110,
hitpoints: 5,
- gridSize: 240
+ gridSize: 240,
+ pattern: 'sparse' // Spread out with gaps
}
};
var upgrades = {
normalSpeed: 1,
@@ -284,9 +322,8 @@
// Bottom: Upgrade Buttons
var bottomHud = new Container();
bottomHud.y = GAME_HEIGHT - 150;
game.addChild(bottomHud);
-// Upgrade Button Factory with Icons
function createUpgradeButton(labelPrefix, x, costKey, upgradeKey, baseCost, iconType) {
var button = LK.getAsset('BuyBall50', {
size: 80,
fill: 0xFFFFFF,
@@ -307,9 +344,8 @@
fill: 0xFFFFFF
});
labelText.anchor.set(0.5, -0.5);
button.addChild(labelText);
- // Add icon if specified
if (iconType) {
button.addChild(button.attachAsset(iconType, {
anchorX: 0.5,
anchorY: -0.5,
@@ -383,45 +419,98 @@
var config = levelConfig[level] || {};
var totalBricks = config.totalBricks || 50;
var hitpoints = config.hitpoints || 1;
var gridSize = config.gridSize || 200;
+ var pattern = config.pattern || 'grid';
var spacingX = 2;
var spacingY = 2;
+ brickGrid = {};
+ bricks = [];
var cols = Math.floor(GAME_WIDTH / (BRICK_WIDTH + spacingX));
var rows = Math.ceil(totalBricks / cols);
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 && 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();
- 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] = [];
+ var brickCount = 0;
+ if (pattern === 'grid') {
+ for (var i = 0; i < rows && brickCount < totalBricks; i++) {
+ for (var j = 0; j < cols && brickCount < totalBricks; j++) {
+ addBrick(startX + j * (BRICK_WIDTH + spacingX), startY + i * (BRICK_HEIGHT + spacingY), hitpoints, gridSize);
+ brickCount++;
}
- brickGrid[gridKey].push(brick);
}
+ } else if (pattern === 'staggered') {
+ for (var i = 0; i < rows && brickCount < totalBricks; i++) {
+ var offsetX = i % 2 === 0 ? 0 : BRICK_WIDTH / 2;
+ for (var j = 0; j < cols && brickCount < totalBricks; j++) {
+ addBrick(startX + offsetX + j * (BRICK_WIDTH + spacingX), startY + i * (BRICK_HEIGHT + spacingY), hitpoints, gridSize);
+ brickCount++;
+ }
+ }
+ } else if (pattern === 'clustered') {
+ var clusterCols = Math.floor(cols / 2);
+ var clusterRows = Math.floor(rows / 2);
+ var clusterStartX = GAME_WIDTH / 2 - clusterCols * BRICK_WIDTH / 2;
+ var clusterStartY = GAME_HEIGHT / 3 - clusterRows * BRICK_HEIGHT / 2;
+ for (var i = 0; i < clusterRows && brickCount < totalBricks; i++) {
+ for (var j = 0; j < clusterCols && brickCount < totalBricks; j++) {
+ addBrick(clusterStartX + j * (BRICK_WIDTH + spacingX), clusterStartY + i * (BRICK_HEIGHT + spacingY), hitpoints, gridSize);
+ brickCount++;
+ }
+ }
+ } else if (pattern === 'diagonal') {
+ var stepX = (GAME_WIDTH - BRICK_WIDTH) / (totalBricks - 1);
+ var stepY = GAME_HEIGHT / 3 / (totalBricks - 1);
+ for (var i = 0; i < totalBricks; i++) {
+ addBrick(startX + i * stepX, startY + i * stepY, hitpoints, gridSize);
+ brickCount++;
+ }
+ } else if (pattern === 'sparse') {
+ while (brickCount < totalBricks) {
+ var x = startX + Math.floor(Math.random() * cols) * (BRICK_WIDTH + spacingX);
+ var y = startY + Math.floor(Math.random() * rows) * (BRICK_HEIGHT + spacingY);
+ if (!bricks.some(function (b) {
+ return b.x === x && b.y === y;
+ })) {
+ addBrick(x, y, hitpoints, gridSize);
+ brickCount++;
+ }
+ }
}
brickGridBounds = {
- minX: startX - BRICK_WIDTH / 2,
- maxX: startX + totalWidth - BRICK_WIDTH / 2,
- minY: startY - BRICK_HEIGHT / 2,
- maxY: startY + totalHeight - BRICK_HEIGHT / 2
+ minX: Math.min.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ return b.x - BRICK_WIDTH / 2;
+ }))),
+ maxX: Math.max.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ return b.x + BRICK_WIDTH / 2;
+ }))),
+ minY: Math.min.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ return b.y - BRICK_HEIGHT / 2;
+ }))),
+ maxY: Math.max.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ return b.y + BRICK_HEIGHT / 2;
+ })))
};
}
+function addBrick(x, y, hitpoints, gridSize) {
+ var brick = new Brick();
+ brick.x = x;
+ brick.y = y;
+ brick.health = hitpoints;
+ brick.maxHealth = hitpoints;
+ brick.healthText.setText(brick.health.toString());
+ brick.updateTint();
+ 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);
+}
function createBall() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'normal';
var ball = new Ball(type);
var gridBottom = brickGridBounds ? brickGridBounds.maxY + 150 : GAME_HEIGHT * 0.7;