User prompt
each time the score goes up, make player's paddle asset to be 10% more yellow
User prompt
Each 0.1 second add a particle under ball, and then have them scale down in size and disappear after 1.5 seconds
User prompt
Each 0.1 second add particle under ball, and then have them scale down in size and disappear after 1.5 seconds
User prompt
Each 0.1 second add a particle under ball, and then have them scale down in size and disappear after 1.5 seconds
User prompt
make ai paddle and player's paddle have 2 different colors. make AI paddle asset to have 50% tint of #E63946
User prompt
make AI paddle asset to have 50% tint of #E63946
User prompt
make AI paddle's asset to have a 50% tint of #E63946
User prompt
dont add tint to player's paddle
User prompt
make AI paddle's asset to be have a 50% tint of #E63946
User prompt
make AI paddle's asset to be have a 50% tint of #ef233c
User prompt
make AI paddle's asset to be have a 50% tint of #EC5B67
User prompt
make AI paddle's asset to be slightly red in color
User prompt
Before disappearing, make bonus scale down very fast in 0.1 second
User prompt
Before disappearing, make bonus smoothly scale down in 0.1 second
User prompt
after bonus is clicked on, make it scale down in size
User prompt
make 20% of dots to be #EDDEA4
User prompt
make bonus scale up 3 times faster
User prompt
when bonus is created, make bonus smoothly scale from tiny size to regular size in 0.2 seconds
User prompt
if a bonus is not clicked on for longer than 2 seconds, make it disappear and appear at a random point from 7 to 13 seconds
User prompt
if a bonus is not clicked on for longer than 2 seconds, make it disappear, and then make it reappear at a random point from 7 to 13 seconds
User prompt
Make bonus reappear at a random point from 7 to 13 seconds each time it disappears or is clicked on
User prompt
bonus to be disappear if not clicked on for more than 2 seconds
User prompt
make bonus fade out 2 times faster when not clicked on for more than 2 seconds
User prompt
make bonus fade out if not clicked on for longer than 2 seconds
User prompt
add object called particles that appear under ball each 0.1 second, and disappear entirely after 1 second
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.fadeSpeed = 0.01; self.rotate = function () { self.rotation += self.rotationSpeed; }; self.timer = LK.setTimeout(function () { self.destroy(); }, 2000); }); 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; function createBonus() { bonus = self.addChildAt(new Bonus(), self.children.length); bonus.x = (Math.random() * 0.2 + 0.4) * 2048; bonus.y = (Math.random() * 0.2 + 0.4) * 2732; bonus.on('down', function () { LK.clearTimeout(bonus.timer); bonus.scale.x *= 0.5; bonus.scale.y *= 0.5; bonus.alpha = 0; score += 3; bonus.destroy(); var bonusDelay = Math.floor(Math.random() * (15000 - 7000 + 1)) + 7000; LK.setTimeout(createBonus, bonusDelay); }); } var bonusDelay = Math.floor(Math.random() * (15000 - 7000 + 1)) + 7000; LK.setTimeout(createBonus, bonusDelay); 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 (bonus) { 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++; if (bonus) { 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,33 +1,15 @@
-var Particle = Container.expand(function () {
- var self = Container.call(this);
- var particleGraphics = self.createAsset('particle', 'Particle Graphics', 0.5, 0.5);
- self.lifeTime = 0;
- self.maxLifeTime = 60;
- self.update = function () {
- self.lifeTime++;
- if (self.lifeTime >= self.maxLifeTime) {
- self.destroy();
- }
- };
-});
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.fadeSpeed = 0.01;
- self.lifeTime = 0;
- self.maxLifeTime = 120 * 2;
self.rotate = function () {
self.rotation += self.rotationSpeed;
- self.lifeTime++;
- if (self.lifeTime >= self.maxLifeTime) {
- self.alpha -= self.fadeSpeed * 2;
- if (self.alpha <= 0) {
- self.destroy();
- }
- }
};
+ self.timer = LK.setTimeout(function () {
+ self.destroy();
+ }, 2000);
});
var Galaxy = Container.expand(function () {
var self = Container.call(this);
self.rotationSpeed = -0.00033333;
@@ -100,14 +82,8 @@
self.move = function () {
self.x += self.speed.x;
self.y += self.speed.y;
self.rotation += self.rotationSpeed * self.rotationDirection;
- if (LK.ticks % 6 == 0) {
- var particle = new Particle();
- particle.x = self.x;
- particle.y = self.y;
- self.parent.addChild(particle);
- }
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
@@ -122,8 +98,9 @@
bonus = self.addChildAt(new Bonus(), self.children.length);
bonus.x = (Math.random() * 0.2 + 0.4) * 2048;
bonus.y = (Math.random() * 0.2 + 0.4) * 2732;
bonus.on('down', function () {
+ LK.clearTimeout(bonus.timer);
bonus.scale.x *= 0.5;
bonus.scale.y *= 0.5;
bonus.alpha = 0;
score += 3;
@@ -177,13 +154,8 @@
}
});
LK.on('tick', function () {
ball.move();
- self.children.forEach(function (child) {
- if (child instanceof Particle) {
- child.update();
- }
- });
if (bonus) {
bonus.rotate();
}
var direction = ball.y - aiPaddle.y;
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.