Code edit (2 edits merged)
Please save this source code
User prompt
star, circularobstacle and lineorbit should move slowly downward after the first tap
User prompt
make sure orbitline moves downards like start after first tap
User prompt
orbitline must move downwards on tick after first tap
User prompt
orbitline shoudl move downwards like start, not bounce like dot
User prompt
make sure orbitline moves downwards smoothly like start after first tap
User prompt
make sure orbitline moves on tick downwards contanly like start
User prompt
wait for first tap before orbitline starts moving downwrads
User prompt
nenw orbitlines should also move downwards
User prompt
orbitline should also have the same movement as star when dot is taped
User prompt
orbitline should keep on moving slighly downwards on tick, but also move down the same amount that star does on every tap
User prompt
on tick, add an extra movedown function for orbitline. this will move the orbitline slightly downwards on tick, after the first tap happens.
User prompt
orbitline should wait for first tap to start moving
Code edit (2 edits merged)
Please save this source code
User prompt
star and orbitline should move downwards at the same speed
User prompt
where can I change the speed of obstacles from orbitline?
Code edit (2 edits merged)
Please save this source code
User prompt
make tap text thiner
User prompt
smallobstacle should increase and decrease its size
User prompt
smallobstacle should update its sizeon tick
User prompt
start, obstacle and smallobstacle should move dowwards on tick after the first tap
User prompt
after first tap, star, circularobstacle and smallobstacles should move slightly downwards on tick
Code edit (2 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
User prompt
use boing sound when player taps on the screen
===================================================================
--- original.js
+++ change.js
@@ -1,53 +1,94 @@
/****
* Classes
-****/
-var ScorePopup = Container.expand(function (x, y) {
+****/
+var CircularObstacle = Container.expand(function (starX, starY, radius, angleSpeed, initialAngle) {
var self = Container.call(this);
- self.x = x;
- self.y = y;
- var scoreText = new Text2('+1', {
- size: 100,
- fill: "#ffffff",
+ var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
- scoreText.x = -scoreText.width / 2;
- scoreText.y = -scoreText.height / 2;
- self.addChild(scoreText);
- self.alpha = 1;
- var duration = 120;
+ self.angle = initialAngle || 0;
+ self.radius = radius;
+ self.angleSpeed = angleSpeed * 0.75;
+ self.starX = starX;
+ self.starY = starY;
+ self.updatePosition = function () {
+ self.x = self.starX + Math.cos(self.angle) * self.radius;
+ self.y = self.starY + Math.sin(self.angle) * self.radius;
+ self.angle += self.angleSpeed * 0.35;
+ obstacleGraphics.rotation += self.angleSpeed * 0.35;
+ };
+ self.moveDown = function (distance, dotY) {
+ var speedMultiplier = dotY < 1200 ? 3 : dotY < 1400 ? 2 : dotY < 2000 ? 1.3 : 1.2;
+ self.starY += distance * speedMultiplier;
+ };
+ self.updatePosition();
+});
+var Dot = Container.expand(function () {
+ var self = Container.call(this);
+ var dotGraphics = self.attachAsset('dot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.destroyed = false;
+ self.velocityY = 0;
+ self.gravity = 0.7;
+ self.bounce = -15;
self.update = function () {
- duration--;
- self.y -= 2;
- self.alpha -= 1 / 120;
- if (duration <= 0) {
+ var previousY = self.y;
+ self.velocityY += self.gravity;
+ self.y += self.velocityY;
+ if (!self.firstTouch && !self.intersects(hand)) {
+ self.y = 2732 - self.height / 2 - 500;
+ } else if (self.intersects(hand)) {
+ self.bounceUp();
+ } else if (self.y > 2232 - self.height / 2 && self.firstTouch && !self.firstStarDestroyed) {
+ self.velocityY = self.bounce;
+ } else if (self.y > 2832 && !self.destroyed) {
+ createDotParticleEffect(self.x, self.y);
+ self.destroyed = true;
self.destroy();
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 1000);
}
+ self.movedDistance = self.y - previousY;
};
- game.addChild(self);
+ self.bounceUp = function () {
+ if (!self.destroyed) {
+ self.velocityY = self.bounce;
+ self.firstTouch = true;
+ if (!self.firstStarDestroyed) {
+ self.firstStarDestroyed = true;
+ }
+ }
+ };
});
-var ParticleEffect = Container.expand(function (x, y) {
+var DotParticleEffect = Container.expand(function (x, y) {
var self = Container.call(this);
self.x = x;
self.y = y;
var particles = [];
+ var angleIncrement = Math.PI * 2 / 20;
+ var speed = 30;
for (var i = 0; i < 20; i++) {
- var particle = self.attachAsset('star', {
+ var particle = self.attachAsset('dot', {
anchorX: 0.5,
anchorY: 0.5
});
- particle.scaleX = particle.scaleY = Math.random() * 0.5 + 0.5;
- particle.alpha = 0.7;
- particle.vx = (Math.random() - 0.5) * 10;
- particle.vy = (Math.random() - 0.5) * 10;
+ particle.scaleX = particle.scaleY = 0.5;
+ particle.alpha = 1;
+ var angle = i * angleIncrement;
+ particle.vx = Math.cos(angle) * speed;
+ particle.vy = Math.sin(angle) * speed;
particles.push(particle);
}
self.update = function () {
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].x += particles[i].vx;
particles[i].y += particles[i].vy;
- particles[i].alpha -= 0.02;
+ particles[i].alpha -= 0.0167;
if (particles[i].alpha <= 0) {
particles[i].destroy();
particles.splice(i, 1);
}
@@ -57,32 +98,84 @@
}
};
game.addChild(self);
});
-var DotParticleEffect = Container.expand(function (x, y) {
+// Add Hand asset below the dot
+var Hand = Container.expand(function () {
var self = Container.call(this);
+ var handGraphics = self.attachAsset('hand', {
+ anchorX: 0.5,
+ anchorY: 0,
+ alpha: 0.9
+ });
+ // Add 'TAP' text to the hand
+ var tapText = new Text2('Tap', {
+ size: 100,
+ fill: '#000000',
+ font: 'Arial',
+ fontWeight: 'normal',
+ anchorX: 0.5,
+ anchorY: 0.5,
+ dropShadow: true,
+ dropShadowColor: '#888888',
+ dropShadowBlur: 4,
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 6
+ });
+ tapText.x = -tapText.width / 2;
+ tapText.y = handGraphics.height / 2 - tapText.height / 2;
+ self.addChild(tapText);
+ self.update = function (distance) {
+ if (distance) {
+ self.y += distance;
+ }
+ };
+});
+var OrbitLine = Container.expand(function (starX, starY, radius) {
+ var self = Container.call(this);
+ self.starX = starX;
+ self.starY = starY;
+ self.radius = radius;
+ var segments = 50;
+ var angleIncrement = Math.PI * 2 / segments;
+ for (var i = 0; i < segments; i++) {
+ var angle = i * angleIncrement;
+ var dot = self.attachAsset('smallObstacle', {
+ x: starX + Math.cos(angle) * radius,
+ y: starY + Math.sin(angle) * radius,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ if (i % 2 === 0) {
+ dot.alpha = 0;
+ }
+ }
+ self.moveDown = function (distance, dotY) {
+ var speedMultiplier = dotY < 1200 ? 3 : dotY < 1400 ? 2 : dotY < 2000 ? 1.3 : dotY < 2300 ? 1.2 : 1;
+ self.y += distance * speedMultiplier;
+ };
+});
+var ParticleEffect = Container.expand(function (x, y) {
+ var self = Container.call(this);
self.x = x;
self.y = y;
var particles = [];
- var angleIncrement = Math.PI * 2 / 20;
- var speed = 30;
for (var i = 0; i < 20; i++) {
- var particle = self.attachAsset('dot', {
+ var particle = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
- particle.scaleX = particle.scaleY = 0.5;
- particle.alpha = 1;
- var angle = i * angleIncrement;
- particle.vx = Math.cos(angle) * speed;
- particle.vy = Math.sin(angle) * speed;
+ particle.scaleX = particle.scaleY = Math.random() * 0.5 + 0.5;
+ particle.alpha = 0.7;
+ particle.vx = (Math.random() - 0.5) * 10;
+ particle.vy = (Math.random() - 0.5) * 10;
particles.push(particle);
}
self.update = function () {
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].x += particles[i].vx;
particles[i].y += particles[i].vy;
- particles[i].alpha -= 0.0167;
+ particles[i].alpha -= 0.02;
if (particles[i].alpha <= 0) {
particles[i].destroy();
particles.splice(i, 1);
}
@@ -92,74 +185,33 @@
}
};
game.addChild(self);
});
-var Dot = Container.expand(function () {
+var ScorePopup = Container.expand(function (x, y) {
var self = Container.call(this);
- var dotGraphics = self.attachAsset('dot', {
+ self.x = x;
+ self.y = y;
+ var scoreText = new Text2('+1', {
+ size: 100,
+ fill: "#ffffff",
anchorX: 0.5,
anchorY: 0.5
});
- self.destroyed = false;
- self.velocityY = 0;
- self.gravity = 0.7;
- self.bounce = -15;
+ scoreText.x = -scoreText.width / 2;
+ scoreText.y = -scoreText.height / 2;
+ self.addChild(scoreText);
+ self.alpha = 1;
+ var duration = 120;
self.update = function () {
- var previousY = self.y;
- self.velocityY += self.gravity;
- self.y += self.velocityY;
- if (!self.firstTouch && !self.intersects(hand)) {
- self.y = 2732 - self.height / 2 - 500;
- } else if (self.intersects(hand)) {
- self.bounceUp();
- } else if (self.y > 2232 - self.height / 2 && self.firstTouch && !self.firstStarDestroyed) {
- self.velocityY = self.bounce;
- } else if (self.y > 2832 && !self.destroyed) {
- createDotParticleEffect(self.x, self.y);
- self.destroyed = true;
+ duration--;
+ self.y -= 2;
+ self.alpha -= 1 / 120;
+ if (duration <= 0) {
self.destroy();
- LK.setTimeout(function () {
- LK.showGameOver();
- }, 1000);
}
- self.movedDistance = self.y - previousY;
};
- self.bounceUp = function () {
- if (!self.destroyed) {
- self.velocityY = self.bounce;
- self.firstTouch = true;
- if (!self.firstStarDestroyed) {
- self.firstStarDestroyed = true;
- }
- }
- };
+ game.addChild(self);
});
-var CircularObstacle = Container.expand(function (starX, starY, radius, angleSpeed, initialAngle) {
- var self = Container.call(this);
- var obstacleGraphics = self.attachAsset('obstacle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.angle = initialAngle || 0;
- self.radius = radius;
- self.angleSpeed = angleSpeed * 0.75;
- self.starX = starX;
- self.starY = starY;
- self.updatePosition = function () {
- self.x = self.starX + Math.cos(self.angle) * self.radius;
- self.y = self.starY + Math.sin(self.angle) * self.radius;
- self.angle += self.angleSpeed * 0.35;
- obstacleGraphics.rotation += self.angleSpeed * 0.35;
- if (dot.firstTouch) {
- self.y += 1;
- }
- };
- self.moveDown = function (distance, dotY) {
- var speedMultiplier = dotY < 1200 ? 3 : dotY < 1400 ? 2 : dotY < 2000 ? 1.3 : 1.2;
- self.starY += distance * speedMultiplier;
- };
- self.updatePosition();
-});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
@@ -186,82 +238,21 @@
}
if (starGraphics.scale.x >= self.maxScale || starGraphics.scale.x <= self.minScale) {
self.scaleDirection *= -1;
}
- if (dot.firstTouch) {
- self.y += 1;
- }
};
});
-var OrbitLine = Container.expand(function (starX, starY, radius) {
- var self = Container.call(this);
- self.starX = starX;
- self.starY = starY;
- self.radius = radius;
- var segments = 50;
- var angleIncrement = Math.PI * 2 / segments;
- for (var i = 0; i < segments; i++) {
- var angle = i * angleIncrement;
- var dot = self.attachAsset('smallObstacle', {
- x: starX + Math.cos(angle) * radius,
- y: starY + Math.sin(angle) * radius,
- anchorX: 0.5,
- anchorY: 0.5
- });
- if (i % 2 === 0) {
- dot.alpha = 0;
- }
- }
- self.moveDown = function (distance, dotY) {
- var speedMultiplier = dotY < 1200 ? 3 : dotY < 1400 ? 2 : dotY < 2000 ? 1.3 : 1.2;
- self.y += distance * speedMultiplier;
- if (dot.firstTouch) {
- self.y += 1;
- }
- };
-});
-// Add Hand asset below the dot
-var Hand = Container.expand(function () {
- var self = Container.call(this);
- var handGraphics = self.attachAsset('hand', {
- anchorX: 0.5,
- anchorY: 0,
- alpha: 0.8
- });
- // Add 'TAP' text to the hand
- var tapText = new Text2('Tap', {
- size: 100,
- fill: '#000000',
- font: 'Arial',
- fontWeight: 'normal',
- anchorX: 0.5,
- anchorY: 0.5,
- dropShadow: true,
- dropShadowColor: '#888888',
- dropShadowBlur: 4,
- dropShadowAngle: Math.PI / 6,
- dropShadowDistance: 6
- });
- tapText.x = -tapText.width / 2;
- tapText.y = handGraphics.height / 2 - tapText.height / 2;
- self.addChild(tapText);
- self.update = function (distance) {
- if (distance) {
- self.y += distance;
- }
- };
-});
/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
-****/
+****/
// Initialize the offscreen threshold for destroying obstacles
var offscreenThreshold = 2732 + 1000;
function createParticleEffect(x, y) {
var effect = new ParticleEffect(x, y);
@@ -326,9 +317,9 @@
if (typeof obstacles[i].move === 'function') {
obstacles[i].move();
}
}
- if (dot.y < 2000 && dot.movedDistance < 0) {
+ if (dot.y < 2300 && dot.movedDistance < 0) {
obstacles[i].moveDown(-dot.movedDistance, dot.y);
}
if (dot.intersects(obstacles[i]) && !(obstacles[i] instanceof OrbitLine)) {
if (!dot.destroyed) {
@@ -395,20 +386,20 @@
}
// Add orbit line after creating all obstacles
var orbitLine = game.addChild(new OrbitLine(newStar.x, newStar.y, 300 + radiusOffset));
obstacles.push(orbitLine);
- } else if (dot.y < 2000 && dot.movedDistance < 0) {
+ } else if (dot.y < 2300 && dot.movedDistance < 0) {
stars[j].moveDown(-dot.movedDistance, dot.y);
}
}
});
var dot = game.addChild(new Dot());
dot.x = 2048 / 2;
-dot.y = 2732 - dot.height / 2 - 500;
+dot.y = 2732 - dot.height / 2 - 200;
var hand;
var handMoved = false;
function createHand() {
hand = game.addChild(new Hand());
hand.x = dot.x;
- hand.y = dot.y + dot.height / 2 + 10;
+ hand.y = dot.y + dot.height / 2;
}
createHand();
\ No newline at end of file