User prompt
Oyunu oynayanlar için liderlik tablosu oluşturalım en çok skoru yapabilen gözüksün ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Oyun 10 levelden oluşsun 1000 skorda bitsin
User prompt
Turbo ekleyelim ona basınca araba hızlansın
User prompt
Arabayı kontrol etmek için konsol ekle
User prompt
Konuşma oyunun orta kısmında gözüksün ve türkçe dil seçeneği gelsin
Code edit (1 edits merged)
Please save this source code
User prompt
Rock Dodge Racing
Initial prompt
Oyun en üstten kayalıklar gelsin araçla kayalıklara çarpmamaya çalışalım eğer kayaya vurursak alttan konuşma geçsin konuşmada araba sürmeyi bilmiyomusun desin her 100 skorda ise bravo böyle devam desin
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Car = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset('car', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.targetX = self.x; self.update = function () { // Smooth movement towards target position var diff = self.targetX - self.x; if (Math.abs(diff) > 1) { self.x += diff * 0.15; } // Keep car within screen bounds var halfWidth = carGraphics.width / 2; if (self.x < halfWidth) { self.x = halfWidth; self.targetX = halfWidth; } if (self.x > 2048 - halfWidth) { self.x = 2048 - halfWidth; self.targetX = 2048 - halfWidth; } }; self.moveLeft = function () { self.targetX -= 150; }; self.moveRight = function () { self.targetX += 150; }; return self; }); var Rock = Container.expand(function () { var self = Container.call(this); var rockGraphics = self.attachAsset('rock', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4 + Math.random() * 3; self.update = function () { self.y += self.speed; }; return self; }); var SpeechBubble = Container.expand(function (message) { var self = Container.call(this); // Create bubble background var bubble = LK.getAsset('speechBubble', { width: 400, height: 120, color: 0xffffff, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.addChild(bubble); // Create text var text = new Text2(message, { size: 40, fill: 0x000000 }); text.anchor.set(0.5, 0.5); self.addChild(text); // Animation self.alpha = 0; self.scaleX = 0.5; self.scaleY = 0.5; // Animate in tween(self, { alpha: 1, scaleX: 1, scaleY: 1 }, { duration: 300, easing: tween.easeOut }); // Auto remove after delay LK.setTimeout(function () { tween(self, { alpha: 0, scaleX: 0.8, scaleY: 0.8 }, { duration: 200, onFinish: function onFinish() { if (self.parent) { self.destroy(); } } }); }, 2000); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ // Game variables var car; var rocks = []; var gameRunning = true; var rockSpawnTimer = 0; var rockSpawnRate = 60; // frames between spawns var pointsTimer = 0; var lastEncouragementScore = 0; // Initialize car car = game.addChild(new Car()); car.x = 2048 / 2; car.y = 2732 - 150; // Score display var scoreTxt = new Text2('0', { size: 80, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y = 100; // Touch controls var lastTouchX = 0; game.down = function (x, y, obj) { lastTouchX = x; }; game.move = function (x, y, obj) { if (!gameRunning) return; var deltaX = x - lastTouchX; if (Math.abs(deltaX) > 10) { if (deltaX > 0) { car.moveRight(); } else { car.moveLeft(); } lastTouchX = x; } }; // Spawn rock function function spawnRock() { var rock = new Rock(); rock.x = Math.random() * (2048 - 160) + 80; // Keep rocks within screen bounds rock.y = -50; rocks.push(rock); game.addChild(rock); } // Show speech bubble function showSpeechBubble(message, x, y) { var bubble = new SpeechBubble(message); bubble.x = x; bubble.y = y; game.addChild(bubble); } // Show encouragement message function showEncouragement() { var encouragement = new SpeechBubble("Bravo, keep it up!"); encouragement.x = 2048 / 2; encouragement.y = 2732 / 2; game.addChild(encouragement); } game.update = function () { if (!gameRunning) return; // Update score based on time survived pointsTimer++; if (pointsTimer >= 10) { // Add point every 10 frames (roughly 6 points per second) LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); pointsTimer = 0; // Check for encouragement message if (LK.getScore() > 0 && LK.getScore() % 100 === 0 && LK.getScore() > lastEncouragementScore) { showEncouragement(); lastEncouragementScore = LK.getScore(); } } // Spawn rocks rockSpawnTimer++; if (rockSpawnTimer >= rockSpawnRate) { spawnRock(); rockSpawnTimer = 0; // Gradually increase difficulty if (rockSpawnRate > 25) { rockSpawnRate = Math.max(25, rockSpawnRate - 0.5); } } // Update and check rocks for (var i = rocks.length - 1; i >= 0; i--) { var rock = rocks[i]; // Check if rock is off screen if (rock.y > 2732 + 50) { rock.destroy(); rocks.splice(i, 1); continue; } // Check collision with car if (rock.intersects(car)) { // Game over gameRunning = false; // Show speech bubble showSpeechBubble("Don't you know how to drive?", car.x, car.y - 100); // Play crash sound LK.getSound('crash').play(); // Flash effect LK.effects.flashScreen(0xff0000, 500); // Show game over after delay LK.setTimeout(function () { LK.showGameOver(); }, 2500); break; } } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,224 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Car = Container.expand(function () {
+ var self = Container.call(this);
+ var carGraphics = self.attachAsset('car', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.targetX = self.x;
+ self.update = function () {
+ // Smooth movement towards target position
+ var diff = self.targetX - self.x;
+ if (Math.abs(diff) > 1) {
+ self.x += diff * 0.15;
+ }
+ // Keep car within screen bounds
+ var halfWidth = carGraphics.width / 2;
+ if (self.x < halfWidth) {
+ self.x = halfWidth;
+ self.targetX = halfWidth;
+ }
+ if (self.x > 2048 - halfWidth) {
+ self.x = 2048 - halfWidth;
+ self.targetX = 2048 - halfWidth;
+ }
+ };
+ self.moveLeft = function () {
+ self.targetX -= 150;
+ };
+ self.moveRight = function () {
+ self.targetX += 150;
+ };
+ return self;
+});
+var Rock = Container.expand(function () {
+ var self = Container.call(this);
+ var rockGraphics = self.attachAsset('rock', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4 + Math.random() * 3;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+var SpeechBubble = Container.expand(function (message) {
+ var self = Container.call(this);
+ // Create bubble background
+ var bubble = LK.getAsset('speechBubble', {
+ width: 400,
+ height: 120,
+ color: 0xffffff,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.addChild(bubble);
+ // Create text
+ var text = new Text2(message, {
+ size: 40,
+ fill: 0x000000
+ });
+ text.anchor.set(0.5, 0.5);
+ self.addChild(text);
+ // Animation
+ self.alpha = 0;
+ self.scaleX = 0.5;
+ self.scaleY = 0.5;
+ // Animate in
+ tween(self, {
+ alpha: 1,
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ // Auto remove after delay
+ LK.setTimeout(function () {
+ tween(self, {
+ alpha: 0,
+ scaleX: 0.8,
+ scaleY: 0.8
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ if (self.parent) {
+ self.destroy();
+ }
+ }
+ });
+ }, 2000);
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var car;
+var rocks = [];
+var gameRunning = true;
+var rockSpawnTimer = 0;
+var rockSpawnRate = 60; // frames between spawns
+var pointsTimer = 0;
+var lastEncouragementScore = 0;
+// Initialize car
+car = game.addChild(new Car());
+car.x = 2048 / 2;
+car.y = 2732 - 150;
+// Score display
+var scoreTxt = new Text2('0', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100;
+// Touch controls
+var lastTouchX = 0;
+game.down = function (x, y, obj) {
+ lastTouchX = x;
+};
+game.move = function (x, y, obj) {
+ if (!gameRunning) return;
+ var deltaX = x - lastTouchX;
+ if (Math.abs(deltaX) > 10) {
+ if (deltaX > 0) {
+ car.moveRight();
+ } else {
+ car.moveLeft();
+ }
+ lastTouchX = x;
+ }
+};
+// Spawn rock function
+function spawnRock() {
+ var rock = new Rock();
+ rock.x = Math.random() * (2048 - 160) + 80; // Keep rocks within screen bounds
+ rock.y = -50;
+ rocks.push(rock);
+ game.addChild(rock);
+}
+// Show speech bubble
+function showSpeechBubble(message, x, y) {
+ var bubble = new SpeechBubble(message);
+ bubble.x = x;
+ bubble.y = y;
+ game.addChild(bubble);
+}
+// Show encouragement message
+function showEncouragement() {
+ var encouragement = new SpeechBubble("Bravo, keep it up!");
+ encouragement.x = 2048 / 2;
+ encouragement.y = 2732 / 2;
+ game.addChild(encouragement);
+}
+game.update = function () {
+ if (!gameRunning) return;
+ // Update score based on time survived
+ pointsTimer++;
+ if (pointsTimer >= 10) {
+ // Add point every 10 frames (roughly 6 points per second)
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ pointsTimer = 0;
+ // Check for encouragement message
+ if (LK.getScore() > 0 && LK.getScore() % 100 === 0 && LK.getScore() > lastEncouragementScore) {
+ showEncouragement();
+ lastEncouragementScore = LK.getScore();
+ }
+ }
+ // Spawn rocks
+ rockSpawnTimer++;
+ if (rockSpawnTimer >= rockSpawnRate) {
+ spawnRock();
+ rockSpawnTimer = 0;
+ // Gradually increase difficulty
+ if (rockSpawnRate > 25) {
+ rockSpawnRate = Math.max(25, rockSpawnRate - 0.5);
+ }
+ }
+ // Update and check rocks
+ for (var i = rocks.length - 1; i >= 0; i--) {
+ var rock = rocks[i];
+ // Check if rock is off screen
+ if (rock.y > 2732 + 50) {
+ rock.destroy();
+ rocks.splice(i, 1);
+ continue;
+ }
+ // Check collision with car
+ if (rock.intersects(car)) {
+ // Game over
+ gameRunning = false;
+ // Show speech bubble
+ showSpeechBubble("Don't you know how to drive?", car.x, car.y - 100);
+ // Play crash sound
+ LK.getSound('crash').play();
+ // Flash effect
+ LK.effects.flashScreen(0xff0000, 500);
+ // Show game over after delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 2500);
+ break;
+ }
+ }
+};
\ No newline at end of file