User prompt
stretch the background to fit the entire playspace
User prompt
make sure the background is static
User prompt
Please fix the bug: 'ReferenceError: backbackground1 is not defined' in or related to this line: 'backbackground1.move();' Line Number: 124
User prompt
apply the background, i dont see it
User prompt
i want to be able to imagine a background, create a class for me
User prompt
rather than a yellow background, i want to be able to render one
User prompt
fix the ground, i dont see it
User prompt
tile the ground properly underneath the dinosaur all the way to the edge of the playspace
User prompt
show the score in the center of the screen
User prompt
this game should play exactly like: Google Chrome's unblocked offline game about dinosaur T-rex running through the desert, jumping over cactuses and dodging pterodactyls.
Initial prompt
T-Rex Run!
===================================================================
--- original.js
+++ change.js
@@ -1,101 +1,120 @@
-/****
+/****
* Classes
****/
var Cactus = Container.expand(function () {
- var self = Container.call(this);
- var cactusGraphics = self.attachAsset('cactus', {
- anchorX: 0.5,
- anchorY: 1.0
- });
- self.move = function () {
- self.x -= game.speed;
- };
+ var self = Container.call(this);
+ var cactusGraphics = self.attachAsset('cactus', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ 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.isJumping = true;
- self.jumpSpeed = -15;
- }
- };
- 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;
- }
- }
- };
+ 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 = -15;
+ }
+ };
+ 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;
+ }
+ };
});
+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 Pterodactyl = Container.expand(function () {
- var self = Container.call(this);
- var pterodactylGraphics = self.attachAsset('pterodactyl', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.move = function () {
- self.x -= game.speed;
- };
+ var self = Container.call(this);
+ var pterodactylGraphics = self.attachAsset('pterodactyl', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.move = function () {
+ self.x -= game.speed;
+ };
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0xF0E68C // Desert yellow
+ backgroundColor: 0xF0E68C // Desert yellow
});
-/****
+/****
* Game Code
****/
+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();
+ dinosaur.jump();
});
LK.on('tick', function () {
- dinosaur.update();
- game.score += 1 / 60; // Add score every tick, 60 ticks per second
- LK.setScore(Math.floor(game.score)); // Update the score display
- // Handle obstacles
- if (LK.ticks % 120 == 0) {
- // Add a new obstacle every 2 seconds
- var obstacle;
- if (Math.random() < 0.5) {
- obstacle = new Cactus();
- } else {
- obstacle = new Pterodactyl();
- obstacle.y = game.floorLevel - Math.random() * 300 - 150; // Random height for pterodactyl
- }
- obstacle.x = 2048;
- game.obstacles.push(obstacle);
- game.addChild(obstacle);
- }
- 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);
- }
- }
+ dinosaur.update();
+ game.score += 1 / 60; // Add score every tick, 60 ticks per second
+ LK.setScore(Math.floor(game.score)); // Update the score display
+ // Move the ground
+ ground1.move();
+ ground2.move();
+ // Handle obstacles
+ if (LK.ticks % 120 == 0) {
+ // Add a new obstacle every 2 seconds
+ var obstacle;
+ if (Math.random() < 0.5) {
+ obstacle = new Cactus();
+ } 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);
+ }
+ 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);
+ }
+ }
});
\ No newline at end of file
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.