Code edit (2 edits merged)
Please save this source code
User prompt
Add a subtle arcade sound every time the user passes a pipe and gets a score.
User prompt
Remove the pop-up at the beginning of the game.
User prompt
Before the game begins, show the game over pop-up screen with the button that says play again. Don't start the game until the user presses that button.
User prompt
Remove the start game pop-up.
User prompt
For the start game pop-up copy the game over pop-up in all of its style. Instead of showing play again say start game. The game will not actually start playing until after the user presses that button.
User prompt
Remove the debug code showing the text that shows the gap.
User prompt
The game should not begin until after the player has clicked the OK button.
User prompt
The information at the beginning of the game needs to be in a pop-up and the game needs to be frozen prior to the user clicking the OK button.
User prompt
Before the game begins, there should be a pop-up that says start your Pelican with a button that says OK. When the player clicks OK, the game starts.
User prompt
As the game progresses, the space between the horizontal pillars should become more narrow, but never more than half the size they are when the game begins.
Code edit (1 edits merged)
Please save this source code
User prompt
The vertical gap between the pipes should be roughly the same as the Flappy Bird game pipes.
User prompt
The vertical gap between the pipes should never be more than 10 times the vertical height of the user character.
User prompt
The vertical gap between the pipes should always be between 10% and 20% of the vertical size of the screen.
User prompt
The vertical gap between the pipes should never be less or should never be more than 30%.
User prompt
The text showing the vertical gap size as a percentage should appear on top of the pipe itself centered on the screen.
User prompt
The text should appear on the top pipe attached to the top pipe as a percentage of the gap size compared to the rest of the screen.
User prompt
The text should be between the pipes and move along with the pipes.
User prompt
For debug purposes, add text that shows the vertical gap between the pipes for each pipe.
User prompt
The vertical gap of the pipes should always be between 30% and 60% of the vertical screen size.
User prompt
The vertical gap in the pipes should be about 30% of the vertical screen size.
User prompt
The user should get 5 points for colliding into a fish and 1 point for passing a pipe.
User prompt
Make the bottom layer bright pink, make the pipes blue.
User prompt
Please fix the bug: 'ReferenceError: scoreTxt is not defined' in or related to this line: 'scoreTxt.setText(LK.getScore());' Line Number: 131
/****
* Classes
****/
// Fish class
var Fish = Container.expand(function () {
var self = Container.call(this);
var fishGraphics = self.attachAsset('pelican', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.direction = 1; // 1 for right, -1 for left
self.update = function () {
self.x += self.speed * self.direction;
if (self.x > 2048 || self.x < 0) {
self.direction *= -1; // Change direction
}
};
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -5;
self.update = function () {
self.x += self.speed;
if (self.x < -100) {
self.destroy();
}
};
self.createPipe = function (gapY, gapHeight) {
var topPipe = LK.getAsset('obstacle', {
anchorX: 0.5,
anchorY: 1.0,
height: gapY
});
var bottomPipe = LK.getAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.0,
y: gapY + gapHeight,
height: 2732 - (gapY + gapHeight)
});
self.addChild(topPipe);
self.addChild(bottomPipe);
};
});
// The assets will be automatically created and loaded by the LK engine
// Pelican class
var Pelican = Container.expand(function () {
var self = Container.call(this);
var pelicanGraphics = self.attachAsset('pelican', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 0;
self.update = function () {
self.speed += 0.5; // Gravity effect
self.y += self.speed;
if (self.y < 0) {
self.y = 0;
}
if (self.y > 2732) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
};
self.dive = function () {
self.speed = 10; // Increase speed for diving
};
self.fly = function () {
self.speed = -15; // Increase upward speed for flying
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
// Forest green color for pipes
// Forest green color for pipes
// Add a light blue layer at the bottom 20% of the screen
var bottomLayer = LK.getAsset('obstacle', {
width: 2048,
height: 2732 * 0.2,
color: 0xADD8E6,
// Light blue color
anchorX: 0.5,
anchorY: 0.0
});
bottomLayer.x = 2048 / 2;
bottomLayer.y = 2732 * 0.8;
game.addChild(bottomLayer);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var pelican = game.addChild(new Pelican());
var fish = game.addChild(new Fish());
fish.x = 1024; // Start in the middle of the screen
fish.y = 2732 * 0.9; // Position in the bottom layer
pelican.speed = 0; // Initial speed
pelican.x = 500;
pelican.y = 1366;
var obstacles = [];
game.update = function () {
if (LK.ticks % 600 == 0) {
var newObstacle = new Obstacle();
newObstacle.x = 2048;
var gapY = Math.random() * (2732 - 600) + 200; // Random gap position
var gapHeight = 400; // Fixed gap height
newObstacle.createPipe(gapY, gapHeight);
obstacles.push(newObstacle);
game.addChild(newObstacle);
}
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i].x < -50) {
obstacles[i].destroy();
obstacles.splice(i, 1);
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
}
if (pelican.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
fish.update();
if (pelican.intersects(fish)) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
fish.destroy();
fish = game.addChild(new Fish());
fish.x = 1024; // Reset fish position
fish.y = 2732 * 0.9;
}
}
};
game.down = function (x, y, obj) {
pelican.fly();
};
game.up = function (x, y, obj) {
// No action needed on mouse up
};
8-bit profile of pelican flying straight. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit profile of fish for arcade game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit profile of pelican flapping it's wings downward. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit silhouette of tugboat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit "YUM" dialog bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.