User prompt
Fix Bug: 'Uncaught Error: [object Object]addChildAt: The index 4 supplied is out of bounds 3' in this line: 'self.move = function () {' Line Number: 90
User prompt
Fix Bug: 'Uncaught Error: [object Object]addChildAt: The index 4 supplied is out of bounds 3' in this line: 'self.move = function () {' Line Number: 90
User prompt
Fix Bug: 'Uncaught Error: [object Object]addChildAt: The index 4 supplied is out of bounds 3' in this line: 'self.move = function () {' Line Number: 90
User prompt
make ball to appear above everything
User prompt
make particles 2 times smaller in size
User prompt
make particles 2 times smaller
User prompt
make particles 0.5 times smaller
User prompt
make particles appear above galaxy and dots
User prompt
make Particles always appear under Ball
User prompt
create an object called Particles under the ball each 0.05 seconds
User prompt
Create a line of objects called Particles under the ball
User prompt
make dots move 10% slower
User prompt
make bonus 1% bigger and rotate 1% faster each time the score goes up
User prompt
make bonus slowly rotate counter clockwise
User prompt
Change bonus to appear in any of the 4 stage's corners
User prompt
how many different assets can i create?
User prompt
Create an asset for particle
User prompt
make a new object called Particles appear under Ball each 0.08 seconds
User prompt
if player's paddle is near bonus, make bonus disappear, and after that add 5 to the score once.
User prompt
if a player is near a paddle, make bonus disappear, and after that add 5 to the score once.
User prompt
make 20% of dots pastel yellow in color
User prompt
if player's paddle is near bonus, make bonus disappear, and add 5 to the score. Then make bonus reappear after 12 seconds
User prompt
make 20% of dots pastel yellow in color
User prompt
make 20% of dots yellow in color
User prompt
each time the score goes up, increase AI paddle's maximum speed by 4%
var Particles = Container.expand(function () { var self = Container.call(this); var particlesGraphics = self.createAsset('particles', 'Particles Graphics', 0.5, 0.5); self.speed = { x: (Math.random() * 10 - 5) / 6, y: (Math.random() * 10 - 5) / 6 }; self.move = function () { self.x += self.speed.x; self.y += self.speed.y; }; }); var Bonus = Container.expand(function () { var self = Container.call(this); var bonusGraphics = self.createAsset('bonus', 'Bonus Graphics', 0.5, 0.5); self.rotationSpeed = -0.01; self.rotate = function () { self.rotation += self.rotationSpeed; }; }); var Galaxy = Container.expand(function () { var self = Container.call(this); self.rotationSpeed = -0.00033333; var galaxyGraphics = self.createAsset('galaxy', 'Galaxy Graphics', 0.5, 0.5); galaxyGraphics.scale.set(12); self.scaleFactor = 0.0001; self.scaleDirection = 0.8; }); var Sun = Container.expand(function () { var self = Container.call(this); var sunGraphics = self.createAsset('sun', 'Sun Graphics', 0.5, 0.5); sunGraphics.scale.set(4); }); var Dot = Container.expand(function () { var self = Container.call(this); var dotGraphics = self.createAsset('dot', 'Dot Graphics', 0.5, 0.5); dotGraphics.scale.set(Math.random() * (0.5 - 0.3) + 0.3); var colors = [0xFFFFFF, 0xADD8E6, 0xFFFFE0]; dotGraphics.tint = colors[Math.floor(Math.random() * colors.length)]; self.speed = { x: (Math.random() * 10 - 5) / 6, y: (Math.random() * 10 - 5) / 6 }; self.alpha = 0; self.fadeIn = true; self.fadeOut = false; self.lifeTime = 0; self.maxLifeTime = Math.floor(Math.random() * (1200 - 300 + 1)) + 300; self.move = function () { self.x += self.speed.x * 0.9; self.y += self.speed.y * 0.9; self.lifeTime++; if (self.fadeIn) { self.alpha += 0.01; if (self.alpha >= 1) { self.fadeIn = false; } } else if (self.fadeOut) { self.alpha -= 0.01; if (self.alpha <= 0) { self.x = Math.random() * 2048; self.y = Math.random() * 2732; self.alpha = 0; self.fadeIn = true; self.fadeOut = false; self.lifeTime = 0; } } else if (self.lifeTime >= self.maxLifeTime) { self.fadeOut = true; } }; }); var Paddle = Container.expand(function () { var self = Container.call(this); var paddleGraphics = self.createAsset('paddle', 'Paddle Graphics', 0.5, 0.5); self.speed = 20; self.move = function (direction) { self.y += direction * self.speed; }; }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.createAsset('ball', 'Ball Graphics', 0.5, 0.5); self.speed = { x: 10, y: 10 }; self.rotationSpeed = 0.01; self.rotationDirection = 1; self.move = function () { self.x += self.speed.x; self.y += self.speed.y; self.rotation += self.rotationSpeed * self.rotationDirection; }; }); var Game = Container.expand(function () { var self = Container.call(this); var galaxy = self.addChild(new Galaxy()); galaxy.x = 2048 / 2; galaxy.y = 2732 / 2; var playerPaddle = self.addChildAt(new Paddle(), self.children.length); var aiPaddle = self.addChildAt(new Paddle(), self.children.length); var ball = self.addChildAt(new Ball(), self.children.length); var bonus = self.addChildAt(new Bonus(), 0); bonus.x = Math.random() < 0.5 ? 0 : 2048; bonus.y = Math.random() < 0.5 ? 0 : 2732; var paddles = [playerPaddle, aiPaddle]; var score = 0; playerPaddle.x = 100; playerPaddle.y = 2732 / 2; aiPaddle.x = 2048 - 100; aiPaddle.y = 2732 / 2; ball.x = 2048 / 2; ball.y = 2732 / 2; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var dots = []; for (var i = 0; i < 100; i++) { var dot = new Dot(); dot.x = Math.random() * 2048; dot.y = Math.random() * 2732; dots.push(dot); } for (var i = 0; i < dots.length; i++) { self.addChild(dots[i]); } var targetY = playerPaddle.y; stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); targetY = pos.y; }); stage.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); targetY = pos.y; }); LK.on('tick', function () { if (targetY < playerPaddle.y) { playerPaddle.move(-1); } else if (targetY > playerPaddle.y) { playerPaddle.move(1); } }); LK.on('tick', function () { ball.move(); if (LK.ticks % 3 == 0) { var particles = new Particles(); particles.x = ball.x; particles.y = ball.y; self.addChild(particles); } bonus.rotate(); var direction = ball.y - aiPaddle.y; direction = direction / Math.abs(direction); aiPaddle.move(direction * 0.5); for (var i = 0; i < paddles.length; i++) { if (ball.intersects(paddles[i])) { var hitPoint = ball.y - paddles[i].y; var hitRatio = hitPoint / paddles[i].height; ball.speed.y += hitRatio * 10; if (ball.speed.x > 0 && ball.x < paddles[i].x || ball.speed.x < 0 && ball.x > paddles[i].x) { ball.speed.x *= -1; ball.rotationDirection *= -1; } if (paddles[i] === playerPaddle) { score++; bonus.scale.x *= 1.01; bonus.scale.y *= 1.01; bonus.rotationSpeed *= 1.01; } } } if (ball.y <= 0 || ball.y >= 2732) { ball.speed.y *= -1; } if (ball.x <= 0) { LK.showGameOver(); } if (ball.x >= 2048) { score++; ball.x = 2048 / 2; ball.y = 2732 / 2; ball.speed.x = 10; ball.speed.y = 10; } scoreTxt.setText(score.toString()); for (var i = 0; i < dots.length; i++) { dots[i].move(); } galaxy.rotation += galaxy.rotationSpeed; galaxy.scale.x += galaxy.scaleFactor * galaxy.scaleDirection; galaxy.scale.y += galaxy.scaleFactor * galaxy.scaleDirection; if (galaxy.scale.x > 1.2 || galaxy.scale.x < 0.8) { galaxy.scaleDirection *= -1; } }); });
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,7 @@
-var Particle = Container.expand(function () {
+var Particles = Container.expand(function () {
var self = Container.call(this);
- var particleGraphics = self.createAsset('particle', 'Particle Graphics', 0.5, 0.5);
+ var particlesGraphics = self.createAsset('particles', 'Particles Graphics', 0.5, 0.5);
self.speed = {
x: (Math.random() * 10 - 5) / 6,
y: (Math.random() * 10 - 5) / 6
};
@@ -117,17 +117,17 @@
fill: "#ffffff"
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
- var particles = [];
+ var dots = [];
for (var i = 0; i < 100; i++) {
- var particle = new Particle();
- particle.x = ball.x;
- particle.y = ball.y;
- particles.push(particle);
+ var dot = new Dot();
+ dot.x = Math.random() * 2048;
+ dot.y = Math.random() * 2732;
+ dots.push(dot);
}
- for (var i = 0; i < particles.length; i++) {
- self.addChild(particles[i]);
+ for (var i = 0; i < dots.length; i++) {
+ self.addChild(dots[i]);
}
var targetY = playerPaddle.y;
stage.on('down', function (obj) {
var event = obj.event;
@@ -147,8 +147,14 @@
}
});
LK.on('tick', function () {
ball.move();
+ if (LK.ticks % 3 == 0) {
+ var particles = new Particles();
+ particles.x = ball.x;
+ particles.y = ball.y;
+ self.addChild(particles);
+ }
bonus.rotate();
var direction = ball.y - aiPaddle.y;
direction = direction / Math.abs(direction);
aiPaddle.move(direction * 0.5);
@@ -182,10 +188,10 @@
ball.speed.x = 10;
ball.speed.y = 10;
}
scoreTxt.setText(score.toString());
- for (var i = 0; i < particles.length; i++) {
- particles[i].move();
+ for (var i = 0; i < dots.length; i++) {
+ dots[i].move();
}
galaxy.rotation += galaxy.rotationSpeed;
galaxy.scale.x += galaxy.scaleFactor * galaxy.scaleDirection;
galaxy.scale.y += galaxy.scaleFactor * galaxy.scaleDirection;
2d earth Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white star, no background, pixelart Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Galaxy pixelart in black background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart of a tall and thin spaceship, no background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
sun pixelart Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle, no background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
3 yellow sparkles, pixelart, no background Single Game Texture. In-Game asset. 2d. High contrast. No shadows.
simple black circle no background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Green microchip pixelart Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
number 10, golden color, pixelart Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.