Code edit (1 edits merged)
Please save this source code
User prompt
You need to check always if the dragon isStandingOnFloor. If not, please make it fall
Code edit (1 edits merged)
Please save this source code
User prompt
Don't shoot a bubble until you are sure the click is not a double click and therefore, a jump
Code edit (9 edits merged)
Please save this source code
User prompt
Make the jump last for 0.2 sec only
User prompt
Make the jump and fall speed quicker
Code edit (3 edits merged)
Please save this source code
User prompt
No. Redo completely the updateFall and updateJump logic. What I need: - Double clicking makes the dragon jump (go up) for 1 second or until it hits a floor it was not hitting before. After, it enters in isFalling = true mode. - When falling, the dragon should go down indifinitely until it finds a floor.
User prompt
The dragon just moves up forever, never falls, when I click on jump
User prompt
Please make sure that when I double click and the dragon starts to jump, that the jump takes either 1 second or until it hits a floor that it was not hitting before
User prompt
Please, fix that when I click on jump, the dragon jumps, I see the "intersecting" but the dragon keeps moving up and does not fall to the ground
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
dragon.y = floors[i].y - floors[i].height / 2; // Align dragon's position to the top of the floor This is making my dragon stuck on the middle of a floor brick, it should be on the top
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
For some reason I fucked it up and the dragon when falling does not stand still on top of a floor and continues its movement down. Please fix it - a falling dragon should stop always if in its way down it finds a floor
Code edit (10 edits merged)
Please save this source code
User prompt
Ok. Now what I want you to do is the following: - While you are jumping, please detect if the dragon intersects with a platform (not a floor, a platform). If so, make isFalling = true, isJumping=false, and create a flag called "canJump" that will set to false until the dragon hits a floor.
Code edit (8 edits merged)
Please save this source code
User prompt
Before this loop, please generate a random tint color and apply it to all the platforms inside that loop: for (var i = 0; i < platformLength; i++) { var newX = startX + i * 100; if (newX > 2000 || newX < 100) { continue; } var platform = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: startX + i * 100, y: platformYPositions[j] }); game.addChild(platform); floors.push(platform); }
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
You can't have overlapping platforms! You still create them on the same height !
/**** * 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; }; }); //<Assets used in the game will automatically appear here> // Class for the Dragon character var Dragon = Container.expand(function () { var self = Container.call(this); var 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 = 10; } else { // If the dragon is looking left, the bubble should move to the left bubble.speed = -10; } 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 ****/ var easingFunctions = [tween.linear, tween.easeIn, tween.easeOut, tween.easeInOut, tween.bounceIn, tween.elasticInOut]; // 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 startDragonFall() { isFalling = true; } function updateFall() { if (isFalling || !isStandingOnFloor()) { dragon.y += 10; // Adjust fall speed as needed // Check for intersection with any floor for (var i = 0; i < floors.length; i++) { if (dragon.intersects(floors[i])) { isJumping = false; // Stop jumping isFalling = false; // Stop falling when colliding with a floor dragon.y -= floors[i].height / 8; dragon.targetX = undefined; // Reset targetX to allow movement after landing break; } } } } //<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 = 2732 - 50 - dragon.height / 2; // Position the dragon on top of the floor var bubbles = []; var enemies = []; enemies.forEach(function (enemy) { enemy.isMoving = false; // Initialize isMoving flag to false }); var floors = []; // 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 (!isJumping && 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 x position if (dragon.targetX > 1024) { dragon.scale.x = -1; } else { dragon.scale.x = 1; } } 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 game.down = function (x, y, obj) { var now = Date.now(); if (now - lastShot > 500) { dragon.shootBubble(); lastShot = now; } if (now - lastClick < 200 && (!isJumping && !isFalling || dragon.isIntersectingBubble)) { // Only allow the dragon to jump if it is not already jumping or if it is intersecting a bubble // Check if the jump trajectory is clear of floors var canJump = true; if (canJump) { isJumping = true; // Set isJumping to true when the dragon starts jumping // Make the dragon jump using a smooth animation tween(dragon, { y: dragon.y - 200 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { isJumping = false; // Reset jumping state after the jump // Start dragon fall after jump startDragonFall(); } }); } // If the dragon is intersecting a bubble, show the pop asset before destroying the bubble if (dragon.isIntersectingBubble) { for (var i = 0; i < bubbles.length; i++) { if (dragon.intersects(bubbles[i])) { var pop = game.addChild(new PoppedBubble()); pop.x = bubbles[i].x; pop.y = bubbles[i].y; bubbles[i].destroy(); bubbles.splice(i, 1); LK.setTimeout(function () { pop.destroy(); }, 500); break; } } } } lastClick = now; }; // Add random platforms with irregular heights and positions for (var j = 0; j < platformYPositions.length; j++) { var platformLength = Math.floor(Math.random() * (maxPlatformLength - minPlatformLength + 1)) + minPlatformLength; var startX = Math.floor(Math.random() * (2048 - platformLength * 100)); // Random start position for (var i = 0; i < platformLength; i++) { var platform = LK.getAsset('floor', { anchorX: 0.5, anchorY: 0.5, x: startX + i * 100, y: platformYPositions[j] }); 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 enemy = LK.getAsset(enemyType, { anchorX: 0.5, anchorY: 0.5, x: startX + 100, y: platformYPositions[j] - 100 // Position enemy on top of the platform }); game.addChild(enemy); enemies.push(enemy); } function updateEnemiesMovement() { // Check if all enemies are moving and start their movement if not enemies.forEach(function (enemy) { if (!enemy.isMoving) { enemy.isMoving = true; // Set isMoving flag to true // Start enemy movement var platformLength = floors.filter(function (floor) { return floor.y === enemy.y + 100; }).length * 40; // Calculate platform length tween(enemy, { x: enemy.x + platformLength - enemy.width }, { duration: 2000, easing: easingFunctions[Math.floor(Math.random() * easingFunctions.length)], onFinish: function onFinish() { tween(enemy, { x: enemy.x - (platformLength - enemy.width) }, { 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)) { // Capture enemy enemy.destroy(); enemies.splice(i, 1); bubble.destroy(); bubbles.splice(j, 1); 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(); }, 500); break; } } } // BLOCKS // Add a floor to the bottom of the screen 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); }
===================================================================
--- original.js
+++ change.js
@@ -207,62 +207,11 @@
}
lastClick = now;
};
// 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 = 10;
-distinctHeights.forEach(function (height) {
- platformYPositions.push(height);
-});
for (var j = 0; j < platformYPositions.length; j++) {
var platformLength = Math.floor(Math.random() * (maxPlatformLength - minPlatformLength + 1)) + minPlatformLength;
var startX = Math.floor(Math.random() * (2048 - platformLength * 100)); // Random start position
- // Ensure no other platform exists at this height
- if (!floors.some(function (floor) {
- return floor.y === platformYPositions[j];
- })) {
- platformTint = Math.floor(Math.random() * 16777215); // Tint platform to a random color
- for (var i = 0; i < platformLength; i++) {
- var platform = LK.getAsset('floor', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: startX + i * 100,
- y: platformYPositions[j]
- });
- platform.tint = platformTint;
- game.addChild(platform);
- floors.push(platform);
- }
- }
-}
-// Add continuous floor on the left margin of the screen
-for (var j = 0; j < 28; 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 < 28; 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
-for (var j = 0; j < platformYPositions.length; j++) {
- var platformLength = Math.floor(Math.random() * (maxPlatformLength - minPlatformLength + 1)) + minPlatformLength;
- var startX = Math.floor(Math.random() * (2048 - platformLength * 100)); // Random start position
for (var i = 0; i < platformLength; i++) {
var platform = LK.getAsset('floor', {
anchorX: 0.5,
anchorY: 0.5,
@@ -397,14 +346,36 @@
}
}
// BLOCKS
// Add a floor to the bottom of the screen
-for (var i = 0; i < 5; i++) {
- var floor = LK.getAsset('bigBlock', {
+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);
}
\ No newline at end of file
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