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
@@ -219,8 +219,70 @@
}
}
};
});
+// Obstacle3 class
+var Obstacle3 = Container.expand(function () {
+ var self = Container.call(this);
+ var obstacle3Graphics = self.attachAsset('obstacle3', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set obstacle3 speed
+ self.speed = -5;
+ // This is automatically called every game tick, if the obstacle3 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;
+ // Add unique behavior to obstacle3
+ self.rotation += 0.05; // Rotate faster than obstacle1
+ self.scale.x = 1 + Math.sin(LK.ticks / 5) * 0.05; // Larger size change
+ self.scale.y = 1 + Math.sin(LK.ticks / 5) * 0.05;
+ 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;
+ }
+ }
+ };
+});
// Shield class
var Shield = Container.expand(function () {
var self = Container.call(this);
var shieldGraphics = self.attachAsset('shield', {
@@ -380,9 +442,10 @@
console.error('Error: layoutPositions is undefined. Check the layout variable and the positions object.');
return;
}
// Randomly choose an obstacle type for the entire wave
- var obstacleType = Math.random() < 0.5 ? Obstacle1 : Obstacle2;
+ var obstacleTypes = [Obstacle1, Obstacle2, Obstacle3];
+ var obstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
for (var i = 0; i < layoutPositions.length; i++) {
var obstacle = game.addChild(new obstacleType());
// Position the obstacles according to the layout, using the grid for positioning
obstacle.x = 2048 / 2 + (layoutPositions[i].x - gridSize / 2) * cellSize;
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.