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
obstacles should only move when dot y is smaller than 1400
User prompt
obstacles should only move down when dot y is smaller than 1400. they should always move sideways
Code edit (4 edits merged)
Please save this source code
User prompt
obstacles should have 1000 pixles y from each other as space
User prompt
when an obstacle is repositiones it should also have 1000 pixels y distance from others
User prompt
obstacles should increse and decrease their width constantly
User prompt
every new spawned or repositioned obstacle should be 1000 pixels higher thanthe higher obstacle
User prompt
obstacles should have different widths and different speeds and oscilations randmonly
User prompt
obstacles should only move when dot y is smaller than 1400
User prompt
obstacles should spawn randmonly from either side of the screen and moveon the opposite side direction
User prompt
obstacles should have random speed but never slower than the current speed
User prompt
add start asset. stars will spawn in the center of the screen every 2000 pixels y
User prompt
star should spawn in the center of the screen
User prompt
dot should spawn in the bottom of the screen
User prompt
star should have the same y moments downwards like the obstacles
User prompt
add particles effect when dot collides with obstacle
User prompt
after dot collides with obstacle wait for 1.5 seconds before game ovevr
User prompt
obstacles should spawn in the center of the screen and move in the shape of a square
User prompt
dot particles should have an explosion pattern
User prompt
remove flash on game over
User prompt
obstacles should start spawnning from the middle of the screen and upwards
Code edit (2 edits merged)
Please save this source code
User prompt
create a new bigobstacle. should behave the sameway as obstacles towards the dot
User prompt
bigobstacle should spawn in the center of x axis and not move sideways
===================================================================
--- original.js
+++ change.js
@@ -45,8 +45,34 @@
self.y = -self.height / 2;
}
};
});
+var BigObstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var bigObstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ // Scale horizontally by 2
+ scaleY: 2 // Scale vertically by 2
+ });
+ 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
****/
@@ -60,14 +86,18 @@
var dot = game.addChild(new Dot());
dot.x = 2048 / 2;
dot.y = 2732 / 2;
var obstacles = [];
-for (var i = 0; i < 5; i++) {
+for (var i = 0; i < 4; 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 bigObstacle = game.addChild(new BigObstacle());
+bigObstacle.x = bigObstacle.direction === 1 ? -bigObstacle.width / 2 : 2048 + bigObstacle.width / 2;
+bigObstacle.y = Math.random() * (1366 - bigObstacle.height) + bigObstacle.height / 2;
+obstacles.push(bigObstacle);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});