Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var StrongFireParticle = Particle.expand(function () {' Line Number: 4
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in this line: 'var StrongFireParticle = Particle.expand(function () {' Line Number: 4
User prompt
After player fills the progression bar play strong fireparticles near progression bar and restart progressionbar
User prompt
set zindex ballflying to 2000
Code edit (4 edits merged)
Please save this source code
User prompt
Set limit that progressbarfg can't progress further than progressbarbg
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'setText')' in this line: 'hoop.scoreLabel.setText(score.toString());' Line Number: 377
User prompt
Hide the number that shows players points
User prompt
Remove the score counter number
Code edit (3 edits merged)
Please save this source code
User prompt
make progress bar need 20 points scored to fill full
User prompt
make a progress bar in the game that fills with every score
User prompt
Create a progression bar in the bottom of the screen that fills with every point scored
Code edit (1 edits merged)
Please save this source code
User prompt
Make fireparticle have much higher zindex
User prompt
increase particle size by 100%
User prompt
Make particle effect when point is scored
User prompt
hide time limit timer
/**** * Classes ****/ var ProgressBar = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('progressBarBg', 'Progress Bar Background', 0, 0.5); var foreground = self.createAsset('progressBarFg', 'Progress Bar Foreground', 0, 0.5); foreground.width = 0; // Start with an empty progress bar self.updateProgress = function (score, targetScore) { var progress = score / targetScore; foreground.width = Math.min(background.width, background.width * progress); }; }); var ScoreText = Container.expand(function () { var self = Container.call(this); var texts = ['Meow! <3', ':3', 'Purr-fectional!', 'Catastic!', 'Yeet!', 'Mew-nificent!', 'Pawsome!', 'Furr-tastic!', 'Meowgical!', 'Whiskerlicious!', 'Grr-eat!', 'Claw-some!', 'Purr-splendid!', 'Tail-endary!', 'Majestifur!', 'Meowvelous!', 'Pawsitively amazing!', 'Feline-tastic!']; var textGraphics = new Text2(texts[Math.floor(Math.random() * texts.length)], { size: 100, fill: '#ffcccc', stroke: '#34344f', strokeThickness: 15 }); textGraphics.anchor.set(0.5, 0.5); self.addChild(textGraphics); var margin = 100; // Margin to ensure text is fully visible var textWidth = textGraphics.width; var textHeight = textGraphics.height; self.x = Math.random() * (2048 - textWidth) + textWidth / 2 + margin; self.y = Math.random() * (2732 - textHeight) + textHeight / 2 + margin; self.lifeSpan = 60; self.move = function () { self.lifeSpan--; if (self.lifeSpan <= 30) { self.alpha -= 1 / 30; } if (self.lifeSpan <= 0 || self.alpha <= 0) { self.destroy(); } }; }); var HoopFlash = Container.expand(function () { var self = Container.call(this); var hoopFlashGraphics = self.createAsset('hoopFlash', 'Hoop Flash Effect', 0.5, 0.5); self.addChild(hoopFlashGraphics); }); var Particle = Container.expand(function () { var self = Container.call(this); self.interactive = false; var particleGraphics = self.createAsset('fireParticle', 'Fire Particle', 0.5, 0.5); particleGraphics.blendMode = 1; particleGraphics.zIndex = 1000; self.lifeSpan = 300; self.speed = { x: (Math.random() - 0.5) * 2, y: (Math.random() - 0.5) * 2 }; self.scale.set((Math.random() * 0.6 + 0.2) * 2); self.rotation = Math.random() * Math.PI * 2; self.move = function () { self.x += self.speed.x; self.y += self.speed.y; self.alpha -= 0.03; if (self.alpha <= 0) { self.destroy(); } }; }); var HoopRim = Container.expand(function () { var self = Container.call(this); var hoopRimGraphics = LK.getAsset('hoopRimSeparate', 'Basketball Hoop Rim Separate', .5, .5); hoopRimGraphics.zIndex = 997; self.addChild(hoopRimGraphics); self.hoopFlash = self.addChild(new HoopFlash()); self.hoopFlash.y += 209; self.hoopFlash.visible = false; }); var Ball = Container.expand(function () { var self = Container.call(this); self.hasScored = false; self.hasBounced = false; var ballGraphics = LK.getAsset('ball', 'Basketball', .5, .5); self.addChild(ballGraphics); self.speed = { x: 0, y: 0 }; self.hasThrown = false; self.move = function () { self.speed.y += 3.2 * 1.3 * 1.15; self.x += self.speed.x; if (self.x < self.width / 2) { self.x = self.width / 2; self.speed.x *= -0.5; } else if (self.x > 2048 - self.width / 2) { self.x = 2048 - self.width / 2; self.speed.x *= -0.5; } self.y += self.speed.y; if (self.y < self.height / 2) { self.y = self.height / 2; self.speed.y *= -0.5; } if (self.hasThrown && !self.flyingAssetChanged) { var assetName = self.x < 1024 ? 'ballFlyingLeft' : 'ballFlying'; self.removeChild(ballGraphics); ballGraphics = LK.getAsset(assetName, 'Flying Basketball', .5, .5); ballGraphics.zIndex = 1; self.addChild(ballGraphics); self.flyingAssetChanged = true; } else if (!self.hasThrown && self.flyingAssetChanged) { self.removeChild(ballGraphics); ballGraphics = LK.getAsset('ball', 'Basketball', .5, .5); self.addChild(ballGraphics); self.flyingAssetChanged = false; } if (self.hasScored) { self.alpha -= 0.15; if (self.alpha <= 0) { self.removeChild(ballGraphics); ballGraphics = LK.getAsset('ball', 'Basketball', .5, .5); self.addChild(ballGraphics); self.alpha = 1; self.hasScored = false; } } else { self.alpha += 0.15; if (self.alpha > 1) { self.alpha = 1; } } }; self.bounceOffPoint = function (x, y, elasticity) { var dx = self.x - x; var dy = self.y - y; var angle = Math.atan2(dy, dx); var speed = Math.sqrt(self.speed.x * self.speed.x + self.speed.y * self.speed.y); self.speed.x = Math.cos(angle) * speed * elasticity; self.speed.y = Math.sin(angle) * speed * elasticity; }; self.angleTo = function (x, y) { var dx = self.x - x; var dy = self.y - y; return Math.atan2(dy, dx); }; self.distanceTo = function (x, y) { var dx = self.x - x; var dy = self.y - y; return Math.sqrt(dx * dx + dy * dy); }; self.moveToDistance = function (x, y, distance) { var angle = self.angleTo(x, y); self.x = x + Math.cos(angle) * (distance * 1.05); self.y = y + Math.sin(angle) * (distance * 1.05); }; }); var Hoop = Container.expand(function () { var self = Container.call(this); self.setScore = function (score) { self.scoreLabel.setText(score.toString()); progressBar.updateProgress(score, 20); }; self.moveTo = function (newX, newY, hoopRim) { var dx = (newX - self.x) / 60; var dy = (newY - self.y) / 60; var steps = 0; var interval = LK.setInterval(function () { self.x += dx; self.y += dy; hoopRim.x = self.x; hoopRim.y = self.y + self.children[1].y - 250; steps++; if (steps >= 60) { LK.clearInterval(interval); } }); }; var backboardGraphics = LK.getAsset('backboard', 'Basketball Backboard', .5, .5); backboardGraphics.y -= 250; self.addChild(backboardGraphics); self.hoopRimGraphics = LK.getAsset('hoopRim', 'Basketball Hoop Rim', .5, .5); self.hoopRimGraphics.y = backboardGraphics.height / 2 - 550 + 20 + 120 + 150 + 100; self.hoopRimGraphics.alpha = 0; self.addChild(self.hoopRimGraphics); // Add HoopTop asset below HoopRim self.hoopTopGraphics = LK.getAsset('hoopTop', 'Basketball Hoop Top', .5, 1); self.hoopTopGraphics.y = self.hoopRimGraphics.y + self.hoopRimGraphics.height / 2 + 291; self.hoopTopGraphics.x -= 2; self.hoopTopGraphics.alpha = 1; self.addChild(self.hoopTopGraphics); self.leftElement = LK.getAsset('leftElement', 'Left Side Element', .5, .5); self.leftElement.x = self.hoopRimGraphics.x - self.hoopRimGraphics.width / 2 + self.leftElement.width / 2 - 50; self.leftElement.y = self.hoopRimGraphics.y - 250; self.leftElement.alpha = 0; self.addChild(self.leftElement); self.rightElement = LK.getAsset('rightElement', 'Right Side Element', .5, .5); self.rightElement.x = self.hoopRimGraphics.x + self.hoopRimGraphics.width / 2 - self.rightElement.width / 2 + 50; self.rightElement.y = self.hoopRimGraphics.y - 250; self.rightElement.alpha = 0; self.addChild(self.rightElement); self.hoopOutlineGraphics = LK.getAsset('hoopOutline', 'Basketball Hoop Outline', 1, .5); self.hoopOutlineGraphics.y = self.hoopRimGraphics.y - 230; self.hoopOutlineGraphics.alpha = 0; self.hoopOutlineGraphics.tint = 0xbb502e; self.hoopOutlineGraphics.rotation = Math.PI / 2; self.addChild(self.hoopOutlineGraphics); self.multiplierLabel = new Text2('', { size: 200, fill: '#8d4529', font: 'Impact' }); self.multiplierLabel.anchor.set(.5, 1); self.multiplierLabel.x = self.hoopRimGraphics.x; self.multiplierLabel.y = self.hoopRimGraphics.y - 250 - 50 + 30; self.addChild(self.multiplierLabel); // Initialize scoreLabel as a Text2 object self.scoreLabel = new Text2('0', { size: 150, fill: '#ffffff' }); self.scoreLabel.anchor.set(0.5, 0); self.scoreLabel.x = self.multiplierLabel.x; self.scoreLabel.y = self.multiplierLabel.y - 200; self.addChild(self.scoreLabel); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFCBCB }); /**** * Game Code ****/ var bg = LK.getAsset('background', 'Background Image', 0.5, 0.5); bg.x = 2048 / 2; bg.y = 2732 / 2 + 150; bg.alpha = 0.7; game.addChild(bg); var gameTime = 1800; var progressBar = game.addChild(new ProgressBar()); progressBar.x = 550; // Centered on the screen progressBar.y = 100; // Positioned at the top var hoop = game.addChild(new Hoop()); var score = 0; var scoreMultiplier = 1; var ball = game.addChild(new Ball()); var hoopRim = game.addChild(new HoopRim()); ball.hitElement = ''; hoop.x = 2048 / 2; hoop.y = 2732 / 2; hoopRim.x = hoop.x; hoopRim.y = hoop.y + hoop.children[1].y - 250; ball.x = 2048 / 2; ball.on('down', function (obj) { if (!ball.hasThrown) { var event = obj.event; dragStart = event.getLocalPosition(game); } }); var dragStart = null; game.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(game); if (dragStart !== null && ball.distanceTo(pos.x, pos.y) > 400) { game.fireBall(obj); } }); game.fireBall = function (obj) { if (dragStart !== null) { var event = obj.event; var pos = event.getLocalPosition(game); var dx = pos.x - dragStart.x; var dy = pos.y - dragStart.y; var angle = Math.atan2(dy, dx); ball.speed.x = Math.cos(angle) * 72 * 1.76 * 0.9 / 3; ball.speed.y = Math.sin(angle) * 72 * 1.76 * 0.9; ball.hasThrown = true; ball.hitElement = ''; game.removeChild(ball); game.addChild(ball); dragStart = null; } }; game.on('up', function (obj) { if (dragStart !== null) { var event = obj.event; var pos = event.getLocalPosition(game); var distance = Math.sqrt(Math.pow(pos.x - dragStart.x, 2) + Math.pow(pos.y - dragStart.y, 2)); if (distance > 150) { game.fireBall(obj); } } dragStart = null; }); var floorY = 2732 - 40 + 900 * (ball.scale.y - 1); ball.y = floorY - ball.height; LK.on('tick', function () { if (scoreMultiplier === 3) { for (var i = 0; i < 2; i++) { var particle = new Particle(); particle.alpha = ball.alpha; var angle = Math.random() * Math.PI * 2; var radius = ball.width * 0.5 * Math.sqrt(Math.random()); particle.x = ball.x + Math.cos(angle) * radius; particle.y = ball.y + Math.sin(angle) * radius; game.addChild(particle); } } game.children.forEach(function (child) { if (child instanceof Particle) { child.move(); } }); var floorY = 2732 - 40 + 900 * (ball.scale.y - 1); ball.move(); if (ball.speed.y > 0) { game.removeChild(hoopRim); game.addChild(hoopRim); if (ball.distanceTo(hoop.x + hoop.leftElement.x, hoop.y + hoop.leftElement.y) < ball.width / 2 + hoop.leftElement.width / 2) { ball.moveToDistance(hoop.x + hoop.leftElement.x, hoop.y + hoop.leftElement.y, ball.width / 2 + hoop.leftElement.width / 2 + 1); ball.bounceOffPoint(hoop.x + hoop.leftElement.x, hoop.y + hoop.leftElement.y, 0.5); ball.hitElement = 'left'; } if (ball.distanceTo(hoop.x + hoop.rightElement.x, hoop.y + hoop.rightElement.y) < ball.width / 2 + hoop.rightElement.width / 2) { ball.moveToDistance(hoop.x + hoop.rightElement.x, hoop.y + hoop.rightElement.y, ball.width / 2 + hoop.rightElement.width / 2 + 1); ball.bounceOffPoint(hoop.x + hoop.rightElement.x, hoop.y + hoop.rightElement.y, 0.5); ball.hitElement = 'right'; } } if (ball.y + ball.height > floorY) { ball.y = floorY - ball.height; ball.speed.y *= -0.75; if (ball.hasThrown && !ball.hasScored) { ball.hasBounced = true; ball.x = 2048 / 2; ball.y = floorY - ball.height; ball.speed.x = 0; ball.speed.y = 0; ball.hasThrown = false; ball.hasBounced = false; ball.scale.x = 1; ball.scale.y = 1; ball.alpha = 1; scoreMultiplier = 1; hoop.multiplierLabel.setText(''); hoop.moveTo(Math.random() * (2048 - 1000) + 500, Math.random() * (2732 - 2000) + 1000, hoopRim); } else if (ball.hasScored) { ball.x = 2048 / 2; ball.y = 2532 - ball.height; ball.speed.x = 0; ball.speed.y = 0; ball.hasThrown = false; ball.hasScored = false; ball.hasBounced = false; ball.scale.x = 1; ball.scale.y = 1; if (ball.hitElement === '') { if (scoreMultiplier < 3) { scoreMultiplier++; } } else { scoreMultiplier = 1; } if (scoreMultiplier > 1) { hoop.multiplierLabel.setText('x' + scoreMultiplier); } else { hoop.multiplierLabel.setText(''); } ball.hitElement = ''; hoop.moveTo(Math.random() * (2048 - 1000) + 500, Math.random() * (2732 - 2000) + 1000, hoopRim); } } else if (ball.hasThrown && ball.intersects(hoop.hoopRimGraphics) && ball.speed.y > 0 && !ball.hasScored && !ball.hasBounced && ball.x > hoop.x + hoop.leftElement.x && ball.x < hoop.x + hoop.rightElement.x) { ball.hasScored = true; score += scoreMultiplier; hoopRim.hoopFlash.visible = true; LK.setTimeout(function () { hoopRim.hoopFlash.visible = false; }, 500); if (score === 2024) { LK.showGameOver(); } else { hoop.scoreLabel.setText(score.toString()); hoop.setScore(score); for (var i = 0; i < 10; i++) { var particle = new Particle(); particle.alpha = 1; var angle = Math.random() * Math.PI * 2; var radius = hoopRim.width * 0.5 * Math.sqrt(Math.random()); particle.x = hoopRim.x + Math.cos(angle) * radius; particle.y = hoopRim.y + Math.sin(angle) * radius; game.addChild(particle); } if (Math.random() < 0.3) { if (window.currentScoreText) { window.currentScoreText.destroy(); } window.currentScoreText = new ScoreText(); game.addChild(window.currentScoreText); } } } });
===================================================================
--- original.js
+++ change.js
@@ -1,51 +1,20 @@
/****
* Classes
****/
-var StrongFireParticle = Container.expand(function () {
- var self = Container.call(this);
- self.lifeSpan = 60; // Shorter lifespan for a strong effect
- self.speed = {
- x: (Math.random() - 0.5) * 4,
- // Faster and more varied speed
- y: (Math.random() - 0.5) * 4
- };
- self.scale.set((Math.random() * 0.6 + 0.4) * 3); // Larger scale for a stronger effect
- self.alpha = 1; // Start fully opaque
- self.move = function () {
- self.x += self.speed.x;
- self.y += self.speed.y;
- self.alpha -= 0.05; // Faster fade out
- if (self.alpha <= 0) {
- self.destroy();
- }
- };
-});
var ProgressBar = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('progressBarBg', 'Progress Bar Background', 0, 0.5);
var foreground = self.createAsset('progressBarFg', 'Progress Bar Foreground', 0, 0.5);
foreground.width = 0; // Start with an empty progress bar
self.updateProgress = function (score, targetScore) {
var progress = score / targetScore;
- if (progress >= 1) {
- score = 0; // Reset score to restart progress
- foreground.width = 0; // Reset progress bar width
- // Play strong fire particles near the progress bar
- for (var i = 0; i < 25; i++) {
- var particle = new StrongFireParticle();
- particle.x = this.x + Math.random() * this.width;
- particle.y = this.y;
- game.addChild(particle);
- }
- } else {
- foreground.width = Math.min(background.width, background.width * progress);
- }
+ foreground.width = Math.min(background.width, background.width * progress);
};
});
var ScoreText = Container.expand(function () {
var self = Container.call(this);
- var texts = ['Meow! <3', ':3', 'Purr-fectional!', 'Catastic!', 'Mew-nificent!', 'Pawsome!', 'Furr-tastic!', 'Meowgical!', 'Whiskerlicious!', 'Grr-eat!', 'Claw-some!', 'Purr-splendid!', 'Tail-endary!', 'Majestifur!', 'Meowvelous!', 'Pawsitively amazing!', 'Feline-tastic!'];
+ var texts = ['Meow! <3', ':3', 'Purr-fectional!', 'Catastic!', 'Yeet!', 'Mew-nificent!', 'Pawsome!', 'Furr-tastic!', 'Meowgical!', 'Whiskerlicious!', 'Grr-eat!', 'Claw-some!', 'Purr-splendid!', 'Tail-endary!', 'Majestifur!', 'Meowvelous!', 'Pawsitively amazing!', 'Feline-tastic!'];
var textGraphics = new Text2(texts[Math.floor(Math.random() * texts.length)], {
size: 100,
fill: '#ffcccc',
stroke: '#34344f',
4:3 Simple rectangle white outline. Black background
Very cute cat looking into camera. Full body cat. Cartoon art style. Ginger cat. No UI elements in the picture like popups, close buttons etc.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
background
Head of a cute ginger cat peeking from a box
heart. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.