User prompt
Add tree to the grass area
User prompt
Add treetrunk around the road
User prompt
Add tree to grass area
User prompt
Add trees in the grass area
User prompt
Add tree variable
User prompt
Add trees at the gras area
User prompt
Yolun etrafına çimen yap
User prompt
Yolun etrafını yeşil yap
User prompt
Yolun etrafını yeşil yap ve ağaç ekle
User prompt
Yol köşelerini daha belirgin hale getir
User prompt
Make the road
User prompt
Make info button
User prompt
Delete the info button
User prompt
Delete the info button and make new
User prompt
Design the info button's background
User prompt
Design the info button
User prompt
Design the background of info button
User prompt
Design the info button
User prompt
Party screen when there is new best score ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Party screen when thr best score is beaten ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Party screen at the start
User prompt
Поднови инфо бутона според новите промени и махни ненужните подробности
User prompt
Намали скока на половина ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Намали скока на половина ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Направи така ,че когато Ф1 колата прескача друга кола ,да се вижда над колата която прескача ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var F1Car = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('f1Car', {
anchorX: 0.5,
anchorY: 0.5
});
self.lane = 1; // 0 = left, 1 = center, 2 = right
self.isJumping = false;
self.jumpStartY = 0;
self.moveToLane = function (targetLane) {
if (targetLane < 0 || targetLane > 2) return;
self.lane = targetLane;
var targetX = lanePositions[targetLane];
tween(self, {
x: targetX
}, {
duration: 200,
easing: tween.easeOut
});
};
self.jump = function () {
if (self.isJumping || jumpPower < 5) return;
self.isJumping = true;
self.jumpStartY = self.y;
// Consume 5 jump power points
jumpPower -= 5;
// Update jump power bar scale
jumpPowerBar.scaleY = Math.min(jumpPower / 20, 1);
// Move player car to front (above other cars) when jumping
self.parent.addChild(self);
// Jump animation
tween(self, {
y: self.jumpStartY - 25,
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 600,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
y: self.jumpStartY,
scaleX: 1,
scaleY: 1
}, {
duration: 600,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isJumping = false;
}
});
}
});
// Play sound only (no points awarded)
LK.getSound('jump').play();
};
return self;
});
var SportsCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('sportsCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 12; // Faster than regular traffic
self.lane = 0;
self.update = function () {
self.y += self.speed;
};
return self;
});
var TrafficCar = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('trafficCar', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.lane = 0;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Truck = Container.expand(function () {
var self = Container.call(this);
var carGraphics = self.attachAsset('truck', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 6; // Slower than regular traffic
self.lane = 0;
self.update = function () {
self.y += self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x228B22
});
/****
* Game Code
****/
// Game state management
var gameState = "menu"; // "menu", "playing"
// Lane positions
var lanePositions = [2048 / 2 - 300, 2048 / 2, 2048 / 2 + 300];
// Global game variables
var roadBg;
var leftLane;
var rightLane;
var playerCar;
var trafficCars;
var spawnTimer;
var gameSpeed;
var difficultyTimer;
var scoreTxt;
var dragStartX;
var dragStartY;
var isDragging;
var lastMoveTime;
var jumpPowerBarBg;
var jumpPowerBar;
var jumpPower = 0;
// Main menu elements
var menuContainer;
var titleText;
var playButton;
var playButtonText;
function createMainMenu() {
menuContainer = game.addChild(new Container());
// Game title
titleText = new Text2('F1 HIGHWAY RUSH', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
menuContainer.addChild(titleText);
// Best score display
var bestScore = storage.bestScore || 0;
var bestScoreText = new Text2('BEST: ' + bestScore, {
size: 60,
fill: 0xFFD700
});
bestScoreText.anchor.set(0.5, 0.5);
bestScoreText.x = 2048 / 2;
bestScoreText.y = 950;
menuContainer.addChild(bestScoreText);
// Play button background
playButton = menuContainer.addChild(LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1400,
scaleX: 0.4,
scaleY: 0.3
}));
// Play button text
playButtonText = new Text2('TAP TO PLAY', {
size: 80,
fill: 0xFFFFFF
});
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = 2048 / 2;
playButtonText.y = 1400;
menuContainer.addChild(playButtonText);
// Info button background - create layered design
var infoButtonContainer = menuContainer.addChild(new Container());
infoButtonContainer.x = 2048 / 2;
infoButtonContainer.y = 1700;
// Main button background (dark base)
var infoButtonBg = infoButtonContainer.addChild(LK.getAsset('jumpPowerBarBg', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 0.8
}));
// Button border/frame using lane sections
var infoButtonFrame = infoButtonContainer.addChild(LK.getAsset('lane', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 30,
scaleY: 0.6
}));
// Top accent line
var infoButtonAccent = infoButtonContainer.addChild(LK.getAsset('dashedLine', {
anchorX: 0.5,
anchorY: 0.5,
y: -25,
scaleX: 2,
scaleY: 0.3
}));
// Set the container as the interactive button
var infoButton = infoButtonContainer;
// Info button text
var infoButtonText = new Text2('INFO', {
size: 60,
fill: 0xFFFFFF
});
infoButtonText.anchor.set(0.5, 0.5);
infoButtonText.x = 2048 / 2;
infoButtonText.y = 1700;
menuContainer.addChild(infoButtonText);
// Info button press effect
infoButton.down = function (x, y, obj) {
tween(infoButton, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut
});
};
infoButton.up = function (x, y, obj) {
tween(infoButton, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
showInfoScreen();
}
});
};
// Button press effect
playButton.down = function (x, y, obj) {
tween(playButton, {
scaleX: 0.35,
scaleY: 0.25
}, {
duration: 100,
easing: tween.easeOut
});
};
playButton.up = function (x, y, obj) {
tween(playButton, {
scaleX: 0.4,
scaleY: 0.3
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
startGame();
}
});
};
}
function startGame() {
gameState = "playing";
menuContainer.destroy();
initializeGameplay();
}
function showInfoScreen() {
// Hide main menu
menuContainer.visible = false;
// Create info container
var infoContainer = game.addChild(new Container());
// Info background
var infoBg = infoContainer.addChild(LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 0.8,
scaleY: 1.2
}));
// Info title
var infoTitle = new Text2('HOW TO PLAY', {
size: 100,
fill: 0xFFFFFF
});
infoTitle.anchor.set(0.5, 0.5);
infoTitle.x = 2048 / 2;
infoTitle.y = 600;
infoContainer.addChild(infoTitle);
// Instructions text
var instructions = new Text2('SWIPE LEFT/RIGHT: Change lanes\nDRAG UP/DOWN: Move freely\nTAP: Jump (costs 5 power)\nAvoid all vehicles!\nSurvival = points', {
size: 50,
fill: 0xFFFFFF,
align: 'center'
});
instructions.anchor.set(0.5, 0.5);
instructions.x = 2048 / 2;
instructions.y = 1200;
infoContainer.addChild(instructions);
// Back button
var backButton = infoContainer.addChild(LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 1800,
scaleX: 0.3,
scaleY: 0.2
}));
var backButtonText = new Text2('BACK', {
size: 60,
fill: 0xFFFFFF
});
backButtonText.anchor.set(0.5, 0.5);
backButtonText.x = 2048 / 2;
backButtonText.y = 1800;
infoContainer.addChild(backButtonText);
// Back button functionality
backButton.down = function (x, y, obj) {
tween(backButton, {
scaleX: 0.25,
scaleY: 0.15
}, {
duration: 100,
easing: tween.easeOut
});
};
backButton.up = function (x, y, obj) {
tween(backButton, {
scaleX: 0.3,
scaleY: 0.2
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
infoContainer.destroy();
menuContainer.visible = true;
}
});
};
}
function initializeGameplay() {
// Initialize game variables
// Create road background
roadBg = game.addChild(LK.getAsset('road', {
anchorX: 0.5,
anchorY: 0,
x: 2048 / 2,
y: 0,
scaleY: 10
}));
// Create lane dividers
leftLane = game.addChild(LK.getAsset('lane', {
anchorX: 0.5,
anchorY: 0,
x: lanePositions[0] + 150,
y: 0
}));
rightLane = game.addChild(LK.getAsset('lane', {
anchorX: 0.5,
anchorY: 0,
x: lanePositions[1] + 150,
y: 0
}));
// Create player car
playerCar = game.addChild(new F1Car());
playerCar.x = lanePositions[1];
playerCar.y = 2200;
// Traffic management
trafficCars = [];
spawnTimer = 0;
gameSpeed = 1;
difficultyTimer = 0;
// Score display
scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Best score display during gameplay
var bestScoreGameTxt = new Text2('BEST: ' + (storage.bestScore || 0), {
size: 60,
fill: 0xFFD700
});
bestScoreGameTxt.anchor.set(0.5, 0);
bestScoreGameTxt.y = 100;
LK.gui.top.addChild(bestScoreGameTxt);
// Store reference globally for efficient updates
window.bestScoreGameTxt = bestScoreGameTxt;
// Jump power bar background
jumpPowerBarBg = game.addChild(LK.getAsset('jumpPowerBarBg', {
anchorX: 0.5,
anchorY: 1,
x: 2048 - 100,
y: 2400
}));
// Jump power bar fill
jumpPowerBar = game.addChild(LK.getAsset('jumpPowerBar', {
anchorX: 0.5,
anchorY: 1,
x: 2048 - 100,
y: 2400,
scaleY: 0
}));
// Control variables
dragStartX = 0;
dragStartY = 0;
isDragging = false;
lastMoveTime = 0;
}
// Touch controls
game.down = function (x, y, obj) {
if (gameState !== "playing") return;
dragStartX = x;
dragStartY = y;
isDragging = true;
lastMoveTime = Date.now();
};
game.move = function (x, y, obj) {
if (gameState !== "playing" || !isDragging) return;
var deltaX = x - dragStartX;
var deltaY = y - dragStartY;
var currentTime = Date.now();
// Lane switching (horizontal swipe)
if (Math.abs(deltaX) > 150 && Math.abs(deltaX) > Math.abs(deltaY)) {
if (deltaX > 0 && playerCar.lane < 2) {
playerCar.moveToLane(playerCar.lane + 1);
} else if (deltaX < 0 && playerCar.lane > 0) {
playerCar.moveToLane(playerCar.lane - 1);
}
isDragging = false;
return;
}
// Free movement - follow drag position for vertical movement
if (isDragging) {
// Calculate new Y position based on drag
var newY = playerCar.y + deltaY * 0.5; // Scale factor for smooth movement
// Constrain movement within road boundaries
newY = Math.max(Math.min(newY, 2500), 200);
// Update player position
playerCar.y = newY;
if (playerCar.isJumping) {
// If jumping, update jump start position to maintain relative jump height
playerCar.jumpStartY = newY;
}
// Update drag start position for continuous movement
dragStartY = y;
}
};
game.up = function (x, y, obj) {
if (gameState !== "playing" || !isDragging) return;
var deltaX = x - dragStartX;
var deltaY = y - dragStartY;
var swipeDistance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
// Tap for jump (small movement distance indicates a tap)
if (swipeDistance < 30) {
playerCar.jump();
}
isDragging = false;
};
// Spawn traffic
function spawnTraffic() {
var lane = Math.floor(Math.random() * 3);
var traffic;
var carType = Math.random();
// 60% regular cars, 25% sports cars, 15% trucks
if (carType < 0.6) {
traffic = new TrafficCar();
traffic.speed = 8 + gameSpeed * 2;
} else if (carType < 0.85) {
traffic = new SportsCar();
traffic.speed = 12 + gameSpeed * 2;
} else {
traffic = new Truck();
traffic.speed = 6 + gameSpeed * 2;
}
traffic.x = lanePositions[lane];
traffic.y = -100;
traffic.lane = lane;
trafficCars.push(traffic);
game.addChild(traffic);
}
// Check collisions
function checkCollisions() {
for (var i = trafficCars.length - 1; i >= 0; i--) {
var traffic = trafficCars[i];
// Check collision with player (only if not jumping)
if (!playerCar.isJumping && traffic.lane === playerCar.lane) {
var distance = Math.abs(traffic.y - playerCar.y);
// Different collision distances based on car type
var collisionDistance = 150; // Default for TrafficCar
if (traffic instanceof SportsCar) {
collisionDistance = 125; // Smaller sports car
} else if (traffic instanceof Truck) {
collisionDistance = 175; // Larger truck
}
if (distance < collisionDistance) {
// Collision detected
var currentScore = LK.getScore();
var bestScore = storage.bestScore || 0;
if (currentScore > bestScore) {
storage.bestScore = currentScore;
// Update best score display during gameplay using stored reference
if (window.bestScoreGameTxt) {
window.bestScoreGameTxt.setText('BEST: ' + currentScore);
}
}
LK.getSound('crash').play();
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
return;
}
}
// Remove off-screen traffic
if (traffic.y > 2800) {
traffic.destroy();
trafficCars.splice(i, 1);
}
}
}
// Initialize main menu
createMainMenu();
// Main game loop
game.update = function () {
if (gameState !== "playing") return;
// Update score display
scoreTxt.setText(LK.getScore());
// Update best score display in real-time
var currentScore = LK.getScore();
var bestScore = storage.bestScore || 0;
if (currentScore > bestScore) {
storage.bestScore = currentScore;
// Update best score display during gameplay using stored reference
if (window.bestScoreGameTxt) {
window.bestScoreGameTxt.setText('BEST: ' + currentScore);
}
}
// Spawn traffic
spawnTimer++;
var spawnRate = Math.max(30 - Math.floor(gameSpeed * 3), 15);
if (spawnTimer >= spawnRate) {
spawnTimer = 0;
spawnTraffic();
}
// Increase difficulty over time
difficultyTimer++;
if (difficultyTimer >= 300) {
// Every 5 seconds
difficultyTimer = 0;
gameSpeed += 0.1;
}
// Increase car speed by 10% every 10 points
var currentScore = LK.getScore();
var speedMultiplier = 1 + Math.floor(currentScore / 10) * 0.1;
for (var i = 0; i < trafficCars.length; i++) {
trafficCars[i].speed = (8 + gameSpeed * 2) * speedMultiplier;
}
// Check collisions
checkCollisions();
// Add survival points
if (LK.ticks % 60 === 0) {
// Every second
LK.setScore(LK.getScore() + 1);
}
// Update jump power (fills twice as fast as points)
if (LK.ticks % 30 === 0) {
// Every half second
jumpPower = Math.min(jumpPower + 1, 20); // Max 20 power points
// Update jump power bar scale
jumpPowerBar.scaleY = Math.min(jumpPower / 20, 1);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -178,17 +178,36 @@
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = 2048 / 2;
playButtonText.y = 1400;
menuContainer.addChild(playButtonText);
- // Info button background
- var infoButton = menuContainer.addChild(LK.getAsset('road', {
+ // Info button background - create layered design
+ var infoButtonContainer = menuContainer.addChild(new Container());
+ infoButtonContainer.x = 2048 / 2;
+ infoButtonContainer.y = 1700;
+ // Main button background (dark base)
+ var infoButtonBg = infoButtonContainer.addChild(LK.getAsset('jumpPowerBarBg', {
anchorX: 0.5,
anchorY: 0.5,
- x: 2048 / 2,
- y: 1700,
- scaleX: 0.3,
- scaleY: 0.2
+ scaleX: 4,
+ scaleY: 0.8
}));
+ // Button border/frame using lane sections
+ var infoButtonFrame = infoButtonContainer.addChild(LK.getAsset('lane', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 30,
+ scaleY: 0.6
+ }));
+ // Top accent line
+ var infoButtonAccent = infoButtonContainer.addChild(LK.getAsset('dashedLine', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -25,
+ scaleX: 2,
+ scaleY: 0.3
+ }));
+ // Set the container as the interactive button
+ var infoButton = infoButtonContainer;
// Info button text
var infoButtonText = new Text2('INFO', {
size: 60,
fill: 0xFFFFFF
@@ -199,19 +218,19 @@
menuContainer.addChild(infoButtonText);
// Info button press effect
infoButton.down = function (x, y, obj) {
tween(infoButton, {
- scaleX: 0.25,
- scaleY: 0.15
+ scaleX: 0.9,
+ scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut
});
};
infoButton.up = function (x, y, obj) {
tween(infoButton, {
- scaleX: 0.3,
- scaleY: 0.2
+ scaleX: 1,
+ scaleY: 1
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
@@ -270,10 +289,10 @@
infoTitle.x = 2048 / 2;
infoTitle.y = 600;
infoContainer.addChild(infoTitle);
// Instructions text
- var instructions = new Text2('🏎️ CONTROLS:\n• SWIPE LEFT/RIGHT: Change lanes\n• DRAG: Move freely\n• TAP: Jump over cars\n\n🎯 OBJECTIVE:\n• Avoid all vehicles\n• Survive as long as possible\n• Earn points over time\n\n⚡ JUMP POWER:\n• Refills automatically\n• Use wisely!', {
- size: 45,
+ var instructions = new Text2('SWIPE LEFT/RIGHT: Change lanes\nDRAG UP/DOWN: Move freely\nTAP: Jump (costs 5 power)\nAvoid all vehicles!\nSurvival = points', {
+ size: 50,
fill: 0xFFFFFF,
align: 'center'
});
instructions.anchor.set(0.5, 0.5);
F1 from a bird's eye view. In-Game asset. High contrast. No shadows
car bird's eye view. In-Game asset. 2d. High contrast. No shadows
Red car bird's eye view. In-Game asset. 2d. High contrast. No shadows
Yellow car bird's eye view. In-Game asset. 2d. High contrast. No shadows
Tree 2d. In-Game asset. 2d. High contrast. No shadows
Blue F1 from a bird's eye view.. In-Game asset. 2d. High contrast. No shadows
Green F1 from a bird's eye view.. In-Game asset. 2d. High contrast. No shadows
Purple F1 from a bird's eye view.. In-Game asset. 2d. High contrast. No shadows
Yellow F1 from a bird's eye view.. In-Game asset. 2d. High contrast. No shadows