User prompt
biraz daha
User prompt
yollar arasındaki boşluğu şimdi çok aralı yap
User prompt
Undo yap. yollar kayboldu
User prompt
şöyle bir sorun oluştu. ilk 3-4 yolun arasını aralı yaptın bu çok güzel ama tekrardan spawn olma döngüsü başlayınca ara yine küçük oluyor bunu düzelt ve onlarıda aralı yap
User prompt
Yollar arasındaki boşluğu baya aralı yap
User prompt
olmadı. undo yap bunu.
User prompt
biraz daha arala yolların aralarını
User prompt
yolların arasını bi tık daha aralı yap
User prompt
3 yol olayını geri düzelt undo yap
User prompt
şimdi de tüm spawn olan ilk 3 yol silindi ama ben sana sadece 1 kerelik olsun bu demiştim yani oyun ilk açılınca sadece 1 seferlik
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'if (pedestrians.length > 0) {' Line Number: 112
User prompt
oyun açılınca ilk 3 yaya yolunu ve ilk 3 yayayı sil
User prompt
çok güzel oldu ama şiimdi de yayalar yaya yollarında gezmiyor kafalarına göre ilerliyorlar. onları yaya yolunda gitmelerini ayarla.
User prompt
Yollar ve yayalar ekranın yukarısından spawn olsun
User prompt
yayalar için bu oldu ama yolların texturesi hala oyuncu oyuna başlayınca arabanın arkasından spawn oluyor
User prompt
yollar arabanın arkasından başlıyor, böyle olmasın. araba en azından biraz gittikten sonra yollar ve yayalar spawn olsun
User prompt
oyuncu oyuna başlayınca değil de, 3 saniye sonra yollar ve yayalar spawn olsun.
User prompt
araba her ekrana tıklayınca değil de basılı tutarak haraket etsin. mesela sağa basılı tutunca sağa doğru, sola basılı tutunca ise sola doğru haraket etsin.
User prompt
yollar çok yavaş geliyor onların delay'ını iyi ayarla. yayalar aynı anda 1-2 tane geliyor . her yoldan 1 yaya geçe bilsin. yaya yolları arasındaki alanı biraz genişlet.
User prompt
çok güzel oldu. şimdi yaya yollarının arasını biraz aç ve yaya yollarıda yolda devam etsin. ve yayaların hızı biraz yavaşlasın
User prompt
o gittikçe yol da yenilensin onunla birlikte yol devam etsin
User prompt
ileri de gitsin kendi kendine
User prompt
then when you touch the right of the screen it goes right, when you touch the left it goes left
Code edit (1 edits merged)
Please save this source code
User prompt
Crosswalk Rush
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Car class
var Car = Container.expand(function () {
var self = Container.call(this);
// Attach car asset, anchor center
var carSprite = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
// For collision, store width/height
self.carWidth = carSprite.width;
self.carHeight = carSprite.height;
// No update needed; car is moved by player
return self;
});
// Crosswalk class (visual only)
var Crosswalk = Container.expand(function () {
var self = Container.call(this);
// Attach crosswalk asset, anchor center
self.attachAsset('crosswalk', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
// Pedestrian class
var Pedestrian = Container.expand(function () {
var self = Container.call(this);
// Attach pedestrian asset, anchor center
var pedSprite = self.attachAsset('pedestrian', {
anchorX: 0.5,
anchorY: 0.5
});
// For collision, store width/height
self.pedWidth = pedSprite.width;
self.pedHeight = pedSprite.height;
// Speed in px per frame (set on spawn)
self.speed = 0;
// Update: move right
self.update = function () {
self.x += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x444444
});
/****
* Game Code
****/
// Center road horizontally
// Road setup
// Car asset: blue box, 200x300
// Pedestrian asset: yellow ellipse, 120x120
// Road asset: dark gray box, 900x2732
// Crosswalk asset: white box, 900x40
var road = LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0
});
road.x = 2048 / 2;
road.y = 0;
game.addChild(road);
// Crosswalk Y positions (4 crosswalks, evenly spaced)
var crosswalkYs = [600, 1100, 1600, 2100];
var crosswalks = [];
for (var i = 0; i < crosswalkYs.length; i++) {
var cw = new Crosswalk();
cw.x = 2048 / 2;
cw.y = crosswalkYs[i];
game.addChild(cw);
crosswalks.push(cw);
}
// Car setup
var car = new Car();
car.x = 2048 / 2;
car.y = 2732 - 400; // Near bottom, but not too close
game.addChild(car);
// Car movement variables
var dragCar = false;
var dragOffsetX = 0;
// Road boundaries (car can't leave road)
var roadLeft = road.x - road.width / 2 + car.carWidth / 2;
var roadRight = road.x + road.width / 2 - car.carWidth / 2;
// Pedestrian management
var pedestrians = [];
// Pedestrian spawn timer
var pedSpawnInterval = 60; // frames (1 sec)
var pedSpawnTick = 0;
// Score
var score = 0;
var scoreTxt = new Text2('0', {
size: 120,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Score timer: add 10 points every second
var scoreTimer = LK.setInterval(function () {
score += 10;
scoreTxt.setText(score);
}, 1000);
// Touch/mouse controls: tap left/right to move car
game.down = function (x, y, obj) {
// If tap is on left half of screen, move car left
// If tap is on right half, move car right
var moveAmount = 180; // px per tap, adjust for feel
if (x < 2048 / 2) {
// Move left
var newX = car.x - moveAmount;
if (newX < roadLeft) newX = roadLeft;
car.x = newX;
} else {
// Move right
var newX = car.x + moveAmount;
if (newX > roadRight) newX = roadRight;
car.x = newX;
}
};
// No drag or move needed for tap-to-move
game.move = function (x, y, obj) {};
game.up = function (x, y, obj) {};
// Main update loop
game.update = function () {
// Spawn pedestrians
pedSpawnTick++;
if (pedSpawnTick >= pedSpawnInterval) {
pedSpawnTick = 0;
// Randomly pick a crosswalk
var idx = Math.floor(Math.random() * crosswalkYs.length);
var y = crosswalkYs[idx];
// Spawn at left edge of road
var ped = new Pedestrian();
ped.y = y;
ped.x = road.x - road.width / 2 + ped.pedWidth / 2;
// Random speed: 6-10 px/frame
ped.speed = 6 + Math.floor(Math.random() * 5);
pedestrians.push(ped);
game.addChild(ped);
}
// Update pedestrians
for (var i = pedestrians.length - 1; i >= 0; i--) {
var ped = pedestrians[i];
ped.update();
// Remove if off right edge
if (ped.x > road.x + road.width / 2 + ped.pedWidth / 2) {
ped.destroy();
pedestrians.splice(i, 1);
continue;
}
// Collision with car?
if (ped.intersects(car)) {
// Flash screen red
LK.effects.flashScreen(0xff0000, 1000);
// Game over
LK.showGameOver();
return;
}
}
};
// Center score text at top, avoid top left 100x100
scoreTxt.x = 2048 / 2;
scoreTxt.y = 20;
// Clean up on game over (handled by LK, but clear timer)
game.onDestroy = function () {
LK.clearInterval(scoreTimer);
}; ===================================================================
--- original.js
+++ change.js
@@ -59,14 +59,14 @@
/****
* Game Code
****/
-// Crosswalk asset: white box, 900x40
-// Road asset: dark gray box, 900x2732
-// Pedestrian asset: yellow ellipse, 120x120
-// Car asset: blue box, 200x300
-// Road setup
// Center road horizontally
+// Road setup
+// Car asset: blue box, 200x300
+// Pedestrian asset: yellow ellipse, 120x120
+// Road asset: dark gray box, 900x2732
+// Crosswalk asset: white box, 900x40
var road = LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0
});
@@ -111,33 +111,28 @@
var scoreTimer = LK.setInterval(function () {
score += 10;
scoreTxt.setText(score);
}, 1000);
-// Touch/mouse controls
+// Touch/mouse controls: tap left/right to move car
game.down = function (x, y, obj) {
- // Only start drag if touch is on car
- // Convert to car local
- var local = car.toLocal({
- x: x,
- y: y
- });
- if (local.x >= -car.carWidth / 2 && local.x <= car.carWidth / 2 && local.y >= -car.carHeight / 2 && local.y <= car.carHeight / 2) {
- dragCar = true;
- dragOffsetX = car.x - x;
- }
-};
-game.move = function (x, y, obj) {
- if (dragCar) {
- // Move car horizontally, clamp to road
- var newX = x + dragOffsetX;
+ // If tap is on left half of screen, move car left
+ // If tap is on right half, move car right
+ var moveAmount = 180; // px per tap, adjust for feel
+ if (x < 2048 / 2) {
+ // Move left
+ var newX = car.x - moveAmount;
if (newX < roadLeft) newX = roadLeft;
+ car.x = newX;
+ } else {
+ // Move right
+ var newX = car.x + moveAmount;
if (newX > roadRight) newX = roadRight;
car.x = newX;
}
};
-game.up = function (x, y, obj) {
- dragCar = false;
-};
+// No drag or move needed for tap-to-move
+game.move = function (x, y, obj) {};
+game.up = function (x, y, obj) {};
// Main update loop
game.update = function () {
// Spawn pedestrians
pedSpawnTick++;