Code edit (4 edits merged)
Please save this source code
User prompt
make sure they can never spawn on screen, but to the right instead, and give them a minimum of 360 distance between each
User prompt
what i want is that they are randomly spared each time they get spawned, so give them an horizontal offset at the moment of the spawn
User prompt
make it so that ground obstacles dont always have the same distance between them
Code edit (2 edits merged)
Please save this source code
User prompt
make the flying obstacle be just above the ground obstacles
User prompt
put the flying obstacle at half its height
User prompt
now lets make a flying obstacle, only one at the same time on screen, it flies straight forward at a medium height
Code edit (1 edits merged)
Please save this source code
User prompt
lets make it so there can be a small offset between obstacles so they dont appear to be always at the same distance to one another, but prevent them from being too close together
User prompt
now lets make simple obstacles that appear on the ground, they must be boxes with 2 sizes, one is same than the box of the player and one is double that size, they appear infinitely and there is not more than 3 total obstacles at the same time on screen
Code edit (1 edits merged)
Please save this source code
User prompt
ground tiles still have gaps, and as the game speed increases the gaps become bigger, fix it please
User prompt
lets make it so that ground is infinitely seamless, no gaps between diferent pieces
Code edit (1 edits merged)
Please save this source code
User prompt
Dino Jump - Evolving Runner
Initial prompt
quiero hacer un juego que consista en el juego del dinosaurio de google, pero al que poco a poco le iremos añadiendo mas mecanicas, vamos a empezar por tener un suelo en el que se apoye el dinosaurio, y que pueda saltar cuando hagamos click
/****
* Classes
****/
var Dinosaur = Container.expand(function () {
var self = Container.call(this);
var dinoGraphics = self.attachAsset('dino', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpPower = -30;
self.isGrounded = false;
self.groundY = 0;
self.jump = function () {
if (self.isGrounded) {
self.velocityY = self.jumpPower;
self.isGrounded = false;
LK.getSound('jump').play();
}
};
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
self.y += self.velocityY;
// Check ground collision
if (self.y >= self.groundY) {
self.y = self.groundY;
self.velocityY = 0;
self.isGrounded = true;
}
// Check if fallen off screen (game over condition)
if (self.y > 2732 + 100) {
LK.showGameOver();
}
};
return self;
});
var FlyingObstacle = Container.expand(function () {
var self = Container.call(this);
var flyingGraphics = self.attachAsset('flying_obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
self.x += -gameSpeed;
};
return self;
});
var GroundTile = Container.expand(function () {
var self = Container.call(this);
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
self.update = function () {
self.x += -gameSpeed;
};
return self;
});
var Obstacle = Container.expand(function (size) {
var self = Container.call(this);
// Determine which asset to use based on size parameter
var assetId = size === 'large' ? 'obstacle_large' : 'obstacle_small';
var obstacleGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 1.0
});
self.size = size;
self.update = function () {
self.x += -gameSpeed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xf7f7f7
});
/****
* Game Code
****/
// Game variables
var dinosaur;
var groundTiles = [];
var obstacles = [];
var flyingObstacle = null;
var flyingObstacleSpawnTimer = 0;
var flyingObstacleHeight = 2000; // Just above ground obstacles (flying obstacle height is 60)
var groundY = 2732 - 200; // Ground level
var gameSpeed = 6;
var distanceScore = 0;
var obstacleSpawnTimer = 0;
var minObstacleSpacing = 400;
var maxObstacles = 3;
// Create score display
var scoreTxt = new Text2('0', {
size: 80,
fill: 0x333333
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
// Create dinosaur
dinosaur = game.addChild(new Dinosaur());
dinosaur.x = 400;
dinosaur.y = groundY;
dinosaur.groundY = groundY;
// Create initial ground tiles
function createGroundTile(x) {
var tile = new GroundTile();
tile.x = x;
tile.y = groundY;
return tile;
}
// Create obstacle function
function createObstacle(x) {
var sizes = ['small', 'large'];
var randomSize = sizes[Math.floor(Math.random() * sizes.length)];
var obstacle = new Obstacle(randomSize);
obstacle.x = x;
obstacle.y = groundY;
return obstacle;
}
// Create flying obstacle function
function createFlyingObstacle(x) {
var obstacle = new FlyingObstacle();
obstacle.x = x;
obstacle.y = flyingObstacleHeight;
return obstacle;
}
// Create initial ground tiles to cover screen width plus extra for scrolling
for (var i = 0; i < 15; i++) {
var tile = game.addChild(createGroundTile(i * 200));
groundTiles.push(tile);
}
// Game input handling
game.down = function (x, y, obj) {
dinosaur.jump();
};
// Main game update loop
game.update = function () {
// Update distance score
distanceScore += gameSpeed;
var displayScore = Math.floor(distanceScore / 10);
LK.setScore(displayScore);
scoreTxt.setText(displayScore);
// Manage ground tiles
for (var i = groundTiles.length - 1; i >= 0; i--) {
var tile = groundTiles[i];
// Remove tiles that have scrolled off screen
if (tile.x < -250) {
tile.destroy();
groundTiles.splice(i, 1);
}
}
// Add new ground tiles as needed
var lastTile = groundTiles[groundTiles.length - 1];
if (lastTile && lastTile.x + 200 < 2048 + 200) {
var newTile = game.addChild(createGroundTile(lastTile.x + 200));
groundTiles.push(newTile);
}
// Manage obstacles
for (var k = obstacles.length - 1; k >= 0; k--) {
var obstacle = obstacles[k];
// Remove obstacles that have scrolled off screen
if (obstacle.x < -200) {
obstacle.destroy();
obstacles.splice(k, 1);
}
}
// Manage flying obstacle
if (flyingObstacle) {
// Remove flying obstacle if it's off screen
if (flyingObstacle.x < -200) {
flyingObstacle.destroy();
flyingObstacle = null;
}
}
// Spawn flying obstacle
flyingObstacleSpawnTimer++;
if (!flyingObstacle && flyingObstacleSpawnTimer > 300) {
// Spawn every 5 seconds
flyingObstacle = game.addChild(createFlyingObstacle(2048 + 100));
flyingObstacleSpawnTimer = 0;
}
// Spawn new obstacles
obstacleSpawnTimer++;
var baseSpawnTime = 120; // Base spawn time (2 seconds at 60fps)
var spawnVariation = 120; // ±2 second variation for more varied spacing
var currentSpawnTime = baseSpawnTime + Math.floor(Math.random() * spawnVariation * 2) - spawnVariation;
if (obstacles.length < maxObstacles && obstacleSpawnTimer > currentSpawnTime) {
var canSpawn = true;
var spawnX = 2048 + 100;
// Check if there's enough space from last obstacle
if (obstacles.length > 0) {
var lastObstacle = obstacles[obstacles.length - 1];
if (lastObstacle.x > spawnX - minObstacleSpacing) {
canSpawn = false;
}
}
if (canSpawn) {
// Add random horizontal offset to vary spacing
var offsetRange = 200; // ±200 pixel variation
var horizontalOffset = Math.floor(Math.random() * offsetRange * 2) - offsetRange;
var newObstacle = game.addChild(createObstacle(spawnX + horizontalOffset));
obstacles.push(newObstacle);
// Reset timer with additional random offset for next spawn
obstacleSpawnTimer = -Math.floor(Math.random() * 60); // Start next timer with up to 1 second head start
}
}
// Gradually increase game speed for difficulty progression
if (LK.ticks % 600 === 0) {
// Every 10 seconds at 60fps
gameSpeed += 0.5;
for (var j = 0; j < groundTiles.length; j++) {
groundTiles[j].scrollSpeed = -gameSpeed;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -201,9 +201,12 @@
canSpawn = false;
}
}
if (canSpawn) {
- var newObstacle = game.addChild(createObstacle(spawnX));
+ // Add random horizontal offset to vary spacing
+ var offsetRange = 200; // ±200 pixel variation
+ var horizontalOffset = Math.floor(Math.random() * offsetRange * 2) - offsetRange;
+ var newObstacle = game.addChild(createObstacle(spawnX + horizontalOffset));
obstacles.push(newObstacle);
// Reset timer with additional random offset for next spawn
obstacleSpawnTimer = -Math.floor(Math.random() * 60); // Start next timer with up to 1 second head start
}
dont crop parts of the image, show full image, give black outline
make him be flying with both wings, dont crop the image
tall rock, brown, very solid, really thick black outline
smaller rock, more rounded, really thick black outline, same brown color
white rounded cloud, really thick black outline
Simple golden coin, rounded, shiny, big black outline, funny
Same dinosaur but with wings down
Same dinosaur but legs running