User prompt
arabanın tekerleklerini yapma. zaten asset olarak arabanın tekerlekleri bulunmakta. onun yerine sadece canları yap
User prompt
Karakter bir engele çarptığında 2 saniyeliğine yavaşlasın
User prompt
eğer tüm canları doluysa bile bir can daha eklesin. Ama en fazla can alma sayısı 9 olsun
User prompt
yol üzerinde toplanabilir canlar olsun. Bu canları aldığımızda canımız artsın
User prompt
can gittikten sonra ekranda kırmızı ışık yanmasın. Oyuncunun engelleri görmesini çok zorlaştırıyor
User prompt
canların yerini değiştir. sol alt köşeye koy
User prompt
oyuna can ekle. 3 tane olsun. canlar bittiğinde oyun bitsin
User prompt
yaptığımız en yüksek skoru kaydetsin ve en yüksek skor kısmında o yazsın ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
En yüksek skor tablosunun aşağısında yaptığımız en yüksek skor bulunsun
User prompt
oyunda en son yaptığımız skoru görebilelim
User prompt
engellerin arasını biraz daha aç
User prompt
bazı engellerin arasını biraz daha aç, bazıları ise böyle kalsın.
User prompt
Please fix the bug: 'TypeError: LK.submitScore is not a function' in or related to this line: 'LK.submitScore(score); // Submit score to leaderboard' Line Number: 189
User prompt
oyuna skor tablosu ekle
User prompt
engellerim arasını biraz daha aç
User prompt
oyunu yavaş başlatıp daha sonra hızlanmasını sağla
User prompt
zıplamıyor
Code edit (1 edits merged)
Please save this source code
User prompt
Jumping Car: Endless Road
Initial prompt
düz sonsuz platformda engellerden zıplayan bir araba oyunu
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
highestScore: 0
});
/****
* Classes
****/
// Car class
var Car = Container.expand(function () {
var self = Container.call(this);
// Car body
var carBody = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 1
});
// Wheels
var wheelOffsetY = 20;
var wheelOffsetX = 70;
var leftWheel = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5,
x: -wheelOffsetX,
y: -wheelOffsetY
});
var rightWheel = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5,
x: wheelOffsetX,
y: -wheelOffsetY
});
// Physics
self.vy = 0; // vertical velocity
self.isJumping = false;
// Car size for collision
self.bodyWidth = carBody.width;
self.bodyHeight = carBody.height;
// Update method
self.update = function () {
// Gravity and jump physics
self.y += self.vy;
if (self.y < groundY) {
self.vy += gravity;
if (self.y > groundY) {
self.y = groundY;
self.vy = 0;
self.isJumping = false;
}
} else if (self.y > groundY) {
self.y = groundY;
self.vy = 0;
self.isJumping = false;
}
};
// Jump method
self.jump = function () {
if (!self.isJumping && self.y >= groundY) {
self.vy = jumpVelocity;
self.isJumping = true;
LK.getSound('jump').play();
}
};
return self;
});
// Obstacle class
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obs = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 1
});
self.width = obs.width;
self.height = obs.height;
// For collision
self.bodyWidth = obs.width;
self.bodyHeight = obs.height;
// Update method
self.update = function () {
self.x -= gameSpeed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb // sky blue
});
/****
* Game Code
****/
// Jump sound
// Road: dark gray box
// Obstacle: red box
// Wheel: black ellipse
// Car: blue box
// Constants
var groundY = 2200; // y position of the road top
var gravity = 4.5;
var jumpVelocity = -80;
var initialGameSpeed = 24;
var maxGameSpeed = 60;
var gameSpeed = initialGameSpeed;
var obstacleMinGap = 500;
var obstacleMaxGap = 1100;
var obstacleMinY = groundY;
var obstacleMaxY = groundY;
var minObstacleHeight = 120;
var maxObstacleHeight = 220;
// Road
var road = LK.getAsset('road', {
anchorX: 0,
anchorY: 0,
x: 0,
y: groundY
});
game.addChild(road);
// Car
var car = new Car();
car.x = 400;
car.y = groundY;
game.addChild(car);
// Obstacles
var obstacles = [];
var nextObstacleX = 2048 + 400;
// Score
var score = 0;
var lastScore = 0;
var lives = 3; // Start with 3 lives
var maxLives = 3;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Lives display
var livesTxt = new Text2('', {
size: 90,
fill: 0xff4444
});
livesTxt.anchor.set(0.5, 0);
livesTxt.y = scoreTxt.height + 80;
LK.gui.top.addChild(livesTxt);
function updateLivesDisplay() {
var hearts = '';
for (var i = 0; i < lives; i++) hearts += '❤ ';
for (var i = lives; i < maxLives; i++) hearts += '♡ ';
livesTxt.setText("Can: " + hearts.trim());
}
updateLivesDisplay();
// Last score display
var lastScoreTxt = new Text2('', {
size: 70,
fill: 0xFFD700
});
lastScoreTxt.anchor.set(0.5, 0);
lastScoreTxt.y = scoreTxt.height + 10;
LK.gui.top.addChild(lastScoreTxt);
// Highest score display (below leaderboard)
var highestScore = storage.highestScore || 0;
var highestScoreTxt = new Text2('', {
size: 70,
fill: 0x00ffcc
});
highestScoreTxt.anchor.set(0.5, 0);
highestScoreTxt.y = lastScoreTxt.y + lastScoreTxt.height + 10;
LK.gui.top.addChild(highestScoreTxt);
// Difficulty
var ticksSinceStart = 0;
// Touch handler: tap anywhere to jump
game.down = function (x, y, obj) {
car.jump();
};
// Main update loop
game.update = function () {
ticksSinceStart++;
// Increase game speed smoothly over time for gradual acceleration
if (gameSpeed < maxGameSpeed) {
// Accelerate slowly at first, then faster as time goes on
// The divisor controls how quickly speed ramps up (higher = slower ramp)
var speedup = ticksSinceStart / 60 * 0.18; // 0.18 px/frame/sec, adjust for feel
gameSpeed = initialGameSpeed + speedup;
if (gameSpeed > maxGameSpeed) gameSpeed = maxGameSpeed;
}
// Update car
car.update();
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Remove if off screen
if (obs.x < -200) {
obs.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision detection (AABB)
var carLeft = car.x - car.bodyWidth / 2 + 20;
var carRight = car.x + car.bodyWidth / 2 - 20;
var carTop = car.y - car.bodyHeight;
var carBottom = car.y;
var obsLeft = obs.x - obs.bodyWidth / 2;
var obsRight = obs.x + obs.bodyWidth / 2;
var obsTop = obs.y - obs.bodyHeight;
var obsBottom = obs.y;
var intersect = !(carRight < obsLeft || carLeft > obsRight || carBottom < obsTop + 10 || carTop > obsBottom - 10);
if (intersect) {
LK.effects.flashScreen(0xff0000, 800);
lives--;
updateLivesDisplay();
if (lives <= 0) {
LK.setScore(score); // Ensure latest score is set
lastScore = score;
lastScoreTxt.setText("Son Skor: " + lastScore);
// Update highest score if needed
if (score > highestScore) {
highestScore = score;
storage.highestScore = highestScore;
highestScoreTxt.setText("En Yüksek Skor: " + highestScore);
} else {
// Always show the stored value if not beaten
highestScoreTxt.setText("En Yüksek Skor: " + (storage.highestScore || highestScore));
}
LK.showGameOver();
return;
} else {
// Remove the obstacle and let the game continue
obs.destroy();
obstacles.splice(i, 1);
continue;
}
}
// Score: passed obstacle
if (!obs.passed && obs.x + obs.bodyWidth / 2 < car.x - car.bodyWidth / 2) {
obs.passed = true;
score++;
scoreTxt.setText(score);
}
}
// Spawn new obstacles
if (obstacles.length === 0 || obstacles.length > 0 && obstacles[obstacles.length - 1].x < 2048 - getNextGap()) {
var obs = new Obstacle();
obs.x = 2048 + 100;
obs.y = groundY;
game.addChild(obs);
obstacles.push(obs);
}
};
// Helper: get next gap (randomized, gets smaller as speed increases)
function getNextGap() {
var minGap = obstacleMinGap + 400 - Math.floor((gameSpeed - initialGameSpeed) * 10);
var maxGap = obstacleMaxGap + 600 - Math.floor((gameSpeed - initialGameSpeed) * 12);
if (minGap < 720) minGap = 720;
if (maxGap < 1000) maxGap = 1000;
// 30% chance to make a much wider gap, otherwise normal
if (Math.random() < 0.3) {
// Extra wide gap
var extraMin = maxGap + 300;
var extraMax = maxGap + 900;
return extraMin + Math.floor(Math.random() * (extraMax - extraMin));
} else {
// Normal gap
return minGap + Math.floor(Math.random() * (maxGap - minGap));
}
}
// Reset score and lives on game start
LK.setScore(0);
score = 0;
lives = maxLives;
scoreTxt.setText(score);
lastScoreTxt.setText("");
updateLivesDisplay();
if ((storage.highestScore || highestScore) > 0) {
highestScoreTxt.setText("En Yüksek Skor: " + (storage.highestScore || highestScore));
} else {
highestScoreTxt.setText("");
}
// Show leaderboard button in the top GUI, right side
var leaderboardBtn = new Text2("🏆", {
size: 110,
fill: 0xffff00
});
leaderboardBtn.anchor.set(1, 0); // right-top
leaderboardBtn.x = -40; // offset from right edge
leaderboardBtn.y = 0;
leaderboardBtn.interactive = true;
leaderboardBtn.buttonMode = true;
leaderboardBtn.down = function (x, y, obj) {
LK.showLeaderboard();
};
LK.gui.topRight.addChild(leaderboardBtn); ===================================================================
--- original.js
+++ change.js
@@ -130,14 +130,31 @@
var nextObstacleX = 2048 + 400;
// Score
var score = 0;
var lastScore = 0;
+var lives = 3; // Start with 3 lives
+var maxLives = 3;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
+// Lives display
+var livesTxt = new Text2('', {
+ size: 90,
+ fill: 0xff4444
+});
+livesTxt.anchor.set(0.5, 0);
+livesTxt.y = scoreTxt.height + 80;
+LK.gui.top.addChild(livesTxt);
+function updateLivesDisplay() {
+ var hearts = '';
+ for (var i = 0; i < lives; i++) hearts += '❤ ';
+ for (var i = lives; i < maxLives; i++) hearts += '♡ ';
+ livesTxt.setText("Can: " + hearts.trim());
+}
+updateLivesDisplay();
// Last score display
var lastScoreTxt = new Text2('', {
size: 70,
fill: 0xFFD700
@@ -194,22 +211,31 @@
var obsBottom = obs.y;
var intersect = !(carRight < obsLeft || carLeft > obsRight || carBottom < obsTop + 10 || carTop > obsBottom - 10);
if (intersect) {
LK.effects.flashScreen(0xff0000, 800);
- LK.setScore(score); // Ensure latest score is set
- lastScore = score;
- lastScoreTxt.setText("Son Skor: " + lastScore);
- // Update highest score if needed
- if (score > highestScore) {
- highestScore = score;
- storage.highestScore = highestScore;
- highestScoreTxt.setText("En Yüksek Skor: " + highestScore);
+ lives--;
+ updateLivesDisplay();
+ if (lives <= 0) {
+ LK.setScore(score); // Ensure latest score is set
+ lastScore = score;
+ lastScoreTxt.setText("Son Skor: " + lastScore);
+ // Update highest score if needed
+ if (score > highestScore) {
+ highestScore = score;
+ storage.highestScore = highestScore;
+ highestScoreTxt.setText("En Yüksek Skor: " + highestScore);
+ } else {
+ // Always show the stored value if not beaten
+ highestScoreTxt.setText("En Yüksek Skor: " + (storage.highestScore || highestScore));
+ }
+ LK.showGameOver();
+ return;
} else {
- // Always show the stored value if not beaten
- highestScoreTxt.setText("En Yüksek Skor: " + (storage.highestScore || highestScore));
+ // Remove the obstacle and let the game continue
+ obs.destroy();
+ obstacles.splice(i, 1);
+ continue;
}
- LK.showGameOver();
- return;
}
// Score: passed obstacle
if (!obs.passed && obs.x + obs.bodyWidth / 2 < car.x - car.bodyWidth / 2) {
obs.passed = true;
@@ -242,13 +268,15 @@
// Normal gap
return minGap + Math.floor(Math.random() * (maxGap - minGap));
}
}
-// Reset score on game start
+// Reset score and lives on game start
LK.setScore(0);
score = 0;
+lives = maxLives;
scoreTxt.setText(score);
lastScoreTxt.setText("");
+updateLivesDisplay();
if ((storage.highestScore || highestScore) > 0) {
highestScoreTxt.setText("En Yüksek Skor: " + (storage.highestScore || highestScore));
} else {
highestScoreTxt.setText("");
red car and driver. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
sarı renkli "Stop" tabelası. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
a human. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
altın para, berrak. In-Game asset. 2d. High contrast. No shadows
pixelart, cloud. In-Game asset. 2d. High contrast. No shadows
dark green car and driver. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
blue car and driver. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat