Code edit (5 edits merged)
Please save this source code
User prompt
move ground and ground asset at the bottom middle of the screen
User prompt
move ground at the bottom middle of the screen
User prompt
create ground asset and make it visible in the center of the screen
User prompt
instanciate ground on the playspace, make it visible
User prompt
Please fix the bug: 'Uncaught TypeError: game.addChildToFront is not a function' in or related to this line: 'self.move = function () {' Line Number: 111
User prompt
asset ground should be visible on the forefront layer
User prompt
if game.score ≥ 100, change the spawning frequency of the pterodactyl and cactus to 1.7 second if game.score ≥ 200, change the spawning frequency of the pterodactyl and cactus to 1.5 second
User prompt
game.score ≥ 200, change the spawning frequency of the pterodactyl and cactus to 1.5 second
User prompt
game.score ≥ 100, change the spawning frequency of the pterodactyl and cactus to 1.7 second
User prompt
when a pterodactyl spawns, give it either a normal movement speed or a slower movement speed
User prompt
game.score ≥ 100, change the spawning frequency of the pterodactyl and cactus to 1 second
User prompt
every 10 seconds, spawn two cactus in a 2 seconds interval rather than one
User prompt
add a 10% chance to spawn two pterodactyls rather than one
Code edit (1 edits merged)
Please save this source code
User prompt
When the dinosaur intersects with a collectible, randomly select one of the six messages and show it at the bottom center of the screen for 3 seconds before fading out. "Gathering data like a pro and outrunning the digital chaos!" "Just another day in the endless run of information!" "Swifter than a byte, slicker than code!" "Surfing the data waves, one byte at a time!" "I'm the endless runner of information!" "I make data collection look easy!"
User prompt
show only one message at a time
User prompt
when the collectible is acquired, show at the bottom center of the screen for 3 seconds before dissapearing one of these lines: "Gathering data like a pro and outrunning the digital chaos!" "Just another day in the endless run of information!" "Swifter than a byte, slicker than code!" "Surfing the data waves, one byte at a time!" "I'm the endless runner of information!" "I make data collection look easy!"
User prompt
randomize the vertical spawning of the collectible
User prompt
increase the interval at which the collectible respawns
User prompt
fix the collectible not respawning correctly
User prompt
when the collectible either left the screen or has been collected, spawn a new one after 7 to 14 seconds
User prompt
spawn collectibles every 7 to 14 seconds
User prompt
if the collectible has been collected, game.score += 10;
User prompt
if the collectible has been collected, game.score += 1;
/****
* Classes
****/
var Background = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('background', {
width: 2048,
height: 2732,
anchorX: 0,
anchorY: 0
});
self.move = function () {
self.x -= game.speed;
if (self.x <= -2048) {
self.x = 0;
}
};
});
var Cactus = Container.expand(function () {
var self = Container.call(this);
var cactusGraphics = self.attachAsset('cactus', {
anchorX: 0.5,
anchorY: 1.0,
scaleX: 1 + Math.random() * 0.2,
scaleY: 1 + Math.random() * 0.2
});
self.move = function () {
if (LK.ticks % 600 == 0) {
game.speed *= 1.1;
}
self.x -= game.speed * 2;
if (LK.ticks % 60 == 0) {
self.scale.x *= -1;
}
};
});
var Cloud = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.6
});
self.move = function () {
self.x -= game.speed;
};
});
var Collectible = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('collectible', {
anchorX: 0.5,
anchorY: 0.5
});
self.move = function () {
self.x -= game.speed;
};
});
var Dinosaur = Container.expand(function () {
var self = Container.call(this);
var dinosaurGraphics = self.attachAsset('dinosaur', {
anchorX: 0.5,
anchorY: 1.0
});
self.isJumping = false;
self.jumpSpeed = 0;
self.gravity = 0.5;
self.jump = function () {
if (!self.isJumping && self.y >= game.floorLevel) {
self.isJumping = true;
self.jumpSpeed = -25;
}
};
self.update = function () {
if (self.isJumping) {
self.y += self.jumpSpeed;
self.jumpSpeed += self.gravity;
}
if (self.y > game.floorLevel) {
self.y = game.floorLevel;
self.isJumping = false;
}
if (LK.ticks % 18 == 0) {
self.scale.x *= self.scale.x > 1 ? 0.95 : 1.05;
self.scale.y *= self.scale.y > 1 ? 0.95 : 1.05;
}
};
});
var Ground = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('ground', {
anchorX: 0,
anchorY: 1.0
});
self.move = function () {
self.x -= game.speed;
if (self.x <= -2048) {
self.x = 0;
}
};
});
var NightBackground = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('nightBackground', {
width: 2048,
height: 2732,
anchorX: 0,
anchorY: 0
});
self.move = function () {
self.x -= game.speed;
if (self.x <= -2048) {
self.x = 0;
}
};
});
var Pterodactyl = Container.expand(function () {
var self = Container.call(this);
var pterodactylGraphics = self.attachAsset('pterodactyl', {
anchorX: 0.5,
anchorY: 0.5
});
self.move = function () {
if (LK.ticks % 600 == 0) {
game.speed *= 1.1;
}
self.x -= game.speed * 2;
self.y += Math.sin(LK.ticks / 10) * 5;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
game.collectibles = [];
var title = LK.gui.top.addChild(LK.getAsset('title', {
anchorX: 0,
anchorY: 0,
x: -500,
y: 0
}));
var background1 = game.addChild(new Background());
var nightBackground1 = game.addChild(new NightBackground());
nightBackground1.visible = false;
var scoreTxt = new Text2(LK.getScore().toString(), {
size: 150,
fill: '#ffffff'
});
scoreTxt.anchor.set(0.5, 0.5);
LK.gui.center.addChild(scoreTxt);
var ground1 = game.addChild(new Ground());
var ground2 = game.addChild(new Ground());
ground2.x = 2048;
game.speed = 5;
game.floorLevel = 2732 - 200; // Dinosaur stands on the floor
game.score = 0;
game.obstacles = [];
var dinosaur = game.addChild(new Dinosaur());
dinosaur.x = 300;
dinosaur.y = game.floorLevel;
game.on('down', function () {
dinosaur.jump();
});
LK.on('tick', function () {
if (LK.ticks % 2700 == 0) {
background1.visible = !background1.visible;
nightBackground1.visible = !nightBackground1.visible;
}
if (LK.ticks % 2700 == 1350) {
background1.visible = !background1.visible;
nightBackground1.visible = !nightBackground1.visible;
}
dinosaur.update();
if (LK.ticks % 60 == 0) {
game.score += 1;
}
scoreTxt.setText(LK.getScore().toString());
LK.setScore(Math.floor(game.score)); // Update the score display
// Move the ground and background
ground1.move();
ground1.move();
ground2.move();
// Handle obstacles
if (LK.ticks % (600 + Math.random() * 600) == 0) {
// Add a new collectible every 10 to 20 seconds
var collectible = new Collectible();
collectible.y = game.floorLevel - Math.random() * 300 - 300; // Random height for collectible
collectible.x = 2048;
game.collectibles.push(collectible);
game.addChild(collectible);
}
if (LK.ticks % 120 == 0) {
// Add a new obstacle every 2 seconds
var obstacle;
if (Math.random() < 0.5) {
obstacle = new Cactus();
obstacle.y = game.floorLevel;
} else {
obstacle = new Pterodactyl();
obstacle.y = game.floorLevel - Math.random() * 300 - 300; // Random height for pterodactyl
}
obstacle.x = 2048;
game.obstacles.push(obstacle);
game.addChild(obstacle);
}
if (LK.ticks % 600 == 0) {
// Add a new cloud every 10 seconds
var cloud = new Cloud();
cloud.y = title.height + 50; // Position cloud under the title
cloud.x = 2048 / 2;
game.addChild(cloud);
}
for (var i = game.collectibles.length - 1; i >= 0; i--) {
game.collectibles[i].move();
if (dinosaur.intersects(game.collectibles[i])) {
// Destroy the collectible and add +10 to the score when dinosaur collides with it
game.collectibles[i].destroy();
game.collectibles.splice(i, 1);
game.score += 1;
}
if (game.collectibles[i] && game.collectibles[i].x < -100) {
// Remove off-screen collectibles
game.collectibles[i].destroy();
game.collectibles.splice(i, 1);
}
}
for (var i = game.obstacles.length - 1; i >= 0; i--) {
game.obstacles[i].move();
if (dinosaur.intersects(game.obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
if (game.obstacles[i].x < -100) {
// Remove off-screen obstacles
game.obstacles[i].destroy();
game.obstacles.splice(i, 1);
}
}
});
pixel art pterodactyl flying. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art cactus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art desert ground sand. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art desert. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art clouds. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art night-time desert. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a microchip no shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a title screen logo with "GPT DASH" written on it, no shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a chat gpt robot running with gpt engraved on his chest and a smiley face on his robot visor. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art tiling of a desert sandy ground.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art particles. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.