Code edit (4 edits merged)
Please save this source code
User prompt
allow to define another x position for a wave spawn where the obstacles of that wave still keep the current shapw
User prompt
but make sure all obstacles of a wave keep their same random x positiion
User prompt
obstacle waves should spawn from different random x positions from outside the bottom of the screen
User prompt
have obstacles waves spawn in the center or either side of the bottom of the screen
User prompt
have obstacles waves move from one conrer of the screen to the other
User prompt
waves of enemys direction should be towards the dierr
User prompt
obstacle initial direction should be towards diver
Code edit (1 edits merged)
Please save this source code
User prompt
obstacles direction should be towards the player
Code edit (1 edits merged)
Please save this source code
User prompt
obstacle.x should be the same for the obstacles shape
User prompt
make obstacle.x position random to any position of the bottom of the screen
Code edit (15 edits merged)
Please save this source code
User prompt
Update spawnwave to starts waves from the bottom right or bottom left and move in obliquos direcio towards the player
User prompt
Spawm waves from the bottom roght corner an iniitial directio should be the divers location
User prompt
Enemies waves can also spanw from the bottom corners and move towars the player
User prompt
Enemies can spawn also from.the bottom corners. It should be random
User prompt
add a collisionbox to the diver
User prompt
reduce downward speed of power ups 20%
User prompt
make sure flippers are attached to player
User prompt
add a collisionbox in the player
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
move flippers 100 pixels up
===================================================================
--- original.js
+++ change.js
@@ -121,9 +121,13 @@
scaleX: 0.7,
scaleY: 0.7
});
// Set obstacle1 speed
- self.speed = -5;
+ var dx = diver.x - self.x;
+ var dy = diver.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ self.speedX = dx / distance * 5;
+ self.speedY = dy / distance * 5;
// This is automatically called every game tick, if the obstacle1 is attached!
self.update = function () {
// Check if the obstacle is colliding with the shield
if (self.intersects(shield, {
@@ -173,9 +177,10 @@
}
spatialHash[newHashKey].push(self);
}
// Continue moving upwards
- self.y += self.speed * speedMultiplier;
+ self.x += self.speedX * speedMultiplier;
+ self.y += self.speedY * speedMultiplier;
self.rotation += 0.01; // Add small rotation to the obstacle
// Add size change to the obstacle
self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
self.scale.y = 1 + Math.sin(LK.ticks / 10) * 0.02;
@@ -213,9 +218,13 @@
scaleX: 0.7,
scaleY: 0.7
});
// Set obstacle2 speed
- self.speed = -5;
+ var dx = diver.x - self.x;
+ var dy = diver.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ self.speedX = dx / distance * 5;
+ self.speedY = dy / distance * 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, {
@@ -265,9 +274,10 @@
}
spatialHash[newHashKey].push(self);
}
// Continue moving upwards
- self.y += self.speed * speedMultiplier;
+ self.x += self.speedX * speedMultiplier;
+ self.y += self.speedY * speedMultiplier;
// Add wiggly movement to the obstacle
self.x += Math.sin(LK.ticks / 10) * 2;
// Add size change to the obstacle
self.scale.x = 1 + Math.sin(LK.ticks / 10) * 0.02;
@@ -306,9 +316,13 @@
scaleX: 0.7,
scaleY: 0.7
});
// Set obstacle3 speed
- self.speed = -5;
+ var dx = diver.x - self.x;
+ var dy = diver.y - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ self.speedX = dx / distance * 5;
+ self.speedY = dy / distance * 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, {
@@ -358,9 +372,10 @@
}
spatialHash[newHashKey].push(self);
}
// Continue moving upwards
- self.y += self.speed * speedMultiplier;
+ self.x += self.speedX * speedMultiplier;
+ self.y += self.speedY * speedMultiplier;
// 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;
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.