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
User prompt
mmove player 100 pixels down
User prompt
make collision bos smaller
User prompt
move diver 200 pixels down
User prompt
collision box should not affect the size of the diver
Code edit (1 edits merged)
Please save this source code
User prompt
move player 200 pixels up
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'rightFlipper.x = 30;' Line Number: 115
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'rightFlipper.x = 30;' Line Number: 115
User prompt
mvoe flippers closer to player
User prompt
move player 100 pixels up
Code edit (10 edits merged)
Please save this source code
User prompt
move collsionbox anchor on player a little down
User prompt
powerup should also collide with playercollisionbox
===================================================================
--- original.js
+++ change.js
@@ -89,8 +89,29 @@
var rightFlipper = self.addChild(new Flipper());
rightFlipper.x = 60;
rightFlipper.depth = -1;
});
+var EnemyWave = Container.expand(function () {
+ var self = Container.call(this);
+ self.enemies = [];
+ self.spawnEnemy = function (x, y) {
+ var enemy = new Obstacle1(); // You can change this to any obstacle type
+ enemy.x = x;
+ enemy.y = y;
+ self.enemies.push(enemy);
+ game.addChild(enemy);
+ };
+ self.update = function () {
+ for (var i = self.enemies.length - 1; i >= 0; i--) {
+ var enemy = self.enemies[i];
+ enemy.y -= 2; // Move enemy upwards
+ if (enemy.y < 0) {
+ enemy.destroy();
+ self.enemies.splice(i, 1);
+ }
+ }
+ };
+});
// Flipper class
var Flipper = Container.expand(function () {
var self = Container.call(this);
var flipperGraphics = self.attachAsset('flippers', {
@@ -459,8 +480,16 @@
/****
* Game Code
****/
+var enemyWave = new EnemyWave();
+game.addChild(enemyWave);
+function spawnEnemyWave() {
+ enemyWave.spawnEnemy(0, 2732); // Bottom-left corner
+ enemyWave.spawnEnemy(2048, 2732); // Bottom-right corner
+ LK.setTimeout(spawnEnemyWave, 20000); // Spawn every 20 seconds
+}
+LK.setTimeout(spawnEnemyWave, 20000); // Initial call to spawn the first wave
// Function to spawn power-ups every 20 seconds
function spawnPowerUp() {
if (!firstPowerUpSpawned) {
if (LK.ticks < 300) {
@@ -592,8 +621,10 @@
// Update bubbles
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].update();
}
+// Update enemy waves
+enemyWave.update();
// Define the current wave
var currentWave = 0;
var allWavesSpawnedOnce = false;
// Spawn wave function
@@ -651,16 +682,10 @@
var obstacleTypes = [Obstacle1, Obstacle2, Obstacle3];
var obstacleType = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
layoutPositions.forEach(function (position) {
var obstacle = game.addChild(new obstacleType());
- // Randomly decide if the obstacle should spawn from the bottom corners
- if (Math.random() < 0.5) {
- // Spawn from the left bottom corner
- obstacle.x = Math.random() * (2048 / 2);
- } else {
- // Spawn from the right bottom corner
- obstacle.x = 2048 / 2 + Math.random() * (2048 / 2);
- }
+ // Position the obstacles according to the layout, using the grid for positioning
+ obstacle.x = 2048 / 2 + (position.x - gridSize / 2) * cellSize;
obstacle.y = 2732 + position.y * cellSize; // Spawn obstacles offscreen at the bottom
obstacles.push(obstacle);
});
currentWave++;
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.