User prompt
From the score text, replace only the ''Depth'' part of the text for the Depth asset. However keep the '':'' and the actual meters that update.
User prompt
add five more waves
User prompt
add one second more between waves
User prompt
wave 4 should have more of the outline of a circle shape. empty center
User prompt
mvoe right flipper 20 piels right
User prompt
add obstacle3.
User prompt
obsctalce2 shoudl increase and decrease their size
User prompt
waves can nrandomly have any obstacle. but one wave will have all obstacles the same
User prompt
create obstacle2. this obstacles will not rotate but have a wiggly movement
User prompt
create 5 assets that will be used randomly in obstacles waves
User prompt
add an extra second between waves
User prompt
make fourth wave easier
User prompt
add a little more time btween waves
User prompt
add inerval of wait between waves
User prompt
do not wait fro obstacles to be destroyed before spawning next wave
User prompt
make waves spawn faster
User prompt
Please fix the bug: 'Timeout.tick error: scoreText.setText is not a function' in or related to this line: 'scoreText.setText('Depth: ' + score + 'm');' Line Number: 248
User prompt
replace only the text piece of scoretext that says Depth for the depth asset.
User prompt
show meters next to depth
User prompt
Please fix the bug: 'Timeout.tick error: scoreText.setText is not a function' in or related to this line: 'scoreText.setText('Depth: ' + score + 'm');' Line Number: 248
User prompt
replace Depth: text for depth asset
User prompt
add a previous wave that will only have 2 obstacles
User prompt
add 5 more waves of obstacles
User prompt
make depth text black
User prompt
make obstacles repel each other more and always to the outside
===================================================================
--- original.js
+++ change.js
@@ -156,192 +156,68 @@
}
}
};
});
+// Obstacle2 class
var Obstacle2 = Container.expand(function () {
var self = Container.call(this);
var obstacle2Graphics = self.attachAsset('obstacle2', {
anchorX: 0.5,
anchorY: 0.5
});
+ // Set obstacle2 speed
self.speed = -5;
+ // This is automatically called every game tick, if the obstacle2 is attached!
self.update = function () {
+ // Check if the obstacle is colliding with the shield
if (self.intersects(shield)) {
+ // Calculate the direction vector between the shield and the obstacle
var dx = self.x - shield.x;
var dy = self.y - shield.y;
var distance = Math.sqrt(dx * dx + dy * dy);
+ // Normalize the direction vector
dx /= distance;
dy /= distance;
+ // Push the obstacle away from the shield
self.x += dx * 5;
self.y += dy * 5;
}
+ // Check for collision with diver
if (self.intersects(diver)) {
+ // Flash screen red for 1 second (1000ms) to show game over
LK.effects.flashScreen(0xff0000, 1000);
+ // Show game over. The game will be automatically paused while game over is showing.
LK.showGameOver();
}
+ // Continue moving upwards
self.y += self.speed;
- self.rotation += 0.01;
- self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
- self.scale.y = 1 + Math.sin(LK.ticks / 10) * 0.02;
+ // Add wiggly movement to the obstacle
+ self.x += Math.sin(LK.ticks / 10) * 2;
if (self.y < 0) {
self.destroy();
var index = obstacles.indexOf(self);
if (index > -1) {
obstacles.splice(index, 1);
}
}
+ // Check if the obstacle is colliding with another obstacle
for (var i = 0; i < obstacles.length; i++) {
var otherObstacle = obstacles[i];
if (self !== otherObstacle && self.intersects(otherObstacle)) {
+ // Calculate the direction vector between the two obstacles
var dx = self.x - otherObstacle.x;
var dy = self.y - otherObstacle.y;
var distance = Math.sqrt(dx * dx + dy * dy);
+ // Normalize the direction vector
dx /= distance;
dy /= distance;
+ // Increase the repulsion force and always push the obstacle to the outside
self.x += dx * 10;
self.y += dy * 10;
}
}
};
});
-var Obstacle3 = Container.expand(function () {
- var self = Container.call(this);
- var obstacle3Graphics = self.attachAsset('obstacle3', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -5;
- self.update = function () {
- if (self.intersects(shield)) {
- var dx = self.x - shield.x;
- var dy = self.y - shield.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 5;
- self.y += dy * 5;
- }
- if (self.intersects(diver)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- self.y += self.speed;
- self.rotation += 0.01;
- self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
- self.scale.y = 1 + Math.sin(LK.ticks / 10) * 0.02;
- if (self.y < 0) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- for (var i = 0; i < obstacles.length; i++) {
- var otherObstacle = obstacles[i];
- if (self !== otherObstacle && self.intersects(otherObstacle)) {
- var dx = self.x - otherObstacle.x;
- var dy = self.y - otherObstacle.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 10;
- self.y += dy * 10;
- }
- }
- };
-});
-var Obstacle4 = Container.expand(function () {
- var self = Container.call(this);
- var obstacle4Graphics = self.attachAsset('obstacle4', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -5;
- self.update = function () {
- if (self.intersects(shield)) {
- var dx = self.x - shield.x;
- var dy = self.y - shield.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 5;
- self.y += dy * 5;
- }
- if (self.intersects(diver)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- self.y += self.speed;
- self.rotation += 0.01;
- self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
- self.scale.y = 1 + Math.sin(LK.ticks / 10) * 0.02;
- if (self.y < 0) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- for (var i = 0; i < obstacles.length; i++) {
- var otherObstacle = obstacles[i];
- if (self !== otherObstacle && self.intersects(otherObstacle)) {
- var dx = self.x - otherObstacle.x;
- var dy = self.y - otherObstacle.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 10;
- self.y += dy * 10;
- }
- }
- };
-});
-var Obstacle5 = Container.expand(function () {
- var self = Container.call(this);
- var obstacle5Graphics = self.attachAsset('obstacle5', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -5;
- self.update = function () {
- if (self.intersects(shield)) {
- var dx = self.x - shield.x;
- var dy = self.y - shield.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 5;
- self.y += dy * 5;
- }
- if (self.intersects(diver)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- self.y += self.speed;
- self.rotation += 0.01;
- self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
- self.scale.y = 1 + Math.sin(LK.ticks / 10) * 0.02;
- if (self.y < 0) {
- self.destroy();
- var index = obstacles.indexOf(self);
- if (index > -1) {
- obstacles.splice(index, 1);
- }
- }
- for (var i = 0; i < obstacles.length; i++) {
- var otherObstacle = obstacles[i];
- if (self !== otherObstacle && self.intersects(otherObstacle)) {
- var dx = self.x - otherObstacle.x;
- var dy = self.y - otherObstacle.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- dx /= distance;
- dy /= distance;
- self.x += dx * 10;
- self.y += dy * 10;
- }
- }
- };
-});
// Shield class
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
@@ -501,10 +377,14 @@
console.error('Error: layoutPositions is undefined. Check the layout variable and the positions object.');
return;
}
for (var i = 0; i < layoutPositions.length; i++) {
- var obstacleClass = [Obstacle1, Obstacle2, Obstacle3, Obstacle4, Obstacle5][Math.floor(Math.random() * 5)];
- var obstacle = game.addChild(new obstacleClass());
+ var obstacle;
+ if (currentWave % 2 === 0) {
+ obstacle = game.addChild(new Obstacle1());
+ } else {
+ obstacle = game.addChild(new Obstacle2());
+ }
// Position the obstacles according to the layout, using the grid for positioning
obstacle.x = 2048 / 2 + (layoutPositions[i].x - gridSize / 2) * cellSize;
obstacle.y = 2732 + layoutPositions[i].y * cellSize; // Spawn obstacles offscreen at the bottom
obstacles.push(obstacle);
8bit. cartoon. jellyfish.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
empty 8 bit cartoon white circle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon. 8-bit. octopus. colorful.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon. 8-bit. sea urchin. colorful. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon 8bit stingray. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.