User prompt
reduce size of obstacles by 30%
Code edit (9 edits merged)
Please save this source code
User prompt
move depth asset and text 500 pixels right
User prompt
reduce size of depth asset and depth text in 30%
User prompt
reduce size of diver and flippers in 30%
User prompt
remove borders from font on depht text and make text blak
Code edit (1 edits merged)
Please save this source code
User prompt
move depthe text 100 pixels up
User prompt
move depth asset 50 pixels down
User prompt
move depth text 50 pixels down
User prompt
move dpeth asset 200 pixels to the left
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
===================================================================
--- 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.