User prompt
Arabanın otomatik hareketini tamamen kaldır. Brake ve pedal butonları ile araç kontrolü sağlansın.
User prompt
Sol altta, Brake butonu oluştur. Pedal butonunun tersini yapsın, giden arabaya fren ve duran arabayı geriye gitmesini sağlasın.
User prompt
Pedal bütün bölümlerde olsun.
User prompt
Motor arızalı bölümlerde sağ alta pedal gelsin. Ona tıklayarak aracın gitmesini sağlayalım.
User prompt
Motor arızalı bölümlerde, arabaya tıklayarak gitmesini sağlayalım.
User prompt
Motor arızalı bölümlerde, araba yokuş aşağı hızlansın, yokuş yukarı yavaşlasın.
User prompt
Motor arızalı bölümlerde, araba ileri doğru çıkmasın, başladığı yerde aşağı düşsün.
User prompt
Level 13 çok zor. Daha kolay olsun
User prompt
Level 13'ü yeniden tasarla.
User prompt
Level başı en fazla 3 çizgi çekebilelim.
User prompt
Level 13'ü yeniden tasarla.
User prompt
Duvarların etki alanı, yalnızca resim boyutları kadar olsun.
User prompt
Duvara çarpan araba parçalansın ve yok olsun. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Bütün bölümlerde, sadece 1 tane bitiş yeri olsun.
User prompt
Bazı bölümlerde neden 2 tane bitiş yeri var? Yalnızca 1 bitiş yeri olsun tamamen.
User prompt
Level 5'i yeniden tasarla.
User prompt
Level 5'i yeniden tasarla.
User prompt
Back butonunu 1 satır sağa konumlandır.
User prompt
Level yazısının sol satırına "Back" butonu ekle. Basınca bir önceki bölüme gitsin.
User prompt
Level 4'ü yeniden tasarlandır.
User prompt
Sağ üst köşeye Reset butonu ekle. Basınca herşey sıfırlansın.
User prompt
Level 10 yeniden tasarla
User prompt
Level 5'den sonra, aynı zorluklar ile ve farklı özellikler ile 15 bölüm daha oluştur.
User prompt
Tramboline zıplama oranını yarıya indir.
User prompt
"" *Aşırı sürtünme etkisi** - Motor bozuk olduğunda araç çok hızlı duraksıyor 2. **Başlangıç hızı yetersiz** - Sadece (5, 0) hızla başlıyor, bu tramboline ulaşmak için yeterli değil 3. **Fizik hesaplama sorunu** - Çizgi üzerinde hareket ederken bile sürtünme devam ediyor. "" bunları biraz daha kolay olması için düzenle.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Car = Container.expand(function () {
var self = Container.call(this);
var carBody = self.attachAsset('car', {
anchorX: 0.5,
anchorY: 0.5
});
var wheelLeft = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5,
x: -25,
y: 20
});
var wheelRight = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5,
x: 25,
y: 20
});
self.velocityX = 0;
self.velocityY = 0;
self.speed = 2;
self.gravity = 0.3;
self.onGround = false;
self.engineWorking = true;
self.update = function () {
// Only update physics if game has started
if (!gameStarted) return;
// Only apply gravity, no automatic movement
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
wheelLeft.rotation += self.velocityX * 0.1;
wheelRight.rotation += self.velocityX * 0.1;
};
self.setVelocity = function (vx, vy) {
self.velocityX = vx;
self.velocityY = vy;
};
return self;
});
var DrawnLine = Container.expand(function () {
var self = Container.call(this);
self.points = [];
self.segments = [];
self.addPoint = function (x, y) {
self.points.push({
x: x,
y: y
});
if (self.points.length > 1) {
var lastPoint = self.points[self.points.length - 2];
var currentPoint = self.points[self.points.length - 1];
var dx = currentPoint.x - lastPoint.x;
var dy = currentPoint.y - lastPoint.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
var segment = self.attachAsset('wall', {
anchorX: 0,
anchorY: 0.5,
x: lastPoint.x,
y: lastPoint.y,
scaleX: distance / 200,
scaleY: 0.1,
rotation: angle,
tint: 0x0000FF
});
self.segments.push(segment);
}
};
self.getSegments = function () {
var segmentData = [];
for (var i = 0; i < self.points.length - 1; i++) {
segmentData.push({
start: self.points[i],
end: self.points[i + 1]
});
}
return segmentData;
};
return self;
});
var SmokeParticle = Container.expand(function () {
var self = Container.call(this);
var smokeGraphics = self.attachAsset('wheel', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x999999,
alpha: 0.6
});
self.init = function (x, y) {
self.x = x;
self.y = y;
self.scale.set(0.3);
// Animate the smoke particle
tween(self, {
y: y - 50,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut
});
tween(self.scale, {
x: 1.2,
y: 1.2
}, {
duration: 800,
easing: tween.easeOut
});
};
return self;
});
var Trampoline = Container.expand(function () {
var self = Container.call(this);
var trampolineGraphics = self.attachAsset('trampoline', {
anchorX: 0.5,
anchorY: 0.5
});
self.bounce = function () {
tween(trampolineGraphics, {
scaleY: 0.7
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(trampolineGraphics, {
scaleY: 1
}, {
duration: 200,
easing: tween.bounceOut
});
}
});
};
return self;
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var wallGraphics = self.attachAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xE8E8E8
});
/****
* Game Code
****/
var currentLevel = storage.currentLevel || 1;
var maxLevel = 20;
var car = null;
var walls = [];
var trampolines = [];
var drawnLine = null;
var isDrawing = false;
var levelComplete = false;
var carCanMove = false;
var gameStarted = false;
var startButton = null;
var startButtonText = null;
var refreshButton = null;
var refreshButtonText = null;
var resetButton = null;
var resetButtonText = null;
var backButton = null;
var backButtonText = null;
var smokeParticles = [];
var smokeTimer = 0;
var drawnLines = []; // Array to store all drawn lines
var maxLines = 3; // Maximum lines per level
var currentLineCount = 0; // Current number of lines drawn
var pedalButton = null;
var pedalButtonText = null;
var brakeButton = null;
var brakeButtonText = null;
var startPos = {
x: 200,
y: 1000
};
var finishPos = {
x: 1800,
y: 1000
};
var levelText = new Text2('Level ' + currentLevel, {
size: 80,
fill: 0x333333
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
var instructionText = new Text2('Draw a path from behind the car!', {
size: 50,
fill: 0x666666
});
instructionText.anchor.set(0.5, 0);
instructionText.y = 100;
LK.gui.top.addChild(instructionText);
// Create or update line counter text
if (!game.lineCounterText) {
game.lineCounterText = new Text2('Lines: 3/3', {
size: 40,
fill: 0x666666
});
game.lineCounterText.anchor.set(0.5, 0);
game.lineCounterText.y = 150;
LK.gui.top.addChild(game.lineCounterText);
}
game.lineCounterText.setText('Lines: ' + (maxLines - currentLineCount) + '/' + maxLines);
function setupLevel(level) {
// Clear existing objects
if (car) car.destroy();
for (var i = 0; i < walls.length; i++) {
walls[i].destroy();
}
for (var i = 0; i < trampolines.length; i++) {
trampolines[i].destroy();
}
if (drawnLine) drawnLine.destroy();
// Clear smoke particles
for (var i = 0; i < smokeParticles.length; i++) {
smokeParticles[i].destroy();
}
smokeParticles = [];
// Clear all drawn lines
for (var i = 0; i < drawnLines.length; i++) {
drawnLines[i].destroy();
}
drawnLines = [];
walls = [];
trampolines = [];
drawnLine = null;
isDrawing = false;
levelComplete = false;
carCanMove = false;
gameStarted = false;
currentLineCount = 0; // Reset line counter
// Create ground
var ground = game.addChild(LK.getAsset('ground', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: 2532
}));
// Create start and finish flags
var startFlag = game.addChild(LK.getAsset('startFlag', {
anchorX: 0.5,
anchorY: 1,
x: startPos.x,
y: startPos.y + 50
}));
var finishFlag = game.addChild(LK.getAsset('finishFlag', {
anchorX: 0.5,
anchorY: 1,
x: finishPos.x,
y: finishPos.y + 50
}));
// Reset finish position to default for all levels
finishPos.x = 1800;
finishPos.y = 1000;
finishFlag.x = finishPos.x;
finishFlag.y = finishPos.y + 50;
// Setup level-specific elements
if (level === 1) {
// Simple level - just draw from start to finish
instructionText.setText('Draw a path, use PEDAL/BRAKE to control car!');
} else if (level === 2) {
// Wall in the middle
var wall = new Wall();
wall.x = 1024;
wall.y = 1000;
walls.push(wall);
game.addChild(wall);
instructionText.setText('Draw around the wall!');
} else if (level === 3) {
// L-shaped obstacle
var wall1 = new Wall();
wall1.x = 1024;
wall1.y = 1000;
wall1.scaleX = 2;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1224;
wall2.y = 900;
wall2.rotation = Math.PI / 2;
walls.push(wall2);
game.addChild(wall2);
instructionText.setText('Navigate the L-shape!');
} else if (level === 4) {
// Multiple trampolines with strategic positioning
var wall1 = new Wall();
wall1.x = 600;
wall1.y = 1000;
wall1.scaleX = 1.5;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1200;
wall2.y = 1200;
wall2.scaleY = 2;
walls.push(wall2);
game.addChild(wall2);
var trampoline1 = new Trampoline();
trampoline1.x = 400;
trampoline1.y = 1200;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 800;
trampoline2.y = 800;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1400;
trampoline3.y = 1000;
trampolines.push(trampoline3);
game.addChild(trampoline3);
finishPos.y = 600;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Bounce through the obstacle course!');
} else if (level === 5) {
// Multi-stage obstacle course with steep climbs and precision jumps
// Create ascending wall platforms
var wall1 = new Wall();
wall1.x = 400;
wall1.y = 1200;
wall1.scaleX = 1.5;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 700;
wall2.y = 1000;
wall2.scaleX = 1.2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1000;
wall3.y = 800;
wall3.scaleX = 1.8;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1300;
wall4.y = 600;
wall4.scaleX = 1.5;
walls.push(wall4);
game.addChild(wall4);
// Create vertical barriers for added difficulty
var wall5 = new Wall();
wall5.x = 550;
wall5.y = 1100;
wall5.scaleY = 1.5;
walls.push(wall5);
game.addChild(wall5);
var wall6 = new Wall();
wall6.x = 850;
wall6.y = 900;
wall6.scaleY = 2;
walls.push(wall6);
game.addChild(wall6);
var wall7 = new Wall();
wall7.x = 1150;
wall7.y = 700;
wall7.scaleY = 1.8;
walls.push(wall7);
game.addChild(wall7);
// Strategic trampoline placement for multi-bounce sequences
var trampoline1 = new Trampoline();
trampoline1.x = 600;
trampoline1.y = 1350;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 900;
trampoline2.y = 1150;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1200;
trampoline3.y = 950;
trampolines.push(trampoline3);
game.addChild(trampoline3);
var trampoline4 = new Trampoline();
trampoline4.x = 1500;
trampoline4.y = 750;
trampolines.push(trampoline4);
game.addChild(trampoline4);
finishPos.y = 400;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Master the multi-stage climb! Precision required!');
} else if (level === 6) {
// Multiple trampolines with walls
var wall1 = new Wall();
wall1.x = 800;
wall1.y = 1000;
wall1.scaleY = 2;
walls.push(wall1);
game.addChild(wall1);
var trampoline1 = new Trampoline();
trampoline1.x = 600;
trampoline1.y = 1300;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 1400;
trampoline2.y = 800;
trampolines.push(trampoline2);
game.addChild(trampoline2);
instructionText.setText('Bounce your way through!');
} else if (level === 7) {
// Engine failure with multiple obstacles
var wall1 = new Wall();
wall1.x = 600;
wall1.y = 1100;
wall1.rotation = Math.PI / 4;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1400;
wall2.y = 900;
wall2.rotation = -Math.PI / 4;
walls.push(wall2);
game.addChild(wall2);
finishPos.y = 1200;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Engine down! Tap car to push! Navigate carefully!');
} else if (level === 8) {
// Maze-like structure
var wall1 = new Wall();
wall1.x = 500;
wall1.y = 1000;
wall1.scaleX = 1.5;
wall1.rotation = Math.PI / 2;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 800;
wall2.y = 800;
wall2.scaleX = 1.5;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1200;
wall3.y = 1200;
wall3.scaleX = 1.5;
wall3.rotation = Math.PI / 2;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1500;
wall4.y = 900;
wall4.scaleX = 1.5;
walls.push(wall4);
game.addChild(wall4);
instructionText.setText('Find your way through the maze!');
} else if (level === 9) {
// Trampoline sequence
var trampoline1 = new Trampoline();
trampoline1.x = 400;
trampoline1.y = 1200;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 700;
trampoline2.y = 900;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1000;
trampoline3.y = 700;
trampolines.push(trampoline3);
game.addChild(trampoline3);
var trampoline4 = new Trampoline();
trampoline4.x = 1300;
trampoline4.y = 1100;
trampolines.push(trampoline4);
game.addChild(trampoline4);
finishPos.y = 800;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Bounce through the sequence!');
} else if (level === 10) {
// Moving trampolines with precise timing - engine failure
finishPos.y = 400;
finishFlag.y = finishPos.y + 50;
// Create three moving trampolines
var trampoline1 = new Trampoline();
trampoline1.x = 500;
trampoline1.y = 1300;
trampoline1.moveDirection = 1;
trampoline1.moveSpeed = 2;
trampoline1.minX = 400;
trampoline1.maxX = 700;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 1000;
trampoline2.y = 1000;
trampoline2.moveDirection = -1;
trampoline2.moveSpeed = 3;
trampoline2.minX = 800;
trampoline2.maxX = 1200;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1400;
trampoline3.y = 700;
trampoline3.moveDirection = 1;
trampoline3.moveSpeed = 2.5;
trampoline3.minX = 1200;
trampoline3.maxX = 1600;
trampolines.push(trampoline3);
game.addChild(trampoline3);
// Add walls to create platforms
var wall1 = new Wall();
wall1.x = 600;
wall1.y = 1200;
wall1.scaleX = 2;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1100;
wall2.y = 900;
wall2.scaleX = 2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1500;
wall3.y = 600;
wall3.scaleX = 2;
walls.push(wall3);
game.addChild(wall3);
instructionText.setText('Time your jumps! Moving trampolines! Engine failed! Tap car to push!');
} else if (level === 11) {
// Complex obstacle course
var wall1 = new Wall();
wall1.x = 400;
wall1.y = 1000;
wall1.scaleY = 3;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 800;
wall2.y = 800;
wall2.scaleX = 2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1200;
wall3.y = 1200;
wall3.scaleY = 2;
walls.push(wall3);
game.addChild(wall3);
var trampoline = new Trampoline();
trampoline.x = 600;
trampoline.y = 1300;
trampolines.push(trampoline);
game.addChild(trampoline);
finishPos.y = 700;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Navigate the obstacle course!');
} else if (level === 12) {
// Multiple gaps with trampolines
finishPos.y = 1600;
finishFlag.y = finishPos.y + 50;
var trampoline1 = new Trampoline();
trampoline1.x = 500;
trampoline1.y = 1200;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 900;
trampoline2.y = 1000;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1300;
trampoline3.y = 1300;
trampolines.push(trampoline3);
game.addChild(trampoline3);
instructionText.setText('Bridge multiple gaps!');
} else if (level === 13) {
// Simplified level with basic platforms and reasonable difficulty
// Create simple ascending platforms
var wall1 = new Wall();
wall1.x = 600;
wall1.y = 1100;
wall1.scaleX = 1.5;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1000;
wall2.y = 900;
wall2.scaleX = 1.5;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1300;
wall3.y = 700;
wall3.scaleX = 1.5;
walls.push(wall3);
game.addChild(wall3);
// Add two trampolines for reasonable jumping
var trampoline1 = new Trampoline();
trampoline1.x = 450;
trampoline1.y = 1250;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 850;
trampoline2.y = 1050;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1150;
trampoline3.y = 850;
trampolines.push(trampoline3);
game.addChild(trampoline3);
finishPos.y = 600;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Jump up the platforms! Engine failed! Tap car to push!');
} else if (level === 14) {
// Tower climbing
var wall1 = new Wall();
wall1.x = 500;
wall1.y = 1200;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 700;
wall2.y = 1000;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 900;
wall3.y = 800;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1100;
wall4.y = 600;
walls.push(wall4);
game.addChild(wall4);
var trampoline1 = new Trampoline();
trampoline1.x = 600;
trampoline1.y = 1300;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 800;
trampoline2.y = 1100;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1000;
trampoline3.y = 900;
trampolines.push(trampoline3);
game.addChild(trampoline3);
finishPos.y = 400;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Climb the tower!');
} else if (level === 15) {
// Zigzag with engine failure
var wall1 = new Wall();
wall1.x = 400;
wall1.y = 1100;
wall1.rotation = Math.PI / 3;
wall1.scaleX = 1.5;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 700;
wall2.y = 900;
wall2.rotation = -Math.PI / 3;
wall2.scaleX = 1.5;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1000;
wall3.y = 1100;
wall3.rotation = Math.PI / 3;
wall3.scaleX = 1.5;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1300;
wall4.y = 900;
wall4.rotation = -Math.PI / 3;
wall4.scaleX = 1.5;
walls.push(wall4);
game.addChild(wall4);
instructionText.setText('Zigzag to victory! Engine failed! Tap car to push!');
} else if (level === 16) {
// Double trampoline jump
var trampoline1 = new Trampoline();
trampoline1.x = 600;
trampoline1.y = 1200;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 1000;
trampoline2.y = 800;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var wall1 = new Wall();
wall1.x = 800;
wall1.y = 1000;
wall1.scaleX = 3;
walls.push(wall1);
game.addChild(wall1);
finishPos.y = 600;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Double bounce to reach the top!');
} else if (level === 17) {
// Narrow passage with engine failure
var wall1 = new Wall();
wall1.x = 800;
wall1.y = 900;
wall1.scaleY = 4;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 1200;
wall2.y = 1100;
wall2.scaleY = 4;
walls.push(wall2);
game.addChild(wall2);
var trampoline = new Trampoline();
trampoline.x = 1000;
trampoline.y = 1300;
trampolines.push(trampoline);
game.addChild(trampoline);
finishPos.y = 800;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Thread the needle! Engine failed! Tap car to push!');
} else if (level === 18) {
// Multi-level platform
var wall1 = new Wall();
wall1.x = 500;
wall1.y = 1200;
wall1.scaleX = 2;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 800;
wall2.y = 1000;
wall2.scaleX = 2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1100;
wall3.y = 800;
wall3.scaleX = 2;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1400;
wall4.y = 600;
wall4.scaleX = 2;
walls.push(wall4);
game.addChild(wall4);
var trampoline1 = new Trampoline();
trampoline1.x = 650;
trampoline1.y = 1300;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 950;
trampoline2.y = 1100;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1250;
trampoline3.y = 900;
trampolines.push(trampoline3);
game.addChild(trampoline3);
finishPos.y = 500;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Climb the platforms!');
} else if (level === 19) {
// Extreme obstacle course with engine failure
var wall1 = new Wall();
wall1.x = 400;
wall1.y = 1100;
wall1.rotation = Math.PI / 4;
wall1.scaleX = 2;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 700;
wall2.y = 800;
wall2.rotation = -Math.PI / 4;
wall2.scaleX = 2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 1000;
wall3.y = 1200;
wall3.rotation = Math.PI / 6;
wall3.scaleX = 2;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1300;
wall4.y = 700;
wall4.rotation = -Math.PI / 6;
wall4.scaleX = 2;
walls.push(wall4);
game.addChild(wall4);
var trampoline1 = new Trampoline();
trampoline1.x = 550;
trampoline1.y = 1300;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 850;
trampoline2.y = 1000;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1150;
trampoline3.y = 900;
trampolines.push(trampoline3);
game.addChild(trampoline3);
finishPos.y = 500;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Ultimate challenge! Engine failed! Tap car to push!');
} else if (level === 20) {
// Final boss level - complex multi-stage
var wall1 = new Wall();
wall1.x = 350;
wall1.y = 1000;
wall1.scaleY = 3;
walls.push(wall1);
game.addChild(wall1);
var wall2 = new Wall();
wall2.x = 600;
wall2.y = 800;
wall2.scaleX = 2;
walls.push(wall2);
game.addChild(wall2);
var wall3 = new Wall();
wall3.x = 900;
wall3.y = 1200;
wall3.rotation = Math.PI / 3;
wall3.scaleX = 2;
walls.push(wall3);
game.addChild(wall3);
var wall4 = new Wall();
wall4.x = 1200;
wall4.y = 600;
wall4.scaleX = 2;
walls.push(wall4);
game.addChild(wall4);
var wall5 = new Wall();
wall5.x = 1500;
wall5.y = 900;
wall5.rotation = -Math.PI / 4;
wall5.scaleX = 2;
walls.push(wall5);
game.addChild(wall5);
var trampoline1 = new Trampoline();
trampoline1.x = 500;
trampoline1.y = 1300;
trampolines.push(trampoline1);
game.addChild(trampoline1);
var trampoline2 = new Trampoline();
trampoline2.x = 750;
trampoline2.y = 1000;
trampolines.push(trampoline2);
game.addChild(trampoline2);
var trampoline3 = new Trampoline();
trampoline3.x = 1050;
trampoline3.y = 800;
trampolines.push(trampoline3);
game.addChild(trampoline3);
var trampoline4 = new Trampoline();
trampoline4.x = 1350;
trampoline4.y = 1100;
trampolines.push(trampoline4);
game.addChild(trampoline4);
finishPos.y = 400;
finishFlag.y = finishPos.y + 50;
instructionText.setText('Final challenge! Master all skills!');
}
// Create car
car = new Car();
car.x = startPos.x;
car.y = startPos.y;
car.engineWorking = false; // All levels now require manual control
car.setVelocity(0, 0); // No automatic movement
game.addChild(car);
levelText.setText('Level ' + level);
// Create start button
if (startButton) startButton.destroy();
if (startButtonText) startButtonText.destroy();
startButton = game.addChild(LK.getAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: 1366
}));
startButtonText = new Text2('START', {
size: 40,
fill: 0xffffff
});
startButtonText.anchor.set(0.5, 0.5);
startButtonText.x = 150;
startButtonText.y = 1366;
game.addChild(startButtonText);
// Create refresh button
if (refreshButton) refreshButton.destroy();
if (refreshButtonText) refreshButtonText.destroy();
refreshButton = game.addChild(LK.getAsset('refreshButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: 1450
}));
refreshButtonText = new Text2('REFRESH', {
size: 35,
fill: 0xffffff
});
refreshButtonText.anchor.set(0.5, 0.5);
refreshButtonText.x = 150;
refreshButtonText.y = 1450;
game.addChild(refreshButtonText);
// Create reset button in top right corner
if (resetButton) resetButton.destroy();
if (resetButtonText) resetButtonText.destroy();
resetButton = game.addChild(LK.getAsset('resetButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1948,
y: 100
}));
resetButtonText = new Text2('RESET', {
size: 30,
fill: 0xffffff
});
resetButtonText.anchor.set(0.5, 0.5);
resetButtonText.x = 1948;
resetButtonText.y = 100;
game.addChild(resetButtonText);
// Create back button next to level text
if (backButton) backButton.destroy();
if (backButtonText) backButtonText.destroy();
backButton = game.addChild(LK.getAsset('backButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 320,
y: 100
}));
backButtonText = new Text2('BACK', {
size: 30,
fill: 0xffffff
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 320;
backButtonText.y = 100;
game.addChild(backButtonText);
// Create pedal button for all levels
if (pedalButton) pedalButton.destroy();
if (pedalButtonText) pedalButtonText.destroy();
pedalButton = game.addChild(LK.getAsset('pedal', {
anchorX: 0.5,
anchorY: 0.5,
x: 1900,
y: 2600
}));
pedalButtonText = new Text2('PEDAL', {
size: 30,
fill: 0xffffff
});
pedalButtonText.anchor.set(0.5, 0.5);
pedalButtonText.x = 1900;
pedalButtonText.y = 2600;
game.addChild(pedalButtonText);
// Create brake button for all levels
if (brakeButton) brakeButton.destroy();
if (brakeButtonText) brakeButtonText.destroy();
brakeButton = game.addChild(LK.getAsset('brake', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: 2600
}));
brakeButtonText = new Text2('BRAKE', {
size: 30,
fill: 0xffffff
});
brakeButtonText.anchor.set(0.5, 0.5);
brakeButtonText.x = 150;
brakeButtonText.y = 2600;
game.addChild(brakeButtonText);
}
function checkLineCollision(line1Start, line1End, line2Start, line2End) {
var x1 = line1Start.x;
var y1 = line1Start.y;
var x2 = line1End.x;
var y2 = line1End.y;
var x3 = line2Start.x;
var y3 = line2Start.y;
var x4 = line2End.x;
var y4 = line2End.y;
var denom = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
if (Math.abs(denom) < 0.0001) return null;
var t = ((x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4)) / denom;
var u = -((x1 - x2) * (y1 - y3) - (y1 - y2) * (x1 - x3)) / denom;
if (t >= 0 && t <= 1 && u >= 0 && u <= 1) {
return {
x: x1 + t * (x2 - x1),
y: y1 + t * (y2 - y1)
};
}
return null;
}
function createCarDestructionEffect() {
if (!car) return;
// Stop car movement
car.velocityX = 0;
car.velocityY = 0;
car.engineWorking = false;
// Create multiple car fragments for explosion effect
var fragments = [];
for (var i = 0; i < 8; i++) {
var fragment = game.addChild(LK.getAsset('car', {
anchorX: 0.5,
anchorY: 0.5,
x: car.x,
y: car.y,
scaleX: 0.3,
scaleY: 0.3,
tint: 0xff0000
}));
fragments.push(fragment);
// Random explosion direction
var angle = Math.PI * 2 * i / 8;
var distance = 100 + Math.random() * 100;
var targetX = car.x + Math.cos(angle) * distance;
var targetY = car.y + Math.sin(angle) * distance;
// Animate fragment explosion
tween(fragment, {
x: targetX,
y: targetY,
rotation: Math.random() * Math.PI * 4,
alpha: 0
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
fragment.destroy();
}
});
// Scale animation
tween(fragment.scale, {
x: 0,
y: 0
}, {
duration: 800,
easing: tween.easeIn
});
}
// Hide original car and restart level after animation
car.alpha = 0;
LK.setTimeout(function () {
setupLevel(currentLevel);
}, 1000);
}
function handleCarPhysics() {
if (!car || !drawnLine || levelComplete || !carCanMove || !gameStarted) return;
var carBottom = {
x: car.x,
y: car.y + 20
};
// Check collision with all drawn lines
var onLine = false;
for (var lineIndex = 0; lineIndex < drawnLines.length; lineIndex++) {
var segments = drawnLines[lineIndex].getSegments();
for (var i = 0; i < segments.length; i++) {
var segment = segments[i];
var carRay = {
start: {
x: car.x,
y: car.y
},
end: {
x: car.x,
y: car.y + 30
}
};
var collision = checkLineCollision(carRay.start, carRay.end, segment.start, segment.end);
if (collision) {
onLine = true;
car.y = collision.y - 20;
car.velocityY = 0;
var dx = segment.end.x - segment.start.x;
var dy = segment.end.y - segment.start.y;
var angle = Math.atan2(dy, dx);
// No automatic movement, only apply slope physics and friction
var slopeAcceleration = Math.sin(angle) * 0.2; // Reduced slope effect
car.velocityX += Math.cos(angle) * slopeAcceleration;
car.velocityY += Math.sin(angle) * slopeAcceleration;
// Apply general friction
var frictionFactor = 0.98;
if (Math.sin(angle) > 0) {
// Going downhill - less friction
frictionFactor = 0.995;
} else if (Math.sin(angle) < 0) {
// Going uphill - more friction
frictionFactor = 0.96;
}
car.velocityX *= frictionFactor;
car.velocityY *= frictionFactor;
car.rotation = angle;
break;
}
}
if (onLine) break; // Exit outer loop if collision found
}
car.onGround = onLine;
// Check collision with trampolines
for (var i = 0; i < trampolines.length; i++) {
if (car.intersects(trampolines[i])) {
car.velocityY = -7.5; // Reduced from -15 to half
trampolines[i].bounce();
LK.getSound('bounce').play();
}
}
// Check if car reached finish
var distToFinish = Math.sqrt(Math.pow(car.x - finishPos.x, 2) + Math.pow(car.y - finishPos.y, 2));
if (distToFinish < 100) {
levelComplete = true;
LK.getSound('success').play();
currentLevel++;
storage.currentLevel = currentLevel;
if (currentLevel > maxLevel) {
LK.setScore(100);
LK.showYouWin();
} else {
LK.setTimeout(function () {
setupLevel(currentLevel);
}, 1500);
}
}
// Check collision with walls
for (var i = 0; i < walls.length; i++) {
if (car.intersects(walls[i])) {
// Car hit a wall - create destruction effect
createCarDestructionEffect();
return; // Exit early to prevent further physics
}
}
// Check if car fell off screen
if (car.y > 2732) {
setupLevel(currentLevel);
}
}
game.down = function (x, y, obj) {
if (levelComplete) return;
// Check if start button clicked
if (startButton && Math.abs(x - startButton.x) < 75 && Math.abs(y - startButton.y) < 30) {
// Only start if we have drawn at least one line
if (drawnLines.length > 0 && !gameStarted) {
gameStarted = true;
carCanMove = true;
startButton.tint = 0x888888;
}
return;
}
// Check if refresh button clicked
if (refreshButton && Math.abs(x - refreshButton.x) < 75 && Math.abs(y - refreshButton.y) < 30) {
// Reset current level
setupLevel(currentLevel);
return;
}
// Check if reset button clicked
if (resetButton && Math.abs(x - resetButton.x) < 60 && Math.abs(y - resetButton.y) < 25) {
// Reset everything - go back to level 1
currentLevel = 1;
storage.currentLevel = 1;
setupLevel(currentLevel);
return;
}
// Check if back button clicked
if (backButton && Math.abs(x - 320) < 60 && Math.abs(y - backButton.y) < 25) {
// Go back to previous level if not at level 1
if (currentLevel > 1) {
currentLevel--;
storage.currentLevel = currentLevel;
setupLevel(currentLevel);
}
return;
}
// Check if pedal button clicked for all levels
if (pedalButton && gameStarted && Math.abs(x - pedalButton.x) < 60 && Math.abs(y - pedalButton.y) < 40) {
// Push car forward
car.velocityX += 2.5;
car.velocityY -= 1.2; // Small upward push
return;
}
// Check if brake button clicked for all levels
if (brakeButton && gameStarted && Math.abs(x - brakeButton.x) < 60 && Math.abs(y - brakeButton.y) < 40) {
// Apply brake - reduce velocity or reverse direction
if (Math.abs(car.velocityX) > 0.5 || Math.abs(car.velocityY) > 0.5) {
// Car is moving - apply brake (reduce velocity)
car.velocityX *= 0.5;
car.velocityY *= 0.5;
} else {
// Car is stopped or moving slowly - make it go backward
car.velocityX -= 2;
car.velocityY += 0.5;
}
return;
}
// Check if starting from behind the car and haven't reached line limit
if (x < car.x - 50 && !gameStarted && currentLineCount < maxLines) {
isDrawing = true;
drawnLine = new DrawnLine();
game.addChild(drawnLine);
drawnLine.addPoint(x, y);
}
};
game.move = function (x, y, obj) {
if (isDrawing && drawnLine) {
drawnLine.addPoint(x, y);
}
};
game.up = function (x, y, obj) {
if (isDrawing && drawnLine) {
// Don't automatically allow car to move - wait for start button
// Store the completed line and increment counter
drawnLines.push(drawnLine);
currentLineCount++;
// Update line counter display
if (game.lineCounterText) {
game.lineCounterText.setText('Lines: ' + (maxLines - currentLineCount) + '/' + maxLines);
}
}
isDrawing = false;
};
game.update = function () {
handleCarPhysics();
// Move trampolines if they have movement properties
for (var i = 0; i < trampolines.length; i++) {
var trampoline = trampolines[i];
if (trampoline.moveDirection !== undefined) {
trampoline.x += trampoline.moveDirection * trampoline.moveSpeed;
// Bounce off boundaries
if (trampoline.x <= trampoline.minX || trampoline.x >= trampoline.maxX) {
trampoline.moveDirection *= -1;
}
}
}
// Create smoke particles when car is moving
if (car && gameStarted && carCanMove && (Math.abs(car.velocityX) > 0.5 || Math.abs(car.velocityY) > 0.5)) {
smokeTimer++;
if (smokeTimer % 4 === 0) {
// Create smoke every 4 frames
var smoke = new SmokeParticle();
// Position smoke behind the car based on its rotation
var offsetX = -Math.cos(car.rotation) * 40;
var offsetY = -Math.sin(car.rotation) * 40;
smoke.init(car.x + offsetX, car.y + offsetY);
game.addChild(smoke);
smokeParticles.push(smoke);
}
}
// Clean up old smoke particles
for (var i = smokeParticles.length - 1; i >= 0; i--) {
if (smokeParticles[i].alpha <= 0) {
smokeParticles[i].destroy();
smokeParticles.splice(i, 1);
}
}
};
// Initialize first level
setupLevel(currentLevel); ===================================================================
--- original.js
+++ change.js
@@ -33,11 +33,9 @@
self.engineWorking = true;
self.update = function () {
// Only update physics if game has started
if (!gameStarted) return;
- if (!self.engineWorking) {
- self.velocityX *= 0.995; // Much less aggressive friction
- }
+ // Only apply gravity, no automatic movement
self.velocityY += self.gravity;
self.x += self.velocityX;
self.y += self.velocityY;
wheelLeft.rotation += self.velocityX * 0.1;
@@ -277,9 +275,9 @@
finishFlag.y = finishPos.y + 50;
// Setup level-specific elements
if (level === 1) {
// Simple level - just draw from start to finish
- instructionText.setText('Draw a path, then press START!');
+ instructionText.setText('Draw a path, use PEDAL/BRAKE to control car!');
} else if (level === 2) {
// Wall in the middle
var wall = new Wall();
wall.x = 1024;
@@ -901,12 +899,10 @@
// Create car
car = new Car();
car.x = startPos.x;
car.y = startPos.y;
- if (level === 5 || level === 7 || level === 10 || level === 13 || level === 15 || level === 17 || level === 19) {
- car.engineWorking = false;
- car.setVelocity(0, 0); // No forward momentum, just fall down
- }
+ car.engineWorking = false; // All levels now require manual control
+ car.setVelocity(0, 0); // No automatic movement
game.addChild(car);
levelText.setText('Level ' + level);
// Create start button
if (startButton) startButton.destroy();
@@ -1113,28 +1109,23 @@
car.velocityY = 0;
var dx = segment.end.x - segment.start.x;
var dy = segment.end.y - segment.start.y;
var angle = Math.atan2(dy, dx);
- if (car.engineWorking) {
- car.velocityX = Math.cos(angle) * car.speed;
- car.velocityY = Math.sin(angle) * car.speed;
- } else {
- // For engine failure: accelerate downhill, decelerate uphill
- var slopeAcceleration = Math.sin(angle) * 0.3; // How much slope affects speed
- car.velocityX += Math.cos(angle) * slopeAcceleration;
- car.velocityY += Math.sin(angle) * slopeAcceleration;
- // Apply friction but less on downhill slopes
- var frictionFactor = 0.98;
- if (Math.sin(angle) > 0) {
- // Going downhill
- frictionFactor = 0.995; // Less friction going downhill
- } else if (Math.sin(angle) < 0) {
- // Going uphill
- frictionFactor = 0.96; // More friction going uphill
- }
- car.velocityX *= frictionFactor;
- car.velocityY *= frictionFactor;
+ // No automatic movement, only apply slope physics and friction
+ var slopeAcceleration = Math.sin(angle) * 0.2; // Reduced slope effect
+ car.velocityX += Math.cos(angle) * slopeAcceleration;
+ car.velocityY += Math.sin(angle) * slopeAcceleration;
+ // Apply general friction
+ var frictionFactor = 0.98;
+ if (Math.sin(angle) > 0) {
+ // Going downhill - less friction
+ frictionFactor = 0.995;
+ } else if (Math.sin(angle) < 0) {
+ // Going uphill - more friction
+ frictionFactor = 0.96;
}
+ car.velocityX *= frictionFactor;
+ car.velocityY *= frictionFactor;
car.rotation = angle;
break;
}
}
@@ -1186,11 +1177,8 @@
if (drawnLines.length > 0 && !gameStarted) {
gameStarted = true;
carCanMove = true;
startButton.tint = 0x888888;
- if (car.engineWorking) {
- LK.getSound('carEngine').play();
- }
}
return;
}
// Check if refresh button clicked
@@ -1218,18 +1206,11 @@
return;
}
// Check if pedal button clicked for all levels
if (pedalButton && gameStarted && Math.abs(x - pedalButton.x) < 60 && Math.abs(y - pedalButton.y) < 40) {
- // Push car forward with small velocity
- if (car.engineWorking) {
- // For working engine, provide normal boost
- car.velocityX += 3;
- car.velocityY -= 1.5;
- } else {
- // For engine failure, provide smaller boost
- car.velocityX += 2;
- car.velocityY -= 1; // Small upward push
- }
+ // Push car forward
+ car.velocityX += 2.5;
+ car.velocityY -= 1.2; // Small upward push
return;
}
// Check if brake button clicked for all levels
if (brakeButton && gameStarted && Math.abs(x - brakeButton.x) < 60 && Math.abs(y - brakeButton.y) < 40) {
@@ -1244,15 +1225,8 @@
car.velocityY += 0.5;
}
return;
}
- // Check if car is tapped in engine failure levels
- if (car && gameStarted && !car.engineWorking && Math.abs(x - car.x) < 60 && Math.abs(y - car.y) < 60) {
- // Push car forward with small velocity
- car.velocityX += 2;
- car.velocityY -= 1; // Small upward push
- return;
- }
// Check if starting from behind the car and haven't reached line limit
if (x < car.x - 50 && !gameStarted && currentLineCount < maxLines) {
isDrawing = true;
drawnLine = new DrawnLine();
Bitiş bayrağı, yazısız, 3d, gerçekçi. In-Game asset. 2d. High contrast. No shadows
araba gaz pedalı, yazısız, 3d, gerçekçi. In-Game asset. 2d. High contrast. No shadows. In-Game asset. 2d. High contrast. No shadows
araba, yazısız, 3d, gerçekçi, yandan görünüm, In-Game asset. 2d. High contrast. No shadows. In-Game asset. 2d. High contrast. No shadows
ateş, 3d, yazısız. In-Game asset. 2d. High contrast. No shadows
water, 3d, yazısız. In-Game asset. 2d. High contrast. No shadows
wall, 3d, yazısız. In-Game asset. 2d. High contrast. No shadows
trampoline, 3d, yazısız. In-Game asset. 2d. High contrast. No shadows