User prompt
araba dumanı 5 saniye dursun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
araba bir arabaya çarptıktan sonra dursun
User prompt
araba kaza yaptığı yerde dursun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kaza yapınca 3 saniye bekleyelim ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
kaza yapınca arabadan duman çıksın ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
araba seçme kaldırılsın
User prompt
araba seçme özelliği olsun
User prompt
Zorda araba trafiğini arttır
User prompt
Kolayda 1x hızda kalsın ortada 2x hız olsun zorda 5x hız olsun
User prompt
Kolay orta zor dereceleri olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Turbo Drift Challenge
Initial prompt
Araba oyunu yap
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var EnemyCar = Container.expand(function () { var self = Container.call(this); // Randomly select car type var carTypes = ['enemyCar1', 'enemyCar2', 'enemyCar3']; var selectedType = carTypes[Math.floor(Math.random() * carTypes.length)]; var carGraphics = self.attachAsset(selectedType, { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.checkedNearMiss = false; self.update = function () { self.y += self.speed; }; return self; }); var PlayerCar = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset('playerCar', { anchorX: 0.5, anchorY: 0.5 }); self.targetX = 2048 / 2; self.currentX = 2048 / 2; self.update = function () { // Smooth movement towards target position var diff = self.targetX - self.currentX; self.currentX += diff * 0.15; self.x = self.currentX; }; return self; }); var RoadLine = Container.expand(function () { var self = Container.call(this); var lineGraphics = self.attachAsset('roadLine', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2d2d2d }); /**** * Game Code ****/ // Game variables var player; var enemyCars = []; var roadLines = []; var gameSpeed = 1; var distanceScore = 0; var bonusScore = 0; var totalScore = 0; var spawnTimer = 0; var roadLineTimer = 0; var speedIncreaseTimer = 0; // Difficulty system var currentDifficulty = 'medium'; // 'easy', 'medium', 'hard' var gameStarted = false; var difficultySettings = { easy: { initialSpeed: 0.8, speedIncrease: 0.1, spawnRateBase: 80, enemySpeedMultiplier: 1.5, speedIncreaseInterval: 900 // 15 seconds }, medium: { initialSpeed: 1.0, speedIncrease: 0.2, spawnRateBase: 60, enemySpeedMultiplier: 2.0, speedIncreaseInterval: 600 // 10 seconds }, hard: { initialSpeed: 1.5, speedIncrease: 0.3, spawnRateBase: 40, enemySpeedMultiplier: 2.5, speedIncreaseInterval: 300 // 5 seconds } }; // Lane positions var lanes = [400, 700, 1000, 1300, 1648]; var laneCount = 5; // UI Elements var scoreTxt = new Text2('Score: 0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; var speedTxt = new Text2('Speed: 1x', { size: 60, fill: 0xFFFF00 }); speedTxt.anchor.set(1, 0); LK.gui.topRight.addChild(speedTxt); speedTxt.x = -50; speedTxt.y = 50; // Difficulty selection UI var difficultyTxt = new Text2('Select Difficulty', { size: 100, fill: 0xFFFFFF }); difficultyTxt.anchor.set(0.5, 0.5); difficultyTxt.x = 2048 / 2; difficultyTxt.y = 800; game.addChild(difficultyTxt); var easyBtn = new Text2('EASY', { size: 80, fill: 0x00FF00 }); easyBtn.anchor.set(0.5, 0.5); easyBtn.x = 2048 / 2 - 300; easyBtn.y = 1200; game.addChild(easyBtn); var mediumBtn = new Text2('MEDIUM', { size: 80, fill: 0xFFFF00 }); mediumBtn.anchor.set(0.5, 0.5); mediumBtn.x = 2048 / 2; mediumBtn.y = 1200; game.addChild(mediumBtn); var hardBtn = new Text2('HARD', { size: 80, fill: 0xFF0000 }); hardBtn.anchor.set(0.5, 0.5); hardBtn.x = 2048 / 2 + 300; hardBtn.y = 1200; game.addChild(hardBtn); var instructionTxt = new Text2('Touch a difficulty to start!', { size: 60, fill: 0xCCCCCC }); instructionTxt.anchor.set(0.5, 0.5); instructionTxt.x = 2048 / 2; instructionTxt.y = 1400; game.addChild(instructionTxt); // Initialize player player = game.addChild(new PlayerCar()); player.x = 2048 / 2; player.y = 2200; player.alpha = 0.3; // Make player semi-transparent during difficulty selection // Difficulty button handlers easyBtn.down = function (x, y, obj) { startGameWithDifficulty('easy'); }; mediumBtn.down = function (x, y, obj) { startGameWithDifficulty('medium'); }; hardBtn.down = function (x, y, obj) { startGameWithDifficulty('hard'); }; function startGameWithDifficulty(difficulty) { currentDifficulty = difficulty; gameStarted = true; gameSpeed = difficultySettings[difficulty].initialSpeed; // Hide difficulty selection UI difficultyTxt.alpha = 0; easyBtn.alpha = 0; mediumBtn.alpha = 0; hardBtn.alpha = 0; instructionTxt.alpha = 0; // Show player car player.alpha = 1; // Update speed display speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x'); // Show difficulty indicator var difficultyIndicator = new Text2('Difficulty: ' + difficulty.toUpperCase(), { size: 50, fill: difficulty === 'easy' ? 0x00FF00 : difficulty === 'medium' ? 0xFFFF00 : 0xFF0000 }); difficultyIndicator.anchor.set(0, 0); LK.gui.topLeft.addChild(difficultyIndicator); difficultyIndicator.x = 120; difficultyIndicator.y = 20; } // Touch controls var isDragging = false; game.down = function (x, y, obj) { if (gameStarted) { isDragging = true; player.targetX = x; } }; game.move = function (x, y, obj) { if (isDragging && gameStarted) { // Constrain to lanes var clampedX = Math.max(lanes[0], Math.min(lanes[lanes.length - 1], x)); player.targetX = clampedX; } }; game.up = function (x, y, obj) { if (gameStarted) { isDragging = false; } }; // Helper functions function spawnEnemyCar() { var enemy = new EnemyCar(); var laneIndex = Math.floor(Math.random() * lanes.length); enemy.x = lanes[laneIndex]; enemy.y = -100; enemy.speed = 8 + gameSpeed * difficultySettings[currentDifficulty].enemySpeedMultiplier; enemyCars.push(enemy); game.addChild(enemy); } function spawnRoadLine() { var line = new RoadLine(); line.x = 2048 / 2; line.y = -50; line.speed = 10 + gameSpeed * 2; roadLines.push(line); game.addChild(line); } function checkNearMiss(enemy) { if (!enemy.checkedNearMiss) { var distance = Math.abs(player.x - enemy.x); var verticalDistance = Math.abs(player.y - enemy.y); if (distance < 150 && verticalDistance < 200) { enemy.checkedNearMiss = true; bonusScore += 10; totalScore += 10; // Visual effect for near miss LK.effects.flashObject(enemy, 0xffff00, 200); LK.getSound('nearMiss').play(); return true; } } return false; } function updateScore() { distanceScore = Math.floor(LK.ticks / 10); totalScore = distanceScore + bonusScore; LK.setScore(totalScore); scoreTxt.setText('Score: ' + totalScore); } function updateSpeed() { speedIncreaseTimer++; var interval = difficultySettings[currentDifficulty].speedIncreaseInterval; if (speedIncreaseTimer >= interval) { gameSpeed += difficultySettings[currentDifficulty].speedIncrease; speedIncreaseTimer = 0; speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x'); } } // Main game loop game.update = function () { if (!gameStarted) { return; // Don't update game logic until difficulty is selected } updateScore(); updateSpeed(); // Spawn enemy cars spawnTimer++; var baseSpawnRate = difficultySettings[currentDifficulty].spawnRateBase; var spawnRate = Math.max(baseSpawnRate - gameSpeed * 10, 20); // Faster spawning as speed increases if (spawnTimer >= spawnRate) { spawnEnemyCar(); spawnTimer = 0; } // Spawn road lines roadLineTimer++; if (roadLineTimer >= 20) { spawnRoadLine(); roadLineTimer = 0; } // Update and check enemy cars for (var i = enemyCars.length - 1; i >= 0; i--) { var enemy = enemyCars[i]; // Check for collision if (enemy.intersects(player)) { // Game over LK.effects.flashScreen(0xff0000, 1000); LK.getSound('crash').play(); LK.showGameOver(); return; } // Check for near miss checkNearMiss(enemy); // Remove off-screen enemies if (enemy.y > 2800) { enemy.destroy(); enemyCars.splice(i, 1); } } // Update and clean up road lines for (var j = roadLines.length - 1; j >= 0; j--) { var line = roadLines[j]; if (line.y > 2800) { line.destroy(); roadLines.splice(j, 1); } } };
===================================================================
--- original.js
+++ change.js
@@ -71,8 +71,34 @@
var totalScore = 0;
var spawnTimer = 0;
var roadLineTimer = 0;
var speedIncreaseTimer = 0;
+// Difficulty system
+var currentDifficulty = 'medium'; // 'easy', 'medium', 'hard'
+var gameStarted = false;
+var difficultySettings = {
+ easy: {
+ initialSpeed: 0.8,
+ speedIncrease: 0.1,
+ spawnRateBase: 80,
+ enemySpeedMultiplier: 1.5,
+ speedIncreaseInterval: 900 // 15 seconds
+ },
+ medium: {
+ initialSpeed: 1.0,
+ speedIncrease: 0.2,
+ spawnRateBase: 60,
+ enemySpeedMultiplier: 2.0,
+ speedIncreaseInterval: 600 // 10 seconds
+ },
+ hard: {
+ initialSpeed: 1.5,
+ speedIncrease: 0.3,
+ spawnRateBase: 40,
+ enemySpeedMultiplier: 2.5,
+ speedIncreaseInterval: 300 // 5 seconds
+ }
+};
// Lane positions
var lanes = [400, 700, 1000, 1300, 1648];
var laneCount = 5;
// UI Elements
@@ -90,35 +116,115 @@
speedTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(speedTxt);
speedTxt.x = -50;
speedTxt.y = 50;
+// Difficulty selection UI
+var difficultyTxt = new Text2('Select Difficulty', {
+ size: 100,
+ fill: 0xFFFFFF
+});
+difficultyTxt.anchor.set(0.5, 0.5);
+difficultyTxt.x = 2048 / 2;
+difficultyTxt.y = 800;
+game.addChild(difficultyTxt);
+var easyBtn = new Text2('EASY', {
+ size: 80,
+ fill: 0x00FF00
+});
+easyBtn.anchor.set(0.5, 0.5);
+easyBtn.x = 2048 / 2 - 300;
+easyBtn.y = 1200;
+game.addChild(easyBtn);
+var mediumBtn = new Text2('MEDIUM', {
+ size: 80,
+ fill: 0xFFFF00
+});
+mediumBtn.anchor.set(0.5, 0.5);
+mediumBtn.x = 2048 / 2;
+mediumBtn.y = 1200;
+game.addChild(mediumBtn);
+var hardBtn = new Text2('HARD', {
+ size: 80,
+ fill: 0xFF0000
+});
+hardBtn.anchor.set(0.5, 0.5);
+hardBtn.x = 2048 / 2 + 300;
+hardBtn.y = 1200;
+game.addChild(hardBtn);
+var instructionTxt = new Text2('Touch a difficulty to start!', {
+ size: 60,
+ fill: 0xCCCCCC
+});
+instructionTxt.anchor.set(0.5, 0.5);
+instructionTxt.x = 2048 / 2;
+instructionTxt.y = 1400;
+game.addChild(instructionTxt);
// Initialize player
player = game.addChild(new PlayerCar());
player.x = 2048 / 2;
player.y = 2200;
+player.alpha = 0.3; // Make player semi-transparent during difficulty selection
+// Difficulty button handlers
+easyBtn.down = function (x, y, obj) {
+ startGameWithDifficulty('easy');
+};
+mediumBtn.down = function (x, y, obj) {
+ startGameWithDifficulty('medium');
+};
+hardBtn.down = function (x, y, obj) {
+ startGameWithDifficulty('hard');
+};
+function startGameWithDifficulty(difficulty) {
+ currentDifficulty = difficulty;
+ gameStarted = true;
+ gameSpeed = difficultySettings[difficulty].initialSpeed;
+ // Hide difficulty selection UI
+ difficultyTxt.alpha = 0;
+ easyBtn.alpha = 0;
+ mediumBtn.alpha = 0;
+ hardBtn.alpha = 0;
+ instructionTxt.alpha = 0;
+ // Show player car
+ player.alpha = 1;
+ // Update speed display
+ speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
+ // Show difficulty indicator
+ var difficultyIndicator = new Text2('Difficulty: ' + difficulty.toUpperCase(), {
+ size: 50,
+ fill: difficulty === 'easy' ? 0x00FF00 : difficulty === 'medium' ? 0xFFFF00 : 0xFF0000
+ });
+ difficultyIndicator.anchor.set(0, 0);
+ LK.gui.topLeft.addChild(difficultyIndicator);
+ difficultyIndicator.x = 120;
+ difficultyIndicator.y = 20;
+}
// Touch controls
var isDragging = false;
game.down = function (x, y, obj) {
- isDragging = true;
- player.targetX = x;
+ if (gameStarted) {
+ isDragging = true;
+ player.targetX = x;
+ }
};
game.move = function (x, y, obj) {
- if (isDragging) {
+ if (isDragging && gameStarted) {
// Constrain to lanes
var clampedX = Math.max(lanes[0], Math.min(lanes[lanes.length - 1], x));
player.targetX = clampedX;
}
};
game.up = function (x, y, obj) {
- isDragging = false;
+ if (gameStarted) {
+ isDragging = false;
+ }
};
// Helper functions
function spawnEnemyCar() {
var enemy = new EnemyCar();
var laneIndex = Math.floor(Math.random() * lanes.length);
enemy.x = lanes[laneIndex];
enemy.y = -100;
- enemy.speed = 8 + gameSpeed * 2;
+ enemy.speed = 8 + gameSpeed * difficultySettings[currentDifficulty].enemySpeedMultiplier;
enemyCars.push(enemy);
game.addChild(enemy);
}
function spawnRoadLine() {
@@ -152,22 +258,26 @@
scoreTxt.setText('Score: ' + totalScore);
}
function updateSpeed() {
speedIncreaseTimer++;
- if (speedIncreaseTimer >= 600) {
- // Every 10 seconds at 60fps
- gameSpeed += 0.2;
+ var interval = difficultySettings[currentDifficulty].speedIncreaseInterval;
+ if (speedIncreaseTimer >= interval) {
+ gameSpeed += difficultySettings[currentDifficulty].speedIncrease;
speedIncreaseTimer = 0;
speedTxt.setText('Speed: ' + gameSpeed.toFixed(1) + 'x');
}
}
// Main game loop
game.update = function () {
+ if (!gameStarted) {
+ return; // Don't update game logic until difficulty is selected
+ }
updateScore();
updateSpeed();
// Spawn enemy cars
spawnTimer++;
- var spawnRate = Math.max(60 - gameSpeed * 10, 30); // Faster spawning as speed increases
+ var baseSpawnRate = difficultySettings[currentDifficulty].spawnRateBase;
+ var spawnRate = Math.max(baseSpawnRate - gameSpeed * 10, 20); // Faster spawning as speed increases
if (spawnTimer >= spawnRate) {
spawnEnemyCar();
spawnTimer = 0;
}
üstten çekilmiş mavi araba. In-Game asset. 2d. High contrast. No shadows
yeşil renk üstten çekilmiş araba resmi. In-Game asset. 2d. High contrast. No shadows
pembe renk araba üstten çekilmiş. In-Game asset. 2d. High contrast. No shadows
duman. In-Game asset. 2d. High contrast. No shadows
formula 1 arabası üsten çekilmiş. In-Game asset. 2d. High contrast. No shadows
lamborghini üstten çekilmiş. In-Game asset. 2d. High contrast. No shadows