Code edit (4 edits merged)
Please save this source code
User prompt
If the dragon intersects with a CapturedBubble with an enemy, before destroying both please show a PoppedBobble sprite and then destroy it after 2 seconds
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
When a enemy is captured by a bubble, make the enemy and the CaptureBubble stop moving and get stuck at the place
Code edit (7 edits merged)
Please save this source code
User prompt
Do it
Code edit (4 edits merged)
Please save this source code
User prompt
Good, but the tint please should be light
User prompt
If it's enemy4, please add a random tint to the enemy
User prompt
No. Floors has floors at the left and right margin of the screen (see "Add continuous floor on the left / right margin"). You can't take those into account as floors at a specific height for enemy movement. Remove those.
User prompt
Change the way the enemies move. They need to start at the start of their platform, and end at the end. To calculate it, the start is the first X of any floor at that height. The end of the platform is the last X of any floor at that height. DOn't take into consideration the left and right floor margins.
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Sometimes when falling the dragon gets in a state for some seconds without a sprite. Fix it
Code edit (7 edits merged)
Please save this source code
User prompt
Do it
User prompt
This code makes the sprite flick. Removing the `destroy` works but then it keeps adding assets until it crashes. I want just to replace the assets, acn you please swap them? dragon.dragonGraphics.destroy(); dragon.dragonGraphics = dragon.attachAsset('dragonWithWings', { anchorX: 0.5, anchorY: 0.5 });
Code edit (3 edits merged)
Please save this source code
User prompt
Change the way jump and bubble shooting are triggered: - For bubble shooting, it's just if I click on the dragon - For jumping, it's if I click on a y position on the game that is higher than dragon.y
Code edit (1 edits merged)
Please save this source code
User prompt
Once an enemy has been captured by a CapturingBubble, they should move jump as the dragon jumps, but without falling set to true
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: enemy.contains is not a function' in or related to this line: 'if (enemy.contains(capturingBubble)) {' Line Number: 354
User prompt
Store the CapturingBubbles also in an array. If the dragon intersects a CapturingBubble, destroy the CapturingBubble and the Enemy.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Class for Bubbles var Bubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; self.update = function () { self.x += self.speed; // Check for intersection with any floor for (var i = 0; i < floors.length; i++) { if (self.intersects(floors[i])) { // Create a PoppedBubble at the bubble's position var pop = game.addChild(new PoppedBubble()); pop.x = self.x; pop.y = self.y; // Destroy the bubble self.destroy(); bubbles.splice(bubbles.indexOf(self), 1); // Destroy the PoppedBubble after 0.5 seconds LK.setTimeout(function () { pop.destroy(); }, 500); break; } } // Update last known positions self.lastX = self.x; self.lastY = self.y; }; }); var CapturingBubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('bubble', { anchorX: 0.5, anchorY: 0.5 }); self.alpha = 0.5; self.scaleX = 2; self.scaleY = 2; self.update = function () {}; }); //<Assets used in the game will automatically appear here> // Class for the Dragon character var Dragon = Container.expand(function () { var self = Container.call(this); self.dragonGraphics = self.attachAsset('dragon', { anchorX: 0.5, anchorY: 0.5 }); self.isIntersectingBubble = false; // Add a variable to track if the dragon is intersecting a bubble self.shootBubble = function () { var bubble = new Bubble(); bubble.x = self.x + 200 * self.scaleX; bubble.y = self.y - 5; // If the dragon is looking right, the bubble should move to the right if (self.scale.x == 1) { bubble.speed = 25; } else { // If the dragon is looking left, the bubble should move to the left bubble.speed = -25; } game.addChild(bubble); bubbles.push(bubble); }; }); // Class for Pop var PoppedBubble = Container.expand(function () { var self = Container.call(this); var popGraphics = self.attachAsset('poppedBubble', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) { return Array.from(r); } } function _arrayWithoutHoles(r) { if (Array.isArray(r)) { return _arrayLikeToArray(r); } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } var jumpStartTime; // Declare jumpStartTime to track the start of the jump var easingFunctions = [tween.linear, tween.easeIn, tween.easeOut, tween.easeInOut, tween.bounceIn, tween.bounceOut, tween.bounceInOut, tween.elasticIn, tween.elasticOut, tween.elasticInOut, tween.cubicIn, tween.cubicOut, tween.cubitInOut, tween.expoIn, tween.expoOut, tween.expoInOut, tween.sineIn, tween.sineOut, tween.sineInOut]; // Attach the background image to the game var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); background.tint = Math.floor(Math.random() * 16777215); game.addChild(background); function isStandingOnFloor() { for (var i = 0; i < floors.length; i++) { if (dragon.intersects(floors[i])) { return true; } } return false; } function updateFall() { if (isFalling) { dragon.y += 25; // Move dragon downwards faster // Check for intersection with any floor for (var i = 0; i < floors.length; i++) { // Check if dragon is landing on a floor if (!dragon.lastWasIntersecting && dragon.intersects(floors[i])) { isJumping = false; // Stop jumping isFalling = false; // Stop falling when colliding with a floor canJump = true; // Allow jumping again when the dragon hits a floor dragon.y = floors[i].y - floors[i].height * 1.5; // Align dragon to the top of the floor break; } } } // Update last known intersection state dragon.lastWasIntersecting = floors.some(function (floor) { return dragon.intersects(floor); }); } //<Assets used in the game will automatically appear here> // Handle mouse move events to move the dragon game.move = function (x, y, obj) { // Ignore the event if the target is outside the screen or close to its margins if (x > 150 && x < 2048 - 200) { // Set the target x position for the dragon dragon.targetX = x; } }; var isFalling = false; // Initialize isFalling to track dragon's fall state var dragon = game.addChild(new Dragon()); dragon.lastY = dragon.y; // Initialize lastY position dragon.x = 1024; // Center horizontally dragon.y = 2532; // Position the dragon on top of the floor var bubbles = []; var behaviours = {}; // Initialize behaviours object var enemies = []; var capturingBubbles = []; // Handle game updates game.update = function () { // Move dragon incrementally towards target x if (dragon.targetX !== undefined) { var increment = (dragon.targetX - dragon.x) / 10; // Move in 0.5 seconds assuming 60 FPS if (dragon.targetX !== undefined && (increment > 0 && dragon.x < dragon.targetX || increment < 0 && dragon.x > dragon.targetX)) { dragon.x += increment; } // Update last known position dragon.lastX = dragon.x; dragon.lastY = dragon.y; // Track lastY position // Adjust dragon's scale based on targetX position if (dragon.targetX < dragon.x) { dragon.scale.x = -1; } else { dragon.scale.x = 1; } } var standingOnFloor = isStandingOnFloor(); if (!standingOnFloor && !isJumping) { isFalling = true; } if (standingOnFloor && dragon.wings) { dragon.wings = false; dragon.removeChild(dragon.dragonGraphics); // Remove the current dragon graphics dragon.dragonGraphics = dragon.attachAsset('dragon', { anchorX: 0.5, anchorY: 0.5 }); dragon.addChild(dragon.dragonGraphics); } updateJump(); updateFall(); updateEnemiesMovement(); updateBubbles(); }; // Handle touch events for shooting bubbles var lastShot = 0; var lastClick = 0; var isJumping = false; // Add a variable to track if the dragon is jumping var canJump = true; // Initialize canJump flag to allow jumping game.down = function (x, y, obj) { var now = Date.now(); if (y < dragon.y - dragon.height && canJump) { isJumping = true; // Set isJumping to true when the dragon starts jumping jumpStartTime = Date.now(); // Initialize jump start time } else { if (now - lastClick > 500) { dragon.shootBubble(); lastShot = now; } } lastClick = now; }; function updateEnemiesMovement() { // Check if all enemies are moving and start their movement if not enemies.forEach(function (enemy) { if (enemy.captured && enemy.isMoving) { tween.stop(enemy); enemy.isMoving = false; enemy.floating = true; } else if (enemy.captured && enemy.floating) { enemy.y -= 1; } else if (!enemy.isMoving && !enemy.captured) { enemy.isMoving = true; // Set isMoving flag to true // Start enemy movement var platformFloors = floors.filter(function (floor) { return floor.y === enemy.y + 100 && floor.x > 0 && floor.x < 2048 - 50; }); var startX = Math.min.apply(Math, _toConsumableArray(platformFloors.map(function (floor) { return floor.x; }))); var endX = Math.max.apply(Math, _toConsumableArray(platformFloors.map(function (floor) { return floor.x; }))); tween(enemy, { x: endX }, { duration: Math.random() * 10000, easing: behaviours[enemy.type], onFinish: function onFinish() { tween(enemy, { x: startX }, { duration: 2000, easing: tween.linear, onFinish: function onFinish() { enemy.isMoving = false; // Reset isMoving flag } }); } }); } // Adjust enemy scale based on movement direction if (enemy.lastX < enemy.x) { enemy.scale.x = 1; // Moving right } else if (enemy.lastX > enemy.x) { enemy.scale.x = -1; // Moving left } // Update last known positions enemy.lastX = enemy.x; enemy.lastY = enemy.y; }); } function updateBubbles() { // Update bubbles for (var i = bubbles.length - 1; i >= 0; i--) { var bubble = bubbles[i]; if (!bubble) { continue; } // Check for bubble-bubble intersections for (var j = i - 1; j >= 0; j--) { var otherBubble = bubbles[j]; if (!otherBubble) { continue; } if (bubble.intersects(otherBubble)) { // Create a PoppedBubble for each intersecting bubble var pop1 = game.addChild(new PoppedBubble()); pop1.x = bubble.x; pop1.y = bubble.y; var pop2 = game.addChild(new PoppedBubble()); pop2.x = otherBubble.x; pop2.y = otherBubble.y; // Destroy both bubbles bubble.destroy(); otherBubble.destroy(); bubbles.splice(i, 1); bubbles.splice(j, 1); // Destroy the PoppedBubbles after 0.5 seconds LK.setTimeout(function () { pop1.destroy(); pop2.destroy(); }, 500); break; } } if (!bubble) { return; } if (bubble.y < -50) { bubble.destroy(); bubbles.splice(i, 1); } } // Check for bubble-enemy collisions for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; for (var j = bubbles.length - 1; j >= 0; j--) { var bubble = bubbles[j]; if (bubble.intersects(enemy)) { // Destroy the original bubble bubble.destroy(); bubbles.splice(j, 1); // Create a new bubble as a child of the enemy var newBubble = new CapturingBubble(); newBubble.x = 0; // Position relative to the enemy newBubble.y = 0; // Position relative to the enemy enemy.addChild(newBubble); enemy.captured = true; capturingBubbles.push(newBubble); break; } } } // Check if the dragon is intersecting a bubble for (var i = 0; i < bubbles.length; i++) { if (dragon.intersects(bubbles[i])) { // Create a PoppedBubble at the bubble's position var pop = game.addChild(new PoppedBubble()); pop.x = bubbles[i].x; pop.y = bubbles[i].y; // Destroy the bubble bubbles[i].destroy(); bubbles.splice(i, 1); // Destroy the PoppedBubble after 0.5 seconds LK.setTimeout(function () { pop.destroy(); }, 5000); break; } } // Check if the dragon is intersecting a CapturingBubble for (var i = capturingBubbles.length - 1; i >= 0; i--) { var capturingBubble = capturingBubbles[i]; if (dragon.intersects(capturingBubble)) { // Find and destroy the enemy that is the parent of the CapturingBubble for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (enemy.children.includes(capturingBubble)) { // Create a PoppedBubble at the capturingBubble's position var pop = game.addChild(new PoppedBubble()); pop.x = capturingBubble.x; pop.y = capturingBubble.y; // Destroy the enemy and capturingBubble enemy.destroy(); enemies.splice(j, 1); // Destroy the PoppedBubble after 2 seconds LK.setTimeout(function () { pop.destroy(); }, 2000); break; } } } } capturingBubbles.forEach(function (capturingBubble) { var enemy = capturingBubble.parent; if (enemy && !enemy.captured) { enemy.y -= 150; // Make the enemy jump with the dragon } }); } function updateJump() { if (isJumping) { if (!dragon.wings) { dragon.wings = true; dragon.removeChild(dragon.dragonGraphics); // Remove the current dragon graphics dragon.dragonGraphics = dragon.attachAsset('dragonWithWings', { anchorX: 0.5, anchorY: 0.5 }); dragon.addChild(dragon.dragonGraphics); // Add the new dragon graphics } dragon.y -= 15; // Move dragon upwards faster // Check for intersection with any floor for (var i = 0; i < floors.length; i++) { // Check if dragon is landing on a new floor if (!dragon.lastWasIntersecting && dragon.intersects(floors[i])) { isJumping = false; // Stop jumping isFalling = true; // Stop falling when colliding with a floor canJump = false; // Allow jumping again when the dragon hits a floor dragon.y -= 25; break; } } // Check if jump duration has exceeded 0.2 seconds if (Date.now() - jumpStartTime >= 200) { isJumping = false; isFalling = true; } } // Update last known intersection state dragon.lastWasIntersecting = floors.some(function (floor) { return dragon.intersects(floor); }); } // BLOCKS // Add a floor to the bottom of the screen var floors = []; for (var i = 0; i < 21; i++) { var floor = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: i * 100, y: 2732 - 30 }); game.addChild(floor); floors.push(floor); } // Add continuous floor on the left margin of the screen for (var j = 0; j < 27; j++) { var leftFloor = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: 0, y: j * 100 }); game.addChild(leftFloor); floors.push(leftFloor); } // Add continuous floor on the right margin of the screen for (var k = 0; k < 27; k++) { var rightFloor = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: 2048 - 50, y: k * 100 }); game.addChild(rightFloor); floors.push(rightFloor); } // Add random platforms with irregular heights and positions var platformYPositions = []; var distinctHeights = [2300, 1900, 1500, 1100, 700]; // Define 4-5 distinct heights var minPlatformLength = 5; var maxPlatformLength = 14; distinctHeights.forEach(function (height) { platformYPositions.push(height); }); // Add random platforms with irregular heights and positions for (var j = 0; j < platformYPositions.length; j++) { var _behaviours$enemyType; var platformLength = Math.floor(Math.random() * (maxPlatformLength - minPlatformLength + 1)) + minPlatformLength; var startX = Math.floor(Math.random() * (2048 - platformLength * 100)); // Random start position var startY = platformYPositions[j]; // Generate a random tint color for the platforms var randomTint = Math.floor(Math.random() * 16777215); for (var i = 0; i < platformLength; i++) { var newX = startX + i * 100; if (newX > 1900 || newX < 120) { continue; } var platform = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: startX + i * 100, y: platformYPositions[j] }); platform.tint = randomTint; // Apply the random tint to the platform game.addChild(platform); floors.push(platform); } // Spawn an enemy on top of each platform var enemyType = 'enemy' + (i % 5 + 1); // Cycle through enemy1 to enemy5 var behaviour = (_behaviours$enemyType = behaviours[enemyType]) !== null && _behaviours$enemyType !== void 0 ? _behaviours$enemyType : easingFunctions[Math.floor(Math.random() * easingFunctions.length)]; // Assign random easing function; behaviours[enemyType] = behaviour; var enemy = LK.getAsset(enemyType, { anchorX: 0.5, anchorY: 0.5, x: startX + 100, y: platformYPositions[j] - 100, type: enemyType }); if (enemyType === 'enemy5' || enemyType === 'enemy2') { enemy.tint = Math.floor(Math.random() * 0x7FFFFF) + 0x808080; // Ensure light tint } enemy.captured = false; game.addChild(enemy); enemies.push(enemy); }
===================================================================
--- original.js
+++ change.js
@@ -359,9 +359,9 @@
bubbles.splice(i, 1);
// Destroy the PoppedBubble after 0.5 seconds
LK.setTimeout(function () {
pop.destroy();
- }, 500);
+ }, 5000);
break;
}
}
// Check if the dragon is intersecting a CapturingBubble
A pixel slime, funny, looking right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
brick, brown color, pixel style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Draw wings to the dragon
better wings, pixel style, more contrasted, more visible, blue color
A pixel based enemy from the world of Bubble Bobble. It should be ghost-like. Make it very 80s 90s like in pixel, arcade style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A pixel based enemy from the world of Bubble Bobble. It should be blob like. Make it very 80s 90s like in pixel, arcade style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a pixel clouds background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a pixel clouds background, with mountains, full height full width Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a similar image. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a pixel clouds background, with mountains, full height full width Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows