User prompt
Add more clouds in the background,
User prompt
Make the clouds very very big and the trees too
User prompt
When I tap on the screen the Dino should jump and it should not die even if it jumps closer to the cactus
User prompt
Add trees in the background, make the sky blue with clouds
User prompt
Make the background aesthetic green forest not bluee
User prompt
Accordingly, the bird should be more up or else it will attack the Dino,
User prompt
Make the Dino, the cactus, the rose a little bigger and the rose should be on the ground for the Dino to collect it
User prompt
Add a small roses collected box and add roses which the Dino collects
Code edit (1 edits merged)
Please save this source code
User prompt
Dino Runner: Endless Desert Sprint
Initial prompt
Dino T‐Rex – Streamlined Game Loop & Features Instant Playability: One-touch controls – tap to jump, hold to duck under flying pterodactyls . Endless Running: Your T‐Rex continuously sprints across a monochrome desert. Score climbs with each meter survived . Dynamic Difficulty: The speed ramps up gradually—keep reflexes sharp to avoid cacti and pterodactyls . Night/Day Cycles: Gameplay transitions between day and night modes as you reach milestones . Retro Pixel Art: Crisp black-and-white, minimalist visuals evoke classic arcade charm . Offline Ready: Fully playable without internet, just like Chrome’s built-in easter egg . High Score Tracking: A persistent high-score saves your best run—compete against yourself . Optional Unlockables: Mobile version adds skins, bird companions, and accessories as you hit new scores . Subtle Audio Cues: Jump and collision sounds enhance engagement without overwhelming the simple aesthetic . Lightweight & Performance-Oriented: Small app size, minimal load, and glitch-free performance even on low-end devices . --- 🔄 Core Game Loop Flow 1. Start → Tap to begin the endless run. 2. React in Real-Time → Jump or duck obstacles that appear. 3. Progression → As distance increases, speed and challenge intensify. 4. Visuals Shift → Transitions into night mode after a score threshold. 5. Game Over → Collision ends the run, and high-score is recorded. 6. Repeat → Attempt to beat your own score, unlocking optional cosmetics along the way.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Cactus = Container.expand(function () {
var self = Container.call(this);
var cactusGraphics = self.attachAsset('cactus', {
anchorX: 0.5,
anchorY: 1.0
});
self.speed = 8;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Dino = Container.expand(function () {
var self = Container.call(this);
var dinoGraphics = self.attachAsset('dino', {
anchorX: 0.5,
anchorY: 1.0
});
self.isJumping = false;
self.isDucking = false;
self.jumpVelocity = 0;
self.groundY = 2500;
self.jumpPower = -25;
self.gravity = 1.2;
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpVelocity = self.jumpPower;
LK.getSound('jump').play();
}
};
self.duck = function () {
if (!self.isJumping) {
self.isDucking = true;
dinoGraphics.scaleY = 0.6;
}
};
self.stopDucking = function () {
self.isDucking = false;
dinoGraphics.scaleY = 1.0;
};
self.update = function () {
if (self.isJumping) {
self.jumpVelocity += self.gravity;
self.y += self.jumpVelocity;
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
}
}
};
return self;
});
var Pterodactyl = Container.expand(function () {
var self = Container.call(this);
var pterodactylGraphics = self.attachAsset('pterodactyl', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.x -= self.speed;
// Simple flying animation
pterodactylGraphics.y = Math.sin(LK.ticks * 0.2) * 10;
};
return self;
});
var Rose = Container.expand(function () {
var self = Container.call(this);
var roseGraphics = self.attachAsset('rose', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.x -= self.speed;
// Simple floating animation
roseGraphics.y = Math.sin(LK.ticks * 0.15) * 5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Game state variables
var gameRunning = false;
var gameSpeed = 8;
var distanceScore = 0;
var speedIncrement = 0.002;
var lastObstacleSpawn = 0;
var minObstacleDistance = 200;
var maxObstacleDistance = 400;
var nextObstacleDistance = 300;
var isNightMode = false;
var dayNightThreshold = 500;
var rosesCollected = 0;
var lastRoseSpawn = 0;
var roseSpawnInterval = 180;
// Game objects
var dino;
var obstacles = [];
var grounds = [];
var roses = [];
// UI elements
var scoreText;
var highScoreText;
var instructionText;
var rosesText;
// Initialize high score from storage
var highScore = storage.highScore || 0;
// Create ground segments
function createGroundSegments() {
for (var i = 0; i < 4; i++) {
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0,
anchorY: 0,
x: i * 2048,
y: 2520
}));
grounds.push(ground);
}
}
// Update ground scrolling
function updateGround() {
for (var i = 0; i < grounds.length; i++) {
var ground = grounds[i];
ground.x -= gameSpeed;
if (ground.x <= -2048) {
ground.x = ground.x + 2048 * grounds.length;
}
}
}
// Spawn obstacle
function spawnObstacle() {
var obstacle;
var obstacleType = Math.random();
if (obstacleType < 0.7) {
// Spawn cactus
obstacle = new Cactus();
obstacle.x = 2200;
obstacle.y = 2520;
} else {
// Spawn pterodactyl
obstacle = new Pterodactyl();
obstacle.x = 2200;
obstacle.y = 2400 - Math.random() * 100;
}
obstacle.speed = gameSpeed;
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn rose
function spawnRose() {
var rose = new Rose();
rose.x = 2200;
rose.y = 2300 - Math.random() * 200;
rose.speed = gameSpeed;
roses.push(rose);
game.addChild(rose);
}
// Update obstacles
function updateObstacles() {
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
obstacle.speed = gameSpeed;
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
}
}
}
// Update roses
function updateRoses() {
for (var i = roses.length - 1; i >= 0; i--) {
var rose = roses[i];
rose.speed = gameSpeed;
if (rose.x < -100) {
rose.destroy();
roses.splice(i, 1);
}
}
}
// Check rose collections
function checkRoseCollections() {
for (var i = roses.length - 1; i >= 0; i--) {
var rose = roses[i];
if (dino.intersects(rose)) {
rosesCollected++;
rosesText.setText('Roses: ' + rosesCollected);
LK.getSound('collect').play();
rose.destroy();
roses.splice(i, 1);
}
}
}
// Check collisions
function checkCollisions() {
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
if (dino.intersects(obstacle)) {
gameOver();
return;
}
}
}
// Game over
function gameOver() {
gameRunning = false;
LK.getSound('collision').play();
// Update high score
if (distanceScore > highScore) {
highScore = distanceScore;
storage.highScore = highScore;
}
LK.showGameOver();
}
// Start game
function startGame() {
if (!gameRunning) {
gameRunning = true;
instructionText.alpha = 0;
rosesCollected = 0;
rosesText.setText('Roses: 0');
}
}
// Update day/night cycle
function updateDayNight() {
if (distanceScore > dayNightThreshold && !isNightMode) {
isNightMode = true;
tween(game, {
backgroundColor: 0x191970
}, {
duration: 2000
});
} else if (distanceScore > dayNightThreshold * 2 && isNightMode) {
isNightMode = false;
dayNightThreshold *= 3;
tween(game, {
backgroundColor: 0x87CEEB
}, {
duration: 2000
});
}
}
// Initialize game elements
createGroundSegments();
// Create dino
dino = game.addChild(new Dino());
dino.x = 300;
dino.y = 2520;
// Create UI
scoreText = new Text2('0', {
size: 60,
fill: 0x000000
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
scoreText.y = 100;
highScoreText = new Text2('HI: ' + highScore, {
size: 40,
fill: 0x666666
});
highScoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(highScoreText);
highScoreText.y = 180;
instructionText = new Text2('TAP TO START', {
size: 80,
fill: 0x000000
});
instructionText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionText);
rosesText = new Text2('Roses: 0', {
size: 40,
fill: 0x8B4513
});
rosesText.anchor.set(0, 0);
LK.gui.topRight.addChild(rosesText);
rosesText.x = -200;
rosesText.y = 50;
// Input handling
var isPressed = false;
game.down = function (x, y, obj) {
if (!gameRunning) {
startGame();
} else {
dino.jump();
}
isPressed = true;
};
game.up = function (x, y, obj) {
isPressed = false;
if (gameRunning) {
dino.stopDucking();
}
};
// Main game loop
game.update = function () {
if (!gameRunning) {
return;
}
// Handle ducking
if (isPressed && !dino.isJumping) {
dino.duck();
}
// Update game speed and score
gameSpeed += speedIncrement;
distanceScore = Math.floor(LK.ticks / 6);
scoreText.setText(distanceScore.toString());
// Update ground
updateGround();
// Spawn obstacles
if (LK.ticks - lastObstacleSpawn > nextObstacleDistance) {
spawnObstacle();
lastObstacleSpawn = LK.ticks;
nextObstacleDistance = minObstacleDistance + Math.random() * (maxObstacleDistance - minObstacleDistance);
}
// Spawn roses
if (LK.ticks - lastRoseSpawn > roseSpawnInterval) {
spawnRose();
lastRoseSpawn = LK.ticks;
roseSpawnInterval = 120 + Math.random() * 120;
}
// Update obstacles
updateObstacles();
// Update roses
updateRoses();
// Check collisions
checkCollisions();
// Check rose collections
checkRoseCollections();
// Update day/night cycle
updateDayNight();
}; ===================================================================
--- original.js
+++ change.js
@@ -74,8 +74,22 @@
pterodactylGraphics.y = Math.sin(LK.ticks * 0.2) * 10;
};
return self;
});
+var Rose = Container.expand(function () {
+ var self = Container.call(this);
+ var roseGraphics = self.attachAsset('rose', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.update = function () {
+ self.x -= self.speed;
+ // Simple floating animation
+ roseGraphics.y = Math.sin(LK.ticks * 0.15) * 5;
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -96,16 +110,21 @@
var maxObstacleDistance = 400;
var nextObstacleDistance = 300;
var isNightMode = false;
var dayNightThreshold = 500;
+var rosesCollected = 0;
+var lastRoseSpawn = 0;
+var roseSpawnInterval = 180;
// Game objects
var dino;
var obstacles = [];
var grounds = [];
+var roses = [];
// UI elements
var scoreText;
var highScoreText;
var instructionText;
+var rosesText;
// Initialize high score from storage
var highScore = storage.highScore || 0;
// Create ground segments
function createGroundSegments() {
@@ -147,8 +166,17 @@
obstacle.speed = gameSpeed;
obstacles.push(obstacle);
game.addChild(obstacle);
}
+// Spawn rose
+function spawnRose() {
+ var rose = new Rose();
+ rose.x = 2200;
+ rose.y = 2300 - Math.random() * 200;
+ rose.speed = gameSpeed;
+ roses.push(rose);
+ game.addChild(rose);
+}
// Update obstacles
function updateObstacles() {
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
@@ -158,8 +186,32 @@
obstacles.splice(i, 1);
}
}
}
+// Update roses
+function updateRoses() {
+ for (var i = roses.length - 1; i >= 0; i--) {
+ var rose = roses[i];
+ rose.speed = gameSpeed;
+ if (rose.x < -100) {
+ rose.destroy();
+ roses.splice(i, 1);
+ }
+ }
+}
+// Check rose collections
+function checkRoseCollections() {
+ for (var i = roses.length - 1; i >= 0; i--) {
+ var rose = roses[i];
+ if (dino.intersects(rose)) {
+ rosesCollected++;
+ rosesText.setText('Roses: ' + rosesCollected);
+ LK.getSound('collect').play();
+ rose.destroy();
+ roses.splice(i, 1);
+ }
+ }
+}
// Check collisions
function checkCollisions() {
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
@@ -184,8 +236,10 @@
function startGame() {
if (!gameRunning) {
gameRunning = true;
instructionText.alpha = 0;
+ rosesCollected = 0;
+ rosesText.setText('Roses: 0');
}
}
// Update day/night cycle
function updateDayNight() {
@@ -232,8 +286,16 @@
fill: 0x000000
});
instructionText.anchor.set(0.5, 0.5);
LK.gui.center.addChild(instructionText);
+rosesText = new Text2('Roses: 0', {
+ size: 40,
+ fill: 0x8B4513
+});
+rosesText.anchor.set(0, 0);
+LK.gui.topRight.addChild(rosesText);
+rosesText.x = -200;
+rosesText.y = 50;
// Input handling
var isPressed = false;
game.down = function (x, y, obj) {
if (!gameRunning) {
@@ -269,11 +331,21 @@
spawnObstacle();
lastObstacleSpawn = LK.ticks;
nextObstacleDistance = minObstacleDistance + Math.random() * (maxObstacleDistance - minObstacleDistance);
}
+ // Spawn roses
+ if (LK.ticks - lastRoseSpawn > roseSpawnInterval) {
+ spawnRose();
+ lastRoseSpawn = LK.ticks;
+ roseSpawnInterval = 120 + Math.random() * 120;
+ }
// Update obstacles
updateObstacles();
+ // Update roses
+ updateRoses();
// Check collisions
checkCollisions();
+ // Check rose collections
+ checkRoseCollections();
// Update day/night cycle
updateDayNight();
};
\ No newline at end of file