User prompt
biraz daha yukarı zıplasın
User prompt
ayakları kıpırdasın
User prompt
dinozora yürüme efekti ver
User prompt
biraz daha yukarı zıplasın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
click tuşuna bastığımızda yukarı zıplasın
User prompt
dinozor click tuşuna bastığımızda yukarı zıplasın
User prompt
yukarıda sadece salise hızıyla sayan sayaç olsun ve sonsuza kadar
User prompt
biraz dah yukarı zıplasın
User prompt
dinozor daha yükseğe zıplasın
User prompt
Please fix the bug: 'TypeError: scoreTxt.setFill is not a function' in or related to this line: 'scoreTxt.setFill(nightMode ? "#FFFFFF" : "#000000");' Line Number: 323
User prompt
click tuşu zıplama tuşu olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Dino Dash: Offline Adventure
Initial prompt
CLASSİC İNTERNET OLMADIĞINDA ÇIKAN DİNO OYUNLARINDAN YAP
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
highScore: 0
});
/****
* Classes
****/
var Cloud = Container.expand(function () {
var self = Container.call(this);
// Properties
self.speed = 1;
// Create cloud graphics
var cloudGraphics = self.attachAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
// Update method
self.update = function () {
self.x -= self.speed;
};
return self;
});
var Dino = Container.expand(function () {
var self = Container.call(this);
// Properties
self.isJumping = false;
self.isDucking = false;
self.jumpVelocity = 0;
self.gravity = 0.8;
self.groundY = 0; // Will be set when positioning
// Create dino graphics
var dinoGraphics = self.attachAsset('dino', {
anchorX: 0.5,
anchorY: 1.0
});
// Jump method
self.jump = function () {
if (!self.isJumping) {
self.isJumping = true;
self.jumpVelocity = -30;
LK.getSound('jump').play();
}
};
// Duck method
self.duck = function () {
if (!self.isDucking && !self.isJumping) {
self.isDucking = true;
dinoGraphics.height = 50; // Half height when ducking
}
};
// Stop ducking
self.stopDucking = function () {
if (self.isDucking) {
self.isDucking = false;
dinoGraphics.height = 100; // Normal height
}
};
// Reset dino state
self.reset = function () {
self.isJumping = false;
self.isDucking = false;
self.jumpVelocity = 0;
self.y = self.groundY;
dinoGraphics.height = 100;
};
// Update method
self.update = function () {
if (self.isJumping) {
self.y += self.jumpVelocity;
self.jumpVelocity += self.gravity;
// Check if landed
if (self.y >= self.groundY) {
self.y = self.groundY;
self.isJumping = false;
self.jumpVelocity = 0;
}
}
};
// Hit box for collision detection
self.getHitBox = function () {
return {
x: self.x - dinoGraphics.width / 2,
y: self.y - dinoGraphics.height,
width: dinoGraphics.width,
height: dinoGraphics.height
};
};
return self;
});
var Obstacle = Container.expand(function (type) {
var self = Container.call(this);
// Properties
self.type = type || 'cactus'; // 'cactus' or 'pterodactyl'
self.speed = 8;
// Create obstacle graphics
var graphics;
if (self.type === 'cactus') {
graphics = self.attachAsset('cactus', {
anchorX: 0.5,
anchorY: 1.0
});
} else {
graphics = self.attachAsset('pterodactyl', {
anchorX: 0.5,
anchorY: 0.5
});
}
// Update method
self.update = function () {
self.x -= self.speed;
};
// Increase speed method
self.setSpeed = function (newSpeed) {
self.speed = newSpeed;
};
// Hit box for collision detection
self.getHitBox = function () {
if (self.type === 'cactus') {
return {
x: self.x - graphics.width / 2,
y: self.y - graphics.height,
width: graphics.width,
height: graphics.height
};
} else {
return {
x: self.x - graphics.width / 2,
y: self.y - graphics.height / 2,
width: graphics.width,
height: graphics.height
};
}
};
return self;
});
var Timer = Container.expand(function () {
var self = Container.call(this);
// Properties
self.milliseconds = 0;
// Create timer text
var timerText = new Text2('0', {
size: 100,
fill: 0x000000
});
timerText.anchor.set(0.5, 0.5);
self.addChild(timerText);
// Update method
self.update = function () {
self.milliseconds += 1000 / 60; // Approximately 16.67ms per frame at 60fps
timerText.setText((self.milliseconds / 1000).toFixed(3));
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create stopwatch timer
var timer = new Timer();
timer.x = 2048 / 2;
timer.y = 2732 / 2;
game.addChild(timer);
// Set background color
game.setBackgroundColor(0x000000);
// Game update loop
game.update = function () {
// Update timer
timer.update();
}; ===================================================================
--- original.js
+++ change.js
@@ -137,230 +137,45 @@
}
};
return self;
});
+var Timer = Container.expand(function () {
+ var self = Container.call(this);
+ // Properties
+ self.milliseconds = 0;
+ // Create timer text
+ var timerText = new Text2('0', {
+ size: 100,
+ fill: 0x000000
+ });
+ timerText.anchor.set(0.5, 0.5);
+ self.addChild(timerText);
+ // Update method
+ self.update = function () {
+ self.milliseconds += 1000 / 60; // Approximately 16.67ms per frame at 60fps
+ timerText.setText((self.milliseconds / 1000).toFixed(3));
+ };
+ return self;
+});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0xFFFFFF
+ backgroundColor: 0x000000
});
/****
* Game Code
****/
-// Game state
-var gameRunning = false;
-var gameSpeed = 8;
-var score = 0;
-var highScore = storage.highScore || 0;
-var lastObstacleTime = 0;
-var nightMode = false;
-var nextSpeedIncrease = 500;
-var nextCloudTime = 0;
-// Game objects
-var dino;
-var ground;
-var obstacles = [];
-var clouds = [];
-// UI elements
-var scoreTxt;
-var highScoreTxt;
-var tapToStartTxt;
-// Ground
-ground = LK.getAsset('ground', {
- anchorX: 0,
- anchorY: 0
-});
-ground.y = 2732 - 200; // Position ground near the bottom
-game.addChild(ground);
-// Score text
-scoreTxt = new Text2('0', {
- size: 60,
- fill: 0x000000
-});
-scoreTxt.anchor.set(1.0, 0);
-scoreTxt.x = 2048 - 30;
-scoreTxt.y = 30;
-game.addChild(scoreTxt);
-// High score text
-highScoreTxt = new Text2('HI: ' + highScore, {
- size: 60,
- fill: 0x888888
-});
-highScoreTxt.anchor.set(1.0, 0);
-highScoreTxt.x = 2048 - 30;
-highScoreTxt.y = 100;
-game.addChild(highScoreTxt);
-// Tap to start text
-tapToStartTxt = new Text2('TAP TO START', {
- size: 80,
- fill: 0x000000
-});
-tapToStartTxt.anchor.set(0.5, 0.5);
-tapToStartTxt.x = 2048 / 2;
-tapToStartTxt.y = 2732 / 2;
-game.addChild(tapToStartTxt);
-// Initialize dino
-dino = new Dino();
-dino.x = 300;
-dino.groundY = ground.y;
-dino.y = dino.groundY;
-game.addChild(dino);
-// Start the game
-function startGame() {
- if (!gameRunning) {
- gameRunning = true;
- gameSpeed = 8;
- score = 0;
- nextSpeedIncrease = 500;
- // Reset dino
- dino.reset();
- // Clear obstacles
- for (var i = obstacles.length - 1; i >= 0; i--) {
- obstacles[i].destroy();
- }
- obstacles = [];
- // Clear clouds
- for (var i = clouds.length - 1; i >= 0; i--) {
- clouds[i].destroy();
- }
- clouds = [];
- // Update UI
- tapToStartTxt.visible = false;
- scoreTxt.setText('0');
- // Set background to day mode
- game.setBackgroundColor(0xFFFFFF);
- nightMode = false;
- }
-}
-// Collision detection
-function checkCollision(dinoHitBox, obstacleHitBox) {
- return !(dinoHitBox.x + dinoHitBox.width < obstacleHitBox.x || dinoHitBox.x > obstacleHitBox.x + obstacleHitBox.width || dinoHitBox.y + dinoHitBox.height < obstacleHitBox.y || dinoHitBox.y > obstacleHitBox.y + obstacleHitBox.height);
-}
-// Spawn a new obstacle
-function spawnObstacle() {
- var type = Math.random() > 0.3 ? 'cactus' : 'pterodactyl';
- var obstacle = new Obstacle(type);
- // Position it
- obstacle.x = 2048 + 100;
- if (type === 'cactus') {
- obstacle.y = ground.y;
- } else {
- // Pterodactyls can be at different heights
- var height = Math.random() > 0.5 ? 200 : 300;
- obstacle.y = ground.y - height;
- }
- obstacle.setSpeed(gameSpeed);
- obstacles.push(obstacle);
- game.addChild(obstacle);
-}
-// Spawn a new cloud
-function spawnCloud() {
- var cloud = new Cloud();
- cloud.x = 2048 + 100;
- cloud.y = ground.y - 300 - Math.random() * 200;
- clouds.push(cloud);
- game.addChild(cloud);
-}
-// Game over
-function gameOver() {
- gameRunning = false;
- LK.getSound('collision').play();
- // Update high score
- if (score > highScore) {
- highScore = score;
- storage.highScore = highScore;
- highScoreTxt.setText('HI: ' + highScore);
- }
- tapToStartTxt.setText('GAME OVER - TAP TO RESTART');
- tapToStartTxt.visible = true;
- // Show game over screen
- LK.showGameOver();
-}
-// Game input handlers
-game.down = function (x, y, obj) {
- if (!gameRunning) {
- startGame();
- } else {
- // Any click/tap triggers jump
- dino.jump();
- }
-};
-game.up = function (x, y, obj) {
- // Stop ducking when released
- if (gameRunning) {
- dino.stopDucking();
- }
-};
+// Create stopwatch timer
+var timer = new Timer();
+timer.x = 2048 / 2;
+timer.y = 2732 / 2;
+game.addChild(timer);
+// Set background color
+game.setBackgroundColor(0x000000);
// Game update loop
game.update = function () {
- if (!gameRunning) {
- return;
- }
- // Update score
- score++;
- if (score % 10 === 0) {
- scoreTxt.setText(Math.floor(score / 10));
- }
- // Day/night transition every 1000 points
- if (score % 1000 === 0 && score > 0) {
- nightMode = !nightMode;
- game.setBackgroundColor(nightMode ? 0x333333 : 0xFFFFFF);
- scoreTxt.setText(scoreTxt.text, {
- fill: nightMode ? "#FFFFFF" : "#000000"
- });
- // Play milestone sound
- LK.getSound('milestone').play();
- }
- // Increase speed every 500 points
- if (score >= nextSpeedIncrease) {
- gameSpeed += 0.5;
- nextSpeedIncrease += 500;
- // Update speed of existing obstacles
- for (var i = 0; i < obstacles.length; i++) {
- obstacles[i].setSpeed(gameSpeed);
- }
- }
- // Spawn obstacles
- if (LK.ticks - lastObstacleTime > 60 + Math.random() * 60) {
- spawnObstacle();
- lastObstacleTime = LK.ticks;
- }
- // Spawn clouds
- if (LK.ticks - nextCloudTime > 180) {
- spawnCloud();
- nextCloudTime = LK.ticks + Math.random() * 180;
- }
- // Update dino
- dino.update();
- // Collision detection and update for obstacles
- for (var i = obstacles.length - 1; i >= 0; i--) {
- obstacles[i].update();
- // Check collision with dino
- var dinoHitBox = dino.getHitBox();
- var obstacleHitBox = obstacles[i].getHitBox();
- if (checkCollision(dinoHitBox, obstacleHitBox)) {
- gameOver();
- return;
- }
- // Remove obstacles that are off-screen
- if (obstacles[i].x < -100) {
- obstacles[i].destroy();
- obstacles.splice(i, 1);
- }
- }
- // Update clouds
- for (var i = clouds.length - 1; i >= 0; i--) {
- clouds[i].update();
- // Remove clouds that are off-screen
- if (clouds[i].x < -150) {
- clouds[i].destroy();
- clouds.splice(i, 1);
- }
- }
-};
-// Play background music
-LK.playMusic('bgMusic', {
- volume: 0.3
-});
\ No newline at end of file
+ // Update timer
+ timer.update();
+};
\ No newline at end of file