User prompt
increase in cost of upgrades should increase te same way the balls cost increase. make sure to update also the visual references and not only the logic
User prompt
upgrades cost are not reflecing the price they have, can you fix that
Code edit (23 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'c is not defined' in or related to this line: 'c;' Line Number: 336
Code edit (13 edits merged)
Please save this source code
User prompt
When a the level ends, balls need to be pushed very fast to either the top or the bottom of the screen, in the same x position they currently were
Code edit (10 edits merged)
Please save this source code
User prompt
When a level is compelted apply a tween effect to the balls, and have them explode into the edges of the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (6 edits merged)
Please save this source code
User prompt
balls should start a little faster just a little, but do not change anyvalue of the buttons or price
Code edit (7 edits merged)
Please save this source code
User prompt
remove the comments form the custom patternsan put them in one line
Code edit (2 edits merged)
Please save this source code
User prompt
when you click on restart, delete from local storage the current level
User prompt
add 4 new levels
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in or related to this line: 'tween(p, arguments[0]);' Line Number: 1470 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in or related to this line: 'tween(p, arguments[0]);' Line Number: 1470
Code edit (1 edits merged)
Please save this source code
User prompt
Make game title bigger font an container
User prompt
make the container 10% less wide
User prompt
move game title and container 100 pixels up
User prompt
move start button 100 pixels down and increase it size
User prompt
increase font of start
===================================================================
--- original.js
+++ change.js
@@ -14,11 +14,15 @@
anchorX: 0.5,
anchorY: 0.5
});
ballGraphics.tint = type === 'splash' ? 0xff0066 : type === 'sniper' ? 0x00ff99 : type === 'scatter' ? 0xffff00 : type === 'smallScatter' ? 0xffff00 : 0xffffff;
+ if (type === 'smallScatter') {
+ ballGraphics.scaleX = 0.5;
+ ballGraphics.scaleY = 0.5;
+ }
self.type = type;
- self.speed = type === 'splash' ? upgrades.splashSpeed : type === 'sniper' ? upgrades.sniperSpeed : type === 'scatter' ? upgrades.scatterSpeed : type === 'smallScatter' ? upgrades.scatterSpeed * 0.8 : upgrades.normalSpeed;
- self.power = type === 'splash' ? upgrades.splashPower : type === 'sniper' ? upgrades.sniperPower : type === 'scatter' ? upgrades.scatterPower : type === 'smallScatter' ? Math.max(1, Math.floor(upgrades.scatterPower * 0.5)) : upgrades.normalPower;
+ self.speed = type === 'splash' ? upgrades.splashSpeed : type === 'sniper' ? upgrades.sniperSpeed : type === 'scatter' ? upgrades.scatterSpeed : type === 'smallScatter' ? upgrades.scatterSpeed * 1.5 : upgrades.normalSpeed;
+ self.power = type === 'splash' ? upgrades.splashPower : type === 'sniper' ? upgrades.sniperPower : type === 'scatter' ? upgrades.scatterPower : type === 'smallScatter' ? Math.max(1, Math.floor(upgrades.scatterPower * 0.8)) : upgrades.normalPower;
self.velocity = {
x: 1,
y: -1
};
@@ -305,8 +309,40 @@
/****
* Game Code
****/
+function _toConsumableArray2(r) {
+ return _arrayWithoutHoles2(r) || _iterableToArray2(r) || _unsupportedIterableToArray2(r) || _nonIterableSpread2();
+}
+function _nonIterableSpread2() {
+ 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 _unsupportedIterableToArray2(r, a) {
+ if (r) {
+ if ("string" == typeof r) {
+ return _arrayLikeToArray2(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) ? _arrayLikeToArray2(r, a) : void 0;
+ }
+}
+function _iterableToArray2(r) {
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) {
+ return Array.from(r);
+ }
+}
+function _arrayWithoutHoles2(r) {
+ if (Array.isArray(r)) {
+ return _arrayLikeToArray2(r);
+ }
+}
+function _arrayLikeToArray2(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;
+}
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
}
function _nonIterableSpread() {
@@ -380,21 +416,21 @@
height: frameThickness
});
bottomFrame.x = 0;
bottomFrame.y = 2720;
-game.addChild(bottomFrame); // Should be bottomFrame
+game.addChild(bottomFrame); // Fixed to bottomFrame
function animateBottomFrameTint() {
tween(bottomFrameGraphics, {
- // Should be bottomFrameGraphics
tint: 0xff33cc
}, {
+ // Fixed to bottomFrameGraphics
duration: 2000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(bottomFrameGraphics, {
- // Should be bottomFrameGraphics
tint: 0x00ff99
}, {
+ // Fixed to bottomFrameGraphics
duration: 2000,
easing: tween.easeInOut,
onFinish: animateBottomFrameTint
});
@@ -464,12 +500,12 @@
hud.visible = false;
powerupContainer.visible = false;
upgradeButton.visible = false;
balls.forEach(function (ball) {
- return ball.visible = true;
+ ball.visible = true;
});
bricks.forEach(function (brick) {
- return brick.visible = false;
+ brick.visible = false;
});
var congratsText = new Text2('Congratulations! You broke them ALL!', {
size: 100,
fill: 0xffffff
@@ -533,9 +569,9 @@
endGameButton.x = GAME_WIDTH / 2;
endGameButton.y = GAME_HEIGHT - 240;
endGameButton.interactive = true;
endGameButton.down = function () {
- storage.level = 1; // Reset the level in local storage
+ storage.level = 1;
LK.showGameOver();
};
game.addChild(endGameButton);
var resetButton = new ResetButton();
@@ -562,72 +598,76 @@
hitpoints: 2,
pattern: 'staggered'
},
3: {
+ totalBricks: 63,
+ hitpoints: 3,
+ pattern: 'cross'
+ },
+ 4: {
totalBricks: 77,
pattern: 'custom',
customPattern: [[0, 3, 3, 0, 3, 3, 0], [3, 4, 4, 3, 4, 4, 3], [3, 4, 4, 4, 4, 4, 3], [3, 4, 4, 4, 4, 4, 3], [3, 4, 4, 4, 4, 4, 3], [3, 4, 4, 4, 4, 4, 3], [3, 4, 4, 4, 4, 4, 3], [0, 3, 4, 4, 4, 3, 0], [0, 0, 3, 4, 3, 0, 0], [0, 0, 0, 3, 0, 0, 0], [0, 0, 0, 3, 0, 0, 0]]
},
- 4: {
+ 5: {
totalBricks: 112,
pattern: 'custom',
customPattern: [[0, 0, 0, 3, 0, 0, 0], [0, 0, 3, 4, 3, 0, 0], [0, 3, 4, 5, 4, 3, 0], [3, 4, 5, 6, 5, 4, 3], [4, 5, 6, 7, 6, 5, 4], [3, 5, 6, 7, 6, 5, 3], [0, 4, 5, 6, 5, 4, 0], [0, 3, 4, 5, 4, 3, 0], [0, 0, 3, 4, 3, 0, 0], [0, 0, 2, 3, 2, 0, 0], [0, 0, 1, 2, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 2, 1, 0, 0], [0, 0, 1, 2, 1, 0, 0]]
},
- 5: {
+ 6: {
totalBricks: 60,
hitpoints: 10,
pattern: 'cross'
},
- 6: {
+ 7: {
totalBricks: 70,
hitpoints: 13,
pattern: 'clustered'
},
- 7: {
+ 8: {
totalBricks: 112,
hitpoints: 15,
pattern: 'clustered'
},
- 8: {
+ 9: {
totalBricks: 112,
hitpoints: 20,
pattern: 'cross'
},
- 9: {
+ 10: {
totalBricks: 112,
hitpoints: 30,
pattern: 'clustered'
},
- 10: {
+ 11: {
totalBricks: 112,
hitpoints: 50,
pattern: 'clustered'
},
- 11: {
+ 12: {
totalBricks: 112,
hitpoints: 99,
pattern: 'clustered'
},
- 12: {
- totalBricks: 120,
- hitpoints: 120,
- pattern: 'staggered'
- },
13: {
- totalBricks: 130,
- hitpoints: 150,
- pattern: 'cross'
+ totalBricks: 140,
+ pattern: 'custom',
+ customPattern: [[222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [222, 222, 0, 0, 0, 222, 222], [0, 222, 222, 222, 222, 222, 0], [0, 0, 222, 222, 222, 0, 0]]
},
14: {
totalBricks: 140,
- hitpoints: 180,
pattern: 'custom',
- customPattern: [[0, 2, 2, 0, 2, 2, 0], [2, 3, 3, 2, 3, 3, 2], [2, 3, 3, 3, 3, 3, 2], [2, 3, 3, 3, 3, 3, 2], [2, 3, 3, 3, 3, 3, 2], [2, 3, 3, 3, 3, 3, 2], [2, 3, 3, 3, 3, 3, 2], [0, 2, 3, 3, 3, 2, 0], [0, 0, 2, 3, 2, 0, 0], [0, 0, 0, 2, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0]]
+ customPattern: [[333, 333, 333, 333, 333, 0, 0], [333, 0, 0, 0, 333, 0, 0], [333, 0, 0, 0, 333, 0, 0], [333, 0, 0, 0, 333, 0, 0], [333, 333, 333, 333, 333, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0], [333, 333, 0, 0, 0, 0, 0]]
},
15: {
- totalBricks: 150,
- hitpoints: 200,
- pattern: 'clustered'
+ totalBricks: 140,
+ pattern: 'custom',
+ customPattern: [[0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0], [0, 444, 444, 444, 0]]
+ },
+ 16: {
+ totalBricks: 140,
+ pattern: 'custom',
+ customPattern: [[555, 555, 555, 555, 555, 555, 555], [555, 555, 555, 555, 555, 555, 555], [555, 555, 555, 555, 555, 555, 555], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0], [0, 0, 555, 555, 555, 0, 0]]
}
};
var upgrades = storage.upgrades || {
normalSpeed: 1,
@@ -847,9 +887,9 @@
powerupContainer.visible = false;
game.addChild(powerupContainer);
var bottomHud = new Container();
bottomHud.y = GAME_HEIGHT - 200;
-game.addChild(bottomHud); // Should be bottomHud
+game.addChild(bottomHud); // Fixed to bottomHud
var upgradeButtons = {};
function createUpgradeButton(labelPrefix, x, costKey, upgradeKey, baseCost, iconType, prevTier) {
var button = new Container();
var buttonGraphics = button.attachAsset('powerupbutton', {
@@ -925,10 +965,9 @@
b[upgradeKey.includes('Speed') ? 'speed' : 'power'] = upgrades[upgradeKey];
}
});
if (upgradeKey === 'clickDamage') {
- upgrades.clickDamage = upgrades[upgradeKey];
- storage.upgrades = Object.assign({}, upgrades);
+ upgrades.clickDamage = upgrades[upgradeKey], storage.upgrades = Object.assign({}, upgrades);
}
updateButtonStates();
};
button.updateState = function () {
@@ -999,15 +1038,21 @@
}
});
}
function scatterOnImpact(ball) {
- for (var i = 0; i < 4; i++) {
+ var numBalls = 4;
+ for (var i = 0; i < numBalls; i++) {
var smallBall = new Ball('smallScatter');
smallBall.x = ball.x;
smallBall.y = ball.y;
- var angle = i / 4 * 2 * Math.PI;
+ var angle = Math.random() * 2 * Math.PI;
+ var speedVariation = 0.8 + Math.random() * 0.4;
+ smallBall.speed = upgrades.scatterSpeed * 0.8 * speedVariation;
smallBall.velocity.x = Math.cos(angle);
smallBall.velocity.y = Math.sin(angle);
+ var magnitude = Math.sqrt(smallBall.velocity.x * smallBall.velocity.x + smallBall.velocity.y * smallBall.velocity.y);
+ smallBall.velocity.x /= magnitude;
+ smallBall.velocity.y /= magnitude;
balls.push(smallBall);
game.addChild(smallBall);
}
}
@@ -1170,18 +1215,18 @@
}
}
console.log("Total bricks created: ".concat(brickCount, ", bricks array length: ").concat(bricks.length));
brickGridBounds = {
- minX: Math.min.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ minX: Math.min.apply(Math, _toConsumableArray2(bricks.map(function (b) {
return b.x - BRICK_WIDTH / 2;
}))),
- maxX: Math.max.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ maxX: Math.max.apply(Math, _toConsumableArray2(bricks.map(function (b) {
return b.x + BRICK_WIDTH / 2;
}))),
- minY: Math.min.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ minY: Math.min.apply(Math, _toConsumableArray2(bricks.map(function (b) {
return b.y - BRICK_HEIGHT / 2;
}))),
- maxY: Math.max.apply(Math, _toConsumableArray(bricks.map(function (b) {
+ maxY: Math.max.apply(Math, _toConsumableArray2(bricks.map(function (b) {
return b.y + BRICK_HEIGHT / 2;
})))
};
}
@@ -1288,92 +1333,136 @@
return;
}
}
};
+// Enhanced Homepage Setup
var stars = [];
for (var i = 0; i < 100; i++) {
var star = new Star();
star.x = Math.random() * GAME_WIDTH;
star.y = Math.random() * GAME_HEIGHT;
+ star.alpha = Math.random() * 0.5 + 0.5;
stars.push(star);
game.addChildAt(star, 0);
+ tween(star, {
+ alpha: Math.random() * 0.3 + 0.2,
+ scaleX: Math.random() * 0.5 + 0.5,
+ scaleY: Math.random() * 0.5 + 0.5
+ }, {
+ duration: 500 + Math.random() * 1000,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
+ });
}
var gameTitleContainer = new Container();
game.addChild(gameTitleContainer);
var gameTitle = new GameTitle();
+gameTitle.scaleX = 0.714; // ~1000x250
+gameTitle.scaleY = 0.714;
gameTitle.x = GAME_WIDTH / 2;
gameTitle.y = GAME_HEIGHT / 2 - 600;
+gameTitle.rotation = -0.5;
gameTitleContainer.addChild(gameTitle);
-function animateTitleColor() {
+function animateTitle() {
tween(gameTitle, {
+ y: GAME_HEIGHT / 2 - 500,
+ rotation: 0,
tint: 0xff33cc
}, {
- duration: 2000,
- easing: tween.easeInOut,
+ duration: 1000,
+ easing: tween.bounceOut,
onFinish: function onFinish() {
tween(gameTitle, {
+ scaleX: 0.75,
+ scaleY: 0.75,
tint: 0x00ff99
}, {
- duration: 2000,
+ duration: 1500,
easing: tween.easeInOut,
- onFinish: animateTitleColor
+ loop: true,
+ yoyo: true
});
}
});
}
-animateTitleColor();
-tween(gameTitle, {
- y: GAME_HEIGHT / 2 - 500
-}, {
- duration: 1000,
- easing: tween.bounceOut
-});
+animateTitle();
var startButton = new StartButton();
+startButton.scaleX = 1.2; // ~600x300
+startButton.scaleY = 1.2;
startButton.x = GAME_WIDTH / 2;
startButton.y = GAME_HEIGHT / 2 + 300;
startButton.tint = 0x00ff99;
game.addChild(startButton);
tween(startButton, {
- y: startButton.y - 20
+ scaleX: 1.25,
+ scaleY: 1.25
}, {
- duration: 1000,
+ duration: 800,
easing: tween.easeInOut,
- onFinish: function onFinish() {
- tween(startButton, {
- y: startButton.y + 20
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
- }
+ loop: true,
+ yoyo: true
});
var resetButton = new ResetButton();
resetButton.x = GAME_WIDTH / 2;
-resetButton.y = startButton.y + 900;
+resetButton.y = startButton.y + 200;
+resetButton.alpha = 0;
game.addChild(resetButton);
tween(resetButton, {
- y: resetButton.y - 20
+ alpha: 1,
+ rotation: 0.1
}, {
duration: 1000,
- easing: tween.easeInOut,
+ delay: 500,
+ easing: tween.easeIn,
onFinish: function onFinish() {
tween(resetButton, {
- y: resetButton.y + 20
+ rotation: -0.1
}, {
- duration: 1000,
- easing: tween.easeInOut
+ duration: 1200,
+ easing: tween.easeInOut,
+ loop: true,
+ yoyo: true
});
}
});
+var particles = [];
+for (var i = 0; i < 20; i++) {
+ var particle = new Ball('normal');
+ particle.scaleX = 0.3;
+ particle.scaleY = 0.3;
+ particle.x = GAME_WIDTH / 2 + (Math.random() - 0.5) * 800;
+ particle.y = GAME_HEIGHT / 2 - 500 + (Math.random() - 0.5) * 300;
+ particle.alpha = 0.7;
+ particles.push(particle);
+ game.addChild(particle);
+ tween(particle, {
+ x: particle.x + (Math.random() - 0.5) * 200,
+ y: particle.y + (Math.random() - 0.5) * 200,
+ alpha: 0
+ }, {
+ duration: 2000 + Math.random() * 1000,
+ easing: tween.easeOut,
+ onFinish: function onFinish(p) {
+ p.x = GAME_WIDTH / 2 + (Math.random() - 0.5) * 800;
+ p.y = GAME_HEIGHT / 2 - 500 + (Math.random() - 0.5) * 300;
+ p.alpha = 0.7;
+ tween(p, arguments[0]);
+ }
+ });
+}
LK.playMusic('backgroundmusic');
function startGame() {
startButton.destroy();
gameTitle.destroy();
resetButton.visible = false;
+ particles.forEach(function (p) {
+ return p.destroy();
+ });
upgradeButton.visible = true;
hud.visible = true;
createBricks();
- console.log("Initial bricks after startGame: ".concat(bricks.length));
+ console.log("Initial bricks after startGame: " + bricks.length);
createBall('normal');
if (score > 0) {
scoreTxt.setText('$' + score.toString());
}