User prompt
Make normal clouds a little transparent
User prompt
Now normal clouds appear moving from right to left in the background
User prompt
Make it so that birds cannot appear underwater
User prompt
So Victory's message says something like play again for a new difficulty
User prompt
Well done
User prompt
So every time you win the bird appears in a different place and one or two birds may appear
User prompt
I wasn't referring to the corners but a little more in the middle.
User prompt
Let's make objects called birds come out from the corners that will move from one side to the other and if the dolphin touches them, he loses.
User prompt
So the whale jumps shorter than the dolphin
User prompt
Now the whale just goes up the whale should fall after jumping
User prompt
Hey, it's not jumping, it's sinking, so jump, don't sink.
User prompt
So the whale makes a little jump when the dolphin jumps on it
User prompt
That the mar are smaller
User prompt
Las isiste más grandes maldito que las aguas más pequeñas
User prompt
As the smallest sea is much smaller than you made it bigger in the first place
User prompt
So the sea returns to its size
User prompt
So when the dolphin leaves the camera it reappears in the center at the same time as the whale and the sea are erased to give the effect that the camera is following it.
User prompt
So there is sea all over the ground
User prompt
So the dolphin can jump where there is no whale
User prompt
So when the dolphin jumps in a place where the whale is not, it creates a transparent cloud that will disappear moments later.
User prompt
Silly, they are touching the whale and they are very far apart, put it as you like
User prompt
Stop that, I'll go back to the way it was. I don't want them to be separated. I want them to be higher up because that way they touch the ground and the dolphin can jump in the clouds.
User prompt
Let that go, I don't want you to separate them, but to put them higher so they don't touch the ground and the dolphin can jump on them.
User prompt
So the clouds are higher and the dolphin can jump in them
User prompt
Raise them and separate them.
/****
* Classes
****/
// Bird class to be created when the dolphin jumps
var Bird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('bird', {
anchorX: 0.5,
anchorY: 0.5
});
self.vx = 5; // Horizontal velocity
self.update = function () {
// Make the bird move horizontally
self.x += self.vx;
if (self.x > 2048 || self.x < 0) {
self.vx *= -1; // Change direction when reaching the screen borders
}
};
});
// Cloud class to be created when the dolphin jumps
var Cloud = Container.expand(function () {
var self = Container.call(this);
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5
});
self.alpha = 0.5; // Make the cloud transparent
self.update = function () {
// Make the cloud disappear after a while
self.alpha -= 0.01;
if (self.alpha <= 0) {
self.destroy();
}
};
});
// Dolphin class to be thrown
var Dolphin = Container.expand(function () {
var self = Container.call(this);
var dolphinGraphics = self.attachAsset('dolphin', {
anchorX: 0.5,
anchorY: 0.5
});
self.vy = 0; // Vertical velocity
self.update = function () {
self.y += self.vy;
self.vy += 1; // Gravity effect
if (self.y > 2732) {
// Reset position if it falls below the screen
self.y = 2732;
self.vy = 0;
}
// Make the dolphin spin as it jumps
self.rotation += 0.1;
};
});
// Mar class to be placed on the ground
var Mar = Container.expand(function () {
var self = Container.call(this);
var marGraphics = self.attachAsset('Mar', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// The mar stays still on the ground
};
});
// NormalCloud class to be created in the background
var NormalCloud = Container.expand(function () {
var self = Container.call(this);
var normalCloudGraphics = self.attachAsset('normalcloud', {
anchorX: 0.5,
anchorY: 0.5
});
self.alpha = 0.5; // Make the normal cloud a little transparent
self.vx = -5; // Horizontal velocity
self.update = function () {
// Make the normal cloud move horizontally
self.x += self.vx;
if (self.x < 0) {
self.x = 2048; // Reset position when reaching the left border
}
};
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Whale class to support the dolphin
var Whale = Container.expand(function () {
var self = Container.call(this);
var whaleGraphics = self.attachAsset('whale', {
anchorX: 0.5,
anchorY: 0.5
});
self.vy = 0; // Vertical velocity
self.update = function () {
// Make the whale follow the dolphin horizontally
self.x = dolphin.x;
// Apply gravity to the whale
self.y += self.vy;
self.vy += 1; // Gravity effect
if (self.y > 2500) {
// Reset position if it falls below the initial position
self.y = 2500;
self.vy = 0;
}
};
self.flatten = function () {
// Play a toy sound
LK.getSound('toy').play();
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Create NormalCloud instances and distribute them across the sky
var normalClouds = [];
for (var i = 0; i < 5; i++) {
var normalCloud = game.addChild(new NormalCloud());
normalCloud.x = Math.random() * 2048; // Random horizontal position
normalCloud.y = Math.random() * 1366; // Random vertical position (only in the upper half of the screen)
normalClouds.push(normalCloud);
}
var whale = game.addChild(new Whale());
whale.x = 1024; // Center horizontally
whale.y = 2500; // Near the bottom
var dolphin = game.addChild(new Dolphin());
dolphin.x = whale.x;
dolphin.y = whale.y - 100; // Position above the whale
// Create 10 Mar instances and distribute them across the ground
var mars = [];
for (var i = 0; i < 10; i++) {
var mar = game.addChild(new Mar());
mar.x = i * 204.8; // Distribute horizontally
mar.y = 2732; // At the bottom
mar.scaleX = 10; // Make them smaller
mar.scaleY = 10; // Make them smaller
mars.push(mar);
}
// Event listener for throwing the dolphin
game.down = function (x, y, obj) {
if (dolphin.y >= whale.y - 100 && Math.abs(dolphin.x - whale.x) < whale.width / 2) {
dolphin.vy = -50; // Increase upward velocity if jumping on the whale
whale.vy = -20; // Make the whale jump a little
LK.getSound('toy').play(); // Play a toy sound
} else {
dolphin.vy = -20; // Initial upward velocity
// Create a cloud at the dolphin's position
var cloud = game.addChild(new Cloud());
cloud.x = dolphin.x;
cloud.y = dolphin.y;
}
};
// Create a variable to store the number of birds to be created
var numBirds = Math.floor(Math.random() * 2) + 1;
// Create Bird instances and distribute them a little more to the middle
var birds = [];
for (var i = 0; i < numBirds; i++) {
var bird = game.addChild(new Bird());
bird.x = Math.random() * (2048 - 500) + 500; // Random position from the left to the right, a little more to the middle
bird.y = Math.random() * (2732 - 500 - 500) + 500; // Random position from the top to the bottom, a little more to the middle but not underwater
birds.push(bird);
}
// Play background music
LK.playMusic('Jumping_song');
// Update game state
game.update = function () {
dolphin.update();
whale.update();
birds.forEach(function (bird) {
bird.update();
if (dolphin.intersects(bird)) {
normalClouds.forEach(function (normalCloud) {
normalCloud.update();
});
LK.showGameOver("Oh no! You've hit a bird. Try again!");
}
});
if (dolphin.y <= 0) {
// Dolphin reached the top
LK.showYouWin("Congratulations! You've reached the top! Play again for a new difficulty");
}
}; ===================================================================
--- original.js
+++ change.js
@@ -70,8 +70,9 @@
var normalCloudGraphics = self.attachAsset('normalcloud', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.alpha = 0.5; // Make the normal cloud a little transparent
self.vx = -5; // Horizontal velocity
self.update = function () {
// Make the normal cloud move horizontally
self.x += self.vx;