Code edit (1 edits merged)
Please save this source code
User prompt
the background slides a bit too much upon jump, make it slide less
Code edit (2 edits merged)
Please save this source code
User prompt
the background correctly slides down while the player is jumping, but it doesn't slide back up, instead it simply snaps back to it's original position. it should slide back up just as it slides down, based on the same distance it slid down
Code edit (2 edits merged)
Please save this source code
User prompt
the background correctly slides down while the player is jumping, but it doesn't slide back up upon the player descending, instead it simply snaps back to it's original position. it should slide back up just as it slides down, based on the same distance it slided down
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: setInterval is not a function' in or related to this line: 'var slideUpInterval = setInterval(function () {' Line Number: 159
User prompt
the background correctly slides down while the player is jumping, but it doesn't slide back up upon the player descending, instead it simply snaps back to it's original position. it should slide back up just as it slides down
User prompt
the background also needs to slide back up to it's original position, as soon as the character starts descending back to treturn to the ground. there needs to be a direct correlation between the player's jump and the background sliding. so while the player is moving up the background slides down, and viceverse, while the player returns back to the ground the background needs to slide back up, so that once the player lands back on the ground that is correlated to the background sliding back up to it's original position
User prompt
the background is not moving, it needs to sldie down as requested
User prompt
after the tap is released and the frog jumps, the background needs to slide down. as soon as the player starts descending back, slide the background back up until it returned to it's original position. the background has to slide down directly proportional to the player's jump as affected by the amount of time the figner was pressed
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
add a delay between the shake effect of each coin so they are not perfectly syncronized
User prompt
add a delay between the shake effect of each coin so they are not perfectly syncronized
Code edit (11 edits merged)
Please save this source code
User prompt
add a shake or vibrate effect to the coins
Code edit (1 edits merged)
Please save this source code
User prompt
the spawners are placed exactly at the edge of the screen, making the coins seem to pop out of nowhere, move them 50 pixels outside the edge of the screen so the coins are generated outside the screen bounds
User prompt
create a new background asset nd stretch it across the entire size of the screen. add it to the backgroundcontainer
Code edit (1 edits merged)
Please save this source code
User prompt
the text writing is aligned to the left, which means the value extends towards the right, it should instead be aligned to the center so the text always remaines centered regardless of the digits it contains
Code edit (3 edits merged)
Please save this source code
User prompt
add a black outline to the score and ensure its alignment is to the center instead of to the left
/****
* Classes
****/
// Define the BackgroundContainer class
var BackgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Define the Coin class
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.update = function () {
self.x += self.speed;
if (self.intersects(player)) {
LK.setScore(LK.getScore() + 1);
scoreText.setText(LK.getScore());
self.destroy();
} else if (self.x > 2048 + self.width) {
self.destroy();
}
};
return self;
});
// Define the CoinLeft class
var CoinLeft = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: +1 // Flip the X axis
});
self.speed = -10;
self.update = function () {
self.x += self.speed;
if (self.intersects(player)) {
LK.setScore(LK.getScore() + 1);
scoreText.setText(LK.getScore());
self.destroy();
} else if (self.x < -self.width) {
self.destroy();
}
};
return self;
});
// Define the ForegroundContainer class
var ForegroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
// Define the Life class
var Life = Container.expand(function () {
var self = Container.call(this);
var lifeGraphics = self.attachAsset('Life', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = 1; // 1 for right, -1 for left
self.speed = 7;
self.x = lifeGraphics.width / 2; // Position at left edge of the screen
self.y = 200; // Lower y position
self.update = function () {
self.x += self.speed * self.direction;
// Check if life's edge has reached the edge of the screen
if (self.x + lifeGraphics.width / 2 >= 2048 || self.x - lifeGraphics.width / 2 <= 0) {
self.direction *= -1; // Change direction
}
};
return self;
});
// Define the MidgroundContainer class
var MidgroundContainer = Container.expand(function () {
var self = Container.call(this);
return self;
});
//<Assets used in the game will automatically appear here>
// Define the Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityY = 0;
self.isJumping = false;
self.isInAir = false;
self.jumpStartTime = 0;
self.jumpCharge = 0;
self.update = function () {
if (self.isJumping) {
self.jumpCharge = Math.min(60, LK.ticks - self.jumpStartTime);
} else {
self.velocityY += 1; // Gravity
if (self.jumpCharge > 0) {
self.velocityY = -Math.max(25, self.jumpCharge * 1.3); // Multiply the jump charge by 2 to increase the jump height, with a minimum jump height of 10
self.jumpCharge = 0;
}
}
self.y += self.velocityY;
// Check if player's top edge has reached the top of the screen
if (self.y - playerGraphics.height <= 0) {
LK.showGameOver();
}
// Prevent player from falling below the ground
if (self.y > 2940 - playerGraphics.height) {
self.y = 2940 - playerGraphics.height;
self.velocityY = 0;
self.isOnGround = true;
if (self.isInAir) {
self.isInAir = false;
self.removeChildren(); // Remove all children (including player_jump asset)
self.attachAsset('player', {
anchorX: 0.5,
anchorY: 1.0
});
}
} else {
self.isOnGround = false;
}
// Add a shake effect to the player when the jump is being charged
if (self.shake) {
self.x += Math.sin(LK.ticks / 1) * 3;
}
};
self.startJump = function () {
if (self.isOnGround) {
self.isJumping = true;
self.jumpStartTime = LK.ticks;
}
};
self.endJump = function () {
self.isJumping = false;
self.isInAir = true;
self.removeChildren(); // Remove all children (including player asset)
self.attachAsset('player_jump', {
anchorX: 0.5,
anchorY: 1.0
});
};
return self;
});
// Define the Spawner class
var Spawner = Container.expand(function (spawnRate, y) {
var self = Container.call(this);
self.spawnRate = spawnRate;
self.y = y;
self.spawnTimer = 0;
self.update = function () {
self.spawnTimer++;
if (self.spawnTimer >= self.spawnRate) {
var coin = game.addChild(new Coin());
coin.x = 0;
coin.y = self.y;
self.spawnTimer = 0;
}
};
return self;
});
// Define the SpawnerLeft class
var SpawnerLeft = Container.expand(function (spawnRate, y) {
var self = Container.call(this);
self.spawnRate = spawnRate;
self.y = y;
self.spawnTimer = 0;
self.update = function () {
self.spawnTimer++;
if (self.spawnTimer >= self.spawnRate) {
var coin = game.addChild(new CoinLeft());
coin.x = 2048;
coin.y = self.y;
self.spawnTimer = 0;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
var backgroundContainer = game.addChild(new BackgroundContainer());
var midgroundContainer = game.addChild(new MidgroundContainer());
var foregroundContainer = game.addChild(new ForegroundContainer());
var player = foregroundContainer.addChild(new Player());
// Create and add score text to the midground container
var scoreText = new Text2('0', {
size: 150,
fill: "#ffffff",
stroke: "#000000",
strokeThickness: 10,
anchorX: 0.5,
anchorY: 0.5
});
scoreText.x = game.width / 2;
scoreText.y = game.height / 2;
midgroundContainer.addChild(scoreText);
var life = foregroundContainer.addChild(new Life());
player.x = 2048 / 2;
player.y = 2732 - player.height;
// Create the spawners
var spawners = [];
for (var i = 0; i < 5; i++) {
var spawner = foregroundContainer.addChild(new Spawner(40 * (i + 1), 2732 / 7 * i + 500));
spawners.push(spawner);
}
// Create the spawners on the right side of the screen
var spawnersLeft = [];
for (var i = 0; i < 5; i++) {
var spawner = foregroundContainer.addChild(new SpawnerLeft(60 * (i + 1), 2732 / 7 * i + 700));
spawnersLeft.push(spawner);
}
game.down = function (x, y, obj) {
player.startJump();
LK.getSound('Charge').play();
player.shake = true;
};
game.up = function (x, y, obj) {
player.endJump();
LK.getSound('Charge').stop();
LK.getSound('Jump').play();
player.shake = false;
};
game.update = function () {
player.update();
life.update();
// Update the spawners on the right side of the screen
for (var i = 0; i < spawnersLeft.length; i++) {
spawnersLeft[i].update();
}
// Update the spawners
for (var i = 0; i < spawners.length; i++) {
spawners[i].update();
}
if (player.intersects(life)) {
life.destroy();
life = game.addChild(new Life());
}
life.update();
};
pixelated 8-bit cute sitting frog seen from the front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelated 8-bit cute jumping frog seen from the front. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
background of a pond in the middle of the nature. pixelated 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.