Code edit (4 edits merged)
Please save this source code
User prompt
obstacles should start spawnning from the middle of the screen and upwards
User prompt
remove flash on game over
User prompt
dot particles should have an explosion pattern
User prompt
obstacles should spawn in the center of the screen and move in the shape of a square
User prompt
after dot collides with obstacle wait for 1.5 seconds before game ovevr
User prompt
add particles effect when dot collides with obstacle
User prompt
star should have the same y moments downwards like the obstacles
User prompt
dot should spawn in the bottom of the screen
User prompt
star should spawn in the center of the screen
User prompt
add start asset. stars will spawn in the center of the screen every 2000 pixels y
User prompt
obstacles should have random speed but never slower than the current speed
User prompt
obstacles should spawn randmonly from either side of the screen and moveon the opposite side direction
User prompt
obstacles should only move when dot y is smaller than 1400
User prompt
obstacles should have different widths and different speeds and oscilations randmonly
User prompt
every new spawned or repositioned obstacle should be 1000 pixels higher thanthe higher obstacle
User prompt
obstacles should increse and decrease their width constantly
User prompt
when an obstacle is repositiones it should also have 1000 pixels y distance from others
User prompt
obstacles should have 1000 pixles y from each other as space
Code edit (1 edits merged)
Please save this source code
User prompt
obstacles should only move down when dot y is smaller than 1400. they should always move sideways
User prompt
obstacles should only move when dot y is smaller than 1400
User prompt
when dot moves up on the top part of the screen, the obstacle should move down the same distancethe dot does
User prompt
obstacle vertical speed should increase if dotsspeed incresase
User prompt
when the dot bounces and its bouncing on the top half of thescreen then obstacle should move downwards generating a sense of screen scrolling upwards
/**** * Classes ****/ var Dot = Container.expand(function () { var self = Container.call(this); var dotGraphics = self.attachAsset('dot', { anchorX: 0.5, anchorY: 0.5 }); self.velocityY = 0; self.gravity = 0.5; self.bounce = -15; self.update = function () { var previousY = self.y; self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > 2732 - self.height / 2) { self.velocityY = self.bounce; } self.movedDistance = self.y - previousY; }; self.bounceUp = function () { self.velocityY = self.bounce; }; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.direction = Math.random() < 0.5 ? -1 : 1; self.speed = (Math.random() * 3 + 5) * self.direction; self.move = function () { self.x += self.speed; if (self.direction === 1 && self.x > 2048 + self.width / 2 || self.direction === -1 && self.x < -self.width / 2) { self.direction *= -1; self.speed *= -1; self.y = Math.random() * (2732 - self.height) + self.height / 2; } }; self.moveDown = function (distance) { self.y += distance; if (self.y > 2732 - self.height / 2) { self.y = -self.height / 2; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var dot = game.addChild(new Dot()); dot.x = 2048 / 2; dot.y = 2732 / 2; var obstacles = []; for (var i = 0; i < 5; i++) { var obstacle = game.addChild(new Obstacle()); obstacle.x = obstacle.direction === 1 ? -obstacle.width / 2 : 2048 + obstacle.width / 2; obstacle.y = Math.random() * (1366 - obstacle.height) + obstacle.height / 2; obstacles.push(obstacle); } var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); scoreTxt.x = 2048 / 2; scoreTxt.y = 50; LK.gui.top.addChild(scoreTxt); game.on('down', function (obj) { dot.bounceUp(); }); LK.on('tick', function () { dot.update(); for (var i = 0; i < obstacles.length; i++) { obstacles[i].move(); if (dot.y < 900 && dot.movedDistance < 0) { // If the dot moved up and its y position is less than 1400 obstacles[i].moveDown(-dot.movedDistance); } if (dot.intersects(obstacles[i])) { LK.showGameOver(); } } // Update score based on the dot's survival time var currentScore = Math.floor(LK.ticks / 60); LK.setScore(currentScore); scoreTxt.setText(LK.getScore().toString()); });
===================================================================
--- original.js
+++ change.js
@@ -81,9 +81,9 @@
LK.on('tick', function () {
dot.update();
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].move();
- if (dot.y < 1800 && dot.movedDistance < 0) {
+ if (dot.y < 900 && dot.movedDistance < 0) {
// If the dot moved up and its y position is less than 1400
obstacles[i].moveDown(-dot.movedDistance);
}
if (dot.intersects(obstacles[i])) {