User prompt
Add lava that starts on the floor and starts movign upwarda
User prompt
Obstacles should always have 500 pixels y betweem each other
Code edit (1 edits merged)
Please save this source code
User prompt
Obstacles can spawn from either side randmonly and move on the oposite side direction
User prompt
Obstacles can spawn or be repositioned on the other side of the screen and move from elft to right
User prompt
Obstacles shoild always spawn and be repositioned from the center to the top of the screen
User prompt
Dot should bounce on top of obstacles
User prompt
If dot interects with side of obatacel then game voer
User prompt
If dot is on top of obstacle the its not game over
User prompt
If dot intersects with top of obstacle, then it is not game over and dot stays still until tap again and self.bounce again
Code edit (1 edits merged)
Please save this source code
User prompt
Slow spawn time of next obatacle
User prompt
Obstacles should resposition as stairs steps to keep the initial atair shape continuous
User prompt
Obstacles should spawn in the shape of a staircase
User prompt
Create a new class called stairs. Stairs will be continuos steps thar will spawn fromt he right of rhe acreen and move.to the left
User prompt
Obstaclea should start spawning from y = 1400 or lowe
User prompt
Dot should spawn at y = 2000
User prompt
Obstacles should spawn and be repositioned always over y = 1400
Code edit (2 edits merged)
Please save this source code
User prompt
If ball interects with top of a obstacle is should roll on top of it
User prompt
Obstacles shouls spawn one at a time
User prompt
First obstacle should spawn in the bottom of the screen and next ones should always have a stair patter even when repositioned
Code edit (1 edits merged)
Please save this source code
User prompt
First obstacle should spawn in y = 2800
User prompt
Obstacles should spawn forming a stair
/**** * 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 () { self.velocityY += self.gravity; self.y += self.velocityY; if (self.y > 2732 - self.height / 2) { self.velocityY = self.bounce; } }; 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 = 5 * self.direction; self.move = function (offsetY) { 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.x = self.direction === 1 ? -self.width / 2 : 2048 + self.width / 2; self.y = Math.random() * (1332 - self.height) + self.height / 2; } if (offsetY) { self.y += offsetY; } }; }); var Lava = Container.expand(function () { var self = Container.call(this); var lavaGraphics = self.attachAsset('lava', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 1; self.move = function () { self.y -= self.speed; }; }); /**** * 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 < 15; i++) { var obstacle = game.addChild(new Obstacle()); obstacle.direction = Math.random() < 0.5 ? -1 : 1; obstacle.x = obstacle.direction === 1 ? -i * 450 : 2048 + i * 450; obstacle.y = i * 500 + obstacle.height / 2; obstacles.push(obstacle); } var lava = game.addChild(new Lava()); lava.x = 2048 / 2; lava.y = 2732 - lava.height / 2; 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 () { var previousY = dot.y; dot.update(); var offsetY = previousY - dot.y; for (var i = 0; i < obstacles.length; i++) { obstacles[i].move(dot.y < 1400 && offsetY > 0 ? offsetY : 0); if (dot.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update score based on the dot's survival time lava.move(); if (dot.intersects(lava)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } var currentScore = Math.floor(LK.ticks / 60); LK.setScore(currentScore); scoreTxt.setText(LK.getScore().toString()); });
===================================================================
--- original.js
+++ change.js
@@ -41,8 +41,19 @@
self.y += offsetY;
}
};
});
+var Lava = Container.expand(function () {
+ var self = Container.call(this);
+ var lavaGraphics = self.attachAsset('lava', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 1;
+ self.move = function () {
+ self.y -= self.speed;
+ };
+});
/****
* Initialize Game
****/
@@ -63,8 +74,11 @@
obstacle.x = obstacle.direction === 1 ? -i * 450 : 2048 + i * 450;
obstacle.y = i * 500 + obstacle.height / 2;
obstacles.push(obstacle);
}
+var lava = game.addChild(new Lava());
+lava.x = 2048 / 2;
+lava.y = 2732 - lava.height / 2;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -86,8 +100,13 @@
LK.showGameOver();
}
}
// Update score based on the dot's survival time
+ lava.move();
+ if (dot.intersects(lava)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
var currentScore = Math.floor(LK.ticks / 60);
LK.setScore(currentScore);
scoreTxt.setText(LK.getScore().toString());
});
\ No newline at end of file