Initial prompt
Chrome Dino T-Rex game
User prompt
Oyunu sil
User prompt
Oyunun kodlarını tamamen sil
User prompt
Chrome dino trex oyunu yaz
User prompt
Kuşlar ve kaktüsler dsha hızlı olmalı
User prompt
Skor metni ekle
User prompt
Increase score by +1 in 7 seconds
User prompt
Increase score by +1 in 7 split seconds
User prompt
Engelleri hızlandıe
User prompt
Yerçekimi gücünü arttır
User prompt
Daha fazla zıpla
User prompt
Engelleri hızlandır
User prompt
Engelleri hızlandır
User prompt
Kuş biraz daha yüksekte olmalı
User prompt
Kuşlar daha yüksekte olmalı kaktüslerin, yeri aynı kalmalı
User prompt
Kuşları biraz yükselt ama kaktüslerin yeri aynı kalsın
User prompt
Engelleri hızlandır
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Dino class representing the player character
var Dino = Container.expand(function () {
var self = Container.call(this);
var dinoGraphics = self.attachAsset('dino', {
anchorX: 0.5,
anchorY: 0.5
});
self.isJumping = false;
self.isDucking = false;
self.jumpSpeed = -20;
self.gravity = 1;
self.yVelocity = 0;
self.update = function () {
if (self.isJumping) {
self.yVelocity += self.gravity;
self.y += self.yVelocity;
if (self.y >= 200) {
// Ground level
self.y = 200;
self.isJumping = false;
self.yVelocity = 0;
}
}
};
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.yVelocity = self.jumpSpeed;
}
};
self.duck = function (isDucking) {
self.isDucking = isDucking;
dinoGraphics.scaleY = isDucking ? 0.5 : 1;
};
});
// Obstacle class for cacti and birds
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
self.update = function () {
self.x += self.speed;
if (self.x < -100) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB // Sky blue background
});
/****
* Game Code
****/
var dino = game.addChild(new Dino());
dino.x = 200;
dino.y = 200;
var obstacles = [];
var score = 0;
var scoreTxt = new Text2('0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2048;
obstacle.y = Math.random() > 0.5 ? 200 : 150; // Randomly place on ground or slightly above
obstacles.push(obstacle);
game.addChild(obstacle);
}
game.down = function (x, y, obj) {
dino.jump();
};
game.up = function (x, y, obj) {
dino.duck(false);
};
game.update = function () {
dino.update();
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].update();
if (dino.intersects(obstacles[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
if (obstacles[i].x < -100) {
obstacles[i].destroy();
obstacles.splice(i, 1);
score++;
scoreTxt.setText(score);
}
}
if (LK.ticks % 120 == 0) {
spawnObstacle();
}
};