User prompt
Turn off menu
User prompt
Change the scroll color to red
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'storage.selectedCar = selectedCar;' Line Number: 420
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var selectedCar = storage.get('selectedCar') || 'AiGP'; // Default car selection' Line Number: 1090 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'var selectedCar = storage.get('selectedCar') || 'AiGP'; // Default car selection' Line Number: 1089 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Set default car the selected car from car selector
User prompt
I give you a task and dont give a shit to these bullshit
User prompt
Remove stripes effect from the menu
User prompt
Increase it 500
User prompt
Make 100 units distance between menu buttons
User prompt
Scale up menu buttons size to 4x ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Change player car to aigp
User prompt
Change menu background to black
User prompt
Change player car to aigp
User prompt
Change the player car to the selected one from the car selector
User prompt
Repair this bug
User prompt
Still not work the car change
User prompt
Load to player's car the selected car from the car selector
User prompt
Selected car method is not working
User prompt
Set selected car size to the selected asset size
User prompt
Fix these problems
User prompt
Ensure player's car change to the selected in the car selector menu
User prompt
Update the latest migrated lk engine
User prompt
Ensure all cars from car selector can be selected to be player car
User prompt
CHANGE PLAYERCAR TO THE SELECTED IN CAR SELECTOR MENU!!!
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // ALFRomeo class var ALFRomeo = Container.expand(function () { var self = Container.call(this); var alfaRomeoGraphics = self.attachAsset('ALFRomeo', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.23 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // AiDU class var AiDU = Container.expand(function () { var self = Container.call(this); var audiGraphics = self.attachAsset('AiDU', { anchorX: 0.5, anchorY: 0.5, scaleX: 384.17 / 384.17, scaleY: 922.01 / 922.01 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // AiGP class var AiGP = Container.expand(function () { var self = Container.call(this); var aigpGraphics = self.attachAsset('AiGP', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; return self; }); // AiphaTauri class var AiphaTauri = Container.expand(function () { var self = Container.call(this); var aiphaTauriGraphics = self.attachAsset('AiphaTauri', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.83, scaleY: 0.96 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Aipine class var Aipine = Container.expand(function () { var self = Container.call(this); var aipineGraphics = self.attachAsset('Aipine', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // AshtonMartin class var AshtonMartin = Container.expand(function () { var self = Container.call(this); var astonMartinGraphics = self.attachAsset('AshtonMartin', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.91, scaleY: 0.98 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // BMiWMotorsport50YearAnniversary class var BMiWMotorsport50YearAnniversary = Container.expand(function () { var self = Container.call(this); var bmw50AnniversaryGraphics = self.attachAsset('BMiWMotorsport50YearAnniversary', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // BMiW Willaims class var BMiWWillaims = Container.expand(function () { var self = Container.call(this); var bmwGraphics = self.attachAsset('BMiWWillaims', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.95, scaleY: 0.98 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // BarRonda class var BarRonda = Container.expand(function () { var self = Container.call(this); var barRondaGraphics = self.attachAsset('BarRonda', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.97, scaleY: 0.95 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var BlueBull = Container.expand(function () { var self = Container.call(this); var blueBullGraphics = self.attachAsset('BlueBull', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.89 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var BrainGP = Container.expand(function () { var self = Container.call(this); var brainGPGraphics = self.attachAsset('BrainGP', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var Cadillaic = Container.expand(function () { var self = Container.call(this); var cadillaicGraphics = self.attachAsset('Cadillaic', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); //<Assets used in the game will automatically appear here> // Car class var Car = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset(selectedCar || 'RealBull', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.maxSpeed = 10 * 1.7; self.acceleration = 0.2 * 1.7; self.deceleration = 0.1 * 1.7; self.update = function () { self.y -= self.speed; if (self.speed > 0) { self.speed -= self.deceleration; } }; self.accelerate = function () { if (self.speed < self.maxSpeed) { self.speed += self.acceleration; } }; }); // CarSelector class var CarSelector = Container.expand(function () { var self = Container.call(this); // Create black background var background = LK.getAsset('shape', { width: 2048, height: 2732, color: 0x000000, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.addChild(background); // Create animated diagonal stripes self.stripes = []; for (var i = 0; i < 30; i++) { var stripe = LK.getAsset('shape', { width: 80, height: 4000, color: 0xff0000, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); stripe.rotation = Math.PI / 4; // 45 degree rotation stripe.x = i * 150 - 500; stripe.y = 1366; stripe.alpha = 0.4; self.addChild(stripe); self.stripes.push(stripe); // Start animated movement with tween tween(stripe, { x: stripe.x + 3000 }, { duration: 8000, easing: tween.linear, onFinish: function onFinish() { stripe.x = i * 150 - 500; tween(stripe, { x: stripe.x + 3000 }, { duration: 8000, easing: tween.linear }); } }); } // Title var titleText = new Text2('SELECT YOUR CAR', { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0.5); titleText.x = 1024; titleText.y = 200; self.addChild(titleText); // Create scrollable container for cars var scrollContainer = new Container(); self.addChild(scrollContainer); // All available cars var carAssets = ['RealBull', 'FerrAi', 'MercedeszAiGPetronais', 'McLairen', 'AiDU', 'Willaims', 'ALFRomeo', 'AiphaTauri', 'Aipine', 'AshtonMartin', 'BMiWMotorsport50YearAnniversary', 'BMiWWillaims', 'BarRonda', 'BlueBull', 'BrainGP', 'Cadillaic', 'FRVR', 'ForceIndAi', 'Jaguair', 'Jordain', 'McLairenBrasil', 'McLairenMP4', 'McLairenMercedesz', 'McLairenRondaMP4302015', 'Mercedesz2000', 'MercedeszAiGPerformance', 'AiGP', 'Porshe', 'Renaiult', 'RenaiultTelefonai', 'SaiberKick', 'SaiberPetronais', 'TOTOYA']; var carNames = ['RealBull', 'FerrAi', 'Mercedes', 'McLairen', 'AiDU', 'Williams', 'ALFRomeo', 'AiphaTauri', 'Aipine', 'Aston Martin', 'BMW 50th', 'BMW Williams', 'BarRonda', 'BlueBull', 'BrainGP', 'Cadillaic', 'FRVR', 'ForceIndAi', 'Jaguair', 'Jordain', 'McLairen Brasil', 'McLairen MP4', 'McLairen Mercedes', 'McLairen Ronda', 'Mercedes 2000', 'Mercedes AMG', 'AiGP', 'Porshe', 'Renaiult', 'Renaiult Telefonica', 'SaiberKick', 'SaiberPetronais', 'TOTOYA']; self.carButtons = []; var cols = 4; var carButtonWidth = 300; var carButtonHeight = 400; var spacingX = 100; var spacingY = 150; var scrollAreaWidth = 1800; // Width for scroll area var startY = 350; var scrollY = 0; var maxScrollY = 0; // Calculate starting X position to center the 4-column layout var totalRowWidth = cols * carButtonWidth + (cols - 1) * spacingX; var startX = (2048 - totalRowWidth) / 2; // Calculate total content height var totalRows = Math.ceil(carAssets.length / cols); var totalContentHeight = totalRows * (carButtonHeight + spacingY) - spacingY; var scrollAreaHeight = 1800; // Height of visible scroll area maxScrollY = Math.max(0, totalContentHeight - scrollAreaHeight); for (var i = 0; i < carAssets.length; i++) { var col = i % cols; var row = Math.floor(i / cols); var carX = startX + col * (carButtonWidth + spacingX); var carY = startY + row * (carButtonHeight + spacingY); // Car button background var carBtn = LK.getAsset('shape', { width: carButtonWidth, height: carButtonHeight, color: 0x333333, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: carX, y: carY }); scrollContainer.addChild(carBtn); // Car image var carImage = LK.getAsset(carAssets[i], { anchorX: 0.5, anchorY: 0.5, scaleX: 0.7, scaleY: 0.7, x: carX, y: carY - 50 }); scrollContainer.addChild(carImage); // Car name text var carNameText = new Text2(carNames[i], { size: 30, fill: 0xFFFFFF }); carNameText.anchor.set(0.5, 0.5); carNameText.x = carX; carNameText.y = carY + 120; scrollContainer.addChild(carNameText); // Store button reference with car asset name carBtn.carAsset = carAssets[i]; carBtn.down = function (x, y, obj) { selectedCar = obj.carAsset; console.log("Selected car:", selectedCar); self.destroy(); // Return to main menu mainMenu = game.addChild(new MainMenu()); }; self.carButtons.push(carBtn); } // Create scrollbar on the right side var scrollBarWidth = 40; var scrollBarHeight = scrollAreaHeight; var scrollBarX = 1850; var scrollBarY = startY; // Scrollbar background var scrollBarBg = LK.getAsset('shape', { width: scrollBarWidth, height: scrollBarHeight, color: 0x333333, shape: 'box', anchorX: 0.5, anchorY: 0, x: scrollBarX, y: scrollBarY }); self.addChild(scrollBarBg); // Scrollbar thumb var thumbHeight = Math.max(50, scrollBarHeight * (scrollAreaHeight / totalContentHeight)); var scrollBarThumb = LK.getAsset('shape', { width: scrollBarWidth - 10, height: thumbHeight, color: 0x666666, shape: 'box', anchorX: 0.5, anchorY: 0, x: scrollBarX, y: scrollBarY }); self.addChild(scrollBarThumb); // Scroll functionality self.isDragging = false; self.lastMouseY = 0; // Scrollbar interaction scrollBarBg.down = function (x, y, obj) { var localY = y - scrollBarY; var scrollPercent = localY / scrollBarHeight; scrollY = scrollPercent * maxScrollY; scrollY = Math.max(0, Math.min(maxScrollY, scrollY)); scrollContainer.y = -scrollY; updateScrollThumb(); }; scrollBarThumb.down = function (x, y, obj) { self.isDragging = true; self.lastMouseY = y; }; function updateScrollThumb() { var thumbPosition = scrollY / maxScrollY * (scrollBarHeight - thumbHeight); scrollBarThumb.y = scrollBarY + thumbPosition; } // Mouse wheel scrolling self.scroll = function (deltaY) { scrollY += deltaY * 50; scrollY = Math.max(0, Math.min(maxScrollY, scrollY)); scrollContainer.y = -scrollY; updateScrollThumb(); }; // Close button self.closeBtn = LK.getAsset('shape', { width: 1600, height: 400, color: 0x666666, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2500 }); self.addChild(self.closeBtn); var closeBtnText = new Text2('BACK TO MENU', { size: 160, fill: 0xFFFFFF }); closeBtnText.anchor.set(0.5, 0.5); closeBtnText.x = 1024; closeBtnText.y = 2500; self.addChild(closeBtnText); self.closeBtn.down = function (x, y, obj) { self.destroy(); // Return to main menu mainMenu = game.addChild(new MainMenu()); }; // Handle mouse movement for scrollbar dragging self.move = function (x, y, obj) { if (self.isDragging) { var deltaY = y - self.lastMouseY; var scrollAmount = deltaY / scrollBarHeight * maxScrollY; scrollY += scrollAmount; scrollY = Math.max(0, Math.min(maxScrollY, scrollY)); scrollContainer.y = -scrollY; updateScrollThumb(); self.lastMouseY = y; } }; // Handle mouse up to stop dragging self.up = function (x, y, obj) { self.isDragging = false; }; // Initialize scroll position updateScrollThumb(); return self; }); var FRVR = Container.expand(function () { var self = Container.call(this); var frvrGraphics = self.attachAsset('FRVR', { anchorX: 0.5, anchorY: 0.5, scaleX: 370 / 370, scaleY: 760 / 760 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // FerrAi class var FerrAi = Container.expand(function () { var self = Container.call(this); var ferrAiGraphics = self.attachAsset('FerrAi', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.95 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // ForceIndAi class var ForceIndAi = Container.expand(function () { var self = Container.call(this); var forceIndAiGraphics = self.attachAsset('ForceIndAi', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.83, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Grid class var Grid = Container.expand(function () { var self = Container.call(this); var gridGraphics = self.attachAsset('grid', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); var index = grids.indexOf(self); if (index > -1) { grids.splice(index, 1); } } }; }); // Jaguair class var Jaguair = Container.expand(function () { var self = Container.call(this); var jaguairGraphics = self.attachAsset('Jaguair', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Jordain class var Jordain = Container.expand(function () { var self = Container.call(this); var jordainGraphics = self.attachAsset('Jordain', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.95, scaleY: 0.98 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // MainMenu class var MainMenu = Container.expand(function () { var self = Container.call(this); // Create black background var background = LK.getAsset('shape', { width: 2048, height: 2732, color: 0x000000, shape: 'box', anchorX: 0, anchorY: 0, x: 0, y: 0 }); self.addChild(background); // Create animated diagonal stripes self.stripes = []; for (var i = 0; i < 30; i++) { var stripe = LK.getAsset('shape', { width: 80, height: 4000, color: 0xff0000, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); stripe.rotation = Math.PI / 4; // 45 degree rotation stripe.x = i * 150 - 500; stripe.y = 1366; stripe.alpha = 0.4; self.addChild(stripe); self.stripes.push(stripe); // Start animated movement with tween tween(stripe, { x: stripe.x + 3000 }, { duration: 8000, easing: tween.linear, onFinish: function onFinish() { stripe.x = i * 150 - 500; tween(stripe, { x: stripe.x + 3000 }, { duration: 8000, easing: tween.linear }); } }); } // Car selector button self.carSelectorBtn = LK.getAsset('shape', { width: 1600, height: 400, color: 0x333333, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1200 }); self.addChild(self.carSelectorBtn); var carBtnText = new Text2('SELECT CAR', { size: 160, fill: 0xFFFFFF }); carBtnText.anchor.set(0.5, 0.5); carBtnText.x = 1024; carBtnText.y = 1200; self.addChild(carBtnText); // Difficulty selector button self.difficultySelectorBtn = LK.getAsset('shape', { width: 1600, height: 400, color: 0x333333, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1400 }); self.addChild(self.difficultySelectorBtn); var difficultyBtnText = new Text2('DIFFICULTY', { size: 160, fill: 0xFFFFFF }); difficultyBtnText.anchor.set(0.5, 0.5); difficultyBtnText.x = 1024; difficultyBtnText.y = 1400; self.addChild(difficultyBtnText); // Start button self.startBtn = LK.getAsset('shape', { width: 1600, height: 400, color: 0x00aa00, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1600 }); self.addChild(self.startBtn); var startBtnText = new Text2('START RACE', { size: 160, fill: 0xFFFFFF }); startBtnText.anchor.set(0.5, 0.5); startBtnText.x = 1024; startBtnText.y = 1600; self.addChild(startBtnText); // Animate stripes (handled by tween now) self.update = function () { // Stripe animation now handled by tween plugin }; // Button handlers self.carSelectorBtn.down = function (x, y, obj) { // Open car selector self.destroy(); var carSelector = game.addChild(new CarSelector()); }; self.difficultySelectorBtn.down = function (x, y, obj) { // Difficulty selection logic would go here console.log("Difficulty selector clicked"); }; self.startBtn.down = function (x, y, obj) { // Start the game self.destroy(); startGame(); }; return self; }); // McLairen class var McLairen = Container.expand(function () { var self = Container.call(this); var mclairenGraphics = self.attachAsset('McLairen', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.91 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // MacLaren Ayrton Senna class var McLairenBrasil = Container.expand(function () { var self = Container.call(this); var mclarenGraphics = self.attachAsset('McLairenBrasil', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.91 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var McLairenMP4 = Container.expand(function () { var self = Container.call(this); var mclarenMP4Graphics = self.attachAsset('McLairenMP4', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 0.91 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // McLairenMercedesz class var McLairenMercedesz = Container.expand(function () { var self = Container.call(this); var mclarenMercedesGraphics = self.attachAsset('McLairenMercedesz', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.91 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // McLairen Ronda MP4-30 (2015) class var McLairenRondaMP4302015 = Container.expand(function () { var self = Container.call(this); var mclarenRondaGraphics = self.attachAsset('McLairenRondaMP4302015', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Mercedesz2000 class var Mercedesz2000 = Container.expand(function () { var self = Container.call(this); var mercedesz2000Graphics = self.attachAsset('Mercedesz2000', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var MercedeszAiGPerformance = Container.expand(function () { var self = Container.call(this); var mercedeszAiGPerformanceGraphics = self.attachAsset('MercedeszAiGPerformance', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // MercedeszAiGPetronais class var MercedeszAiGPetronais = Container.expand(function () { var self = Container.call(this); var mercedesGraphics = self.attachAsset('MercedeszAiGPetronais', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.79, scaleY: 0.96 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var Porshe = Container.expand(function () { var self = Container.call(this); var porsheGraphics = self.attachAsset('Porshe', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // RealBull class var RealBull = Container.expand(function () { var self = Container.call(this); var realBullGraphics = self.attachAsset('RealBull', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Renaiult class var Renaiult = Container.expand(function () { var self = Container.call(this); var renaultGraphics = self.attachAsset('Renaiult', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var RenaiultTelefonica = Container.expand(function () { var self = Container.call(this); var renaiultTelefonicaGraphics = self.attachAsset('RenaiultTelefonai', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // SaiberKick class var SaiberKick = Container.expand(function () { var self = Container.call(this); var saiberKickGraphics = self.attachAsset('SaiberKick', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // SaiberPetronais class var SaiberPetronais = Container.expand(function () { var self = Container.call(this); var saiberGraphics = self.attachAsset('SaiberPetronais', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.89, scaleY: 0.94 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); var TOTOYA = Container.expand(function () { var self = Container.call(this); var tGraphics = self.attachAsset('TOTOYA', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.0 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); // Williams class var Willaims = Container.expand(function () { var self = Container.call(this); var williamsGraphics = self.attachAsset('Willaims', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.0, scaleY: 1.02 }); self.speed = 5 / 1.5 * 2 * 1.7; self.update = function () { self.y += self.speed; if (self.y > 2732 || obstacles.length > 4) { self.destroy(); var index = obstacles.indexOf(self); if (index > -1) { obstacles.splice(index, 1); } } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Game state variables var gameStarted = false; var mainMenu = null; var selectedCar = 'AiGP'; // Default car selection // Function to start the actual game function startGame() { gameStarted = true; // Play background music LK.playMusic('v', { loop: true }); // Initialize all game elements that were previously in the main code initializeRaceTrack(); initializeGrids(); initializeCar(); initializeUI(); } function initializeRaceTrack() { racetrack = LK.getAsset('racetrack', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 2000, scaleY: 2732 / 2850, x: 2048 / 2, y: 0 }); game.addChild(racetrack); racetrack2 = LK.getAsset('racetrack', { anchorX: 0.5, anchorY: 0.5, scaleX: 2048 / 2000, scaleY: 2732 / 2850, x: 2048 / 2, y: -2732 }); game.addChild(racetrack2); leftFrame = LK.getAsset('leftFrame', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(leftFrame); closingLine1 = LK.getAsset('closingLine1', { anchorX: 0, anchorY: 0, x: 50, y: 0 }); game.addChild(closingLine1); rightFrame = LK.getAsset('rightFrame', { anchorX: 1, anchorY: 0, x: 2048, y: 0 }); game.addChild(rightFrame); closingLine2 = LK.getAsset('closingLine2', { anchorX: 1, anchorY: 0, x: 2048 - 50, y: 0 }); game.addChild(closingLine2); } function initializeGrids() { grids = []; for (var i = 0; i < 5; i++) { var grid = new Grid(); grid.x = i % 2 === 0 ? 524 : 1524; // Alternate left and right grid.y = 2732 - 1000 - i * 1000; // Ensure all grids are positioned at the same distance apart if (!grids.some(function (existingGrid) { return existingGrid.x === grid.x && existingGrid.y === grid.y; })) { game.addChild(grid); grids.push(grid); } } } function initializeCar() { car = game.addChild(new Car()); car.x = 524; // Start from the grid on the left side of the map car.y = 2732 - 200 - 277 + 25; } function initializeUI() { scoreTxt = new Text2('0', { size: 30, // Reduced to one-fifth fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 1); // Adjust anchor for bottom-left positioning LK.gui.bottomLeft.addChild(scoreTxt); // Move to bottom-left corner timeTxt = new Text2('Current time: 0-0-0-0-0-0', { size: 30, // Same size as scoreTxt fill: 0xFFFFFF }); timeTxt.anchor.set(0.5, 1); // Centered at the bottom LK.gui.bottom.addChild(timeTxt); // Add to bottom center } // Show main menu on game start mainMenu = game.addChild(new MainMenu()); // Declare global variables var keys = {}; var racetrackSpeed = 0; var racetrackAcceleration = 4; var racetrack, racetrack2, leftFrame, rightFrame, closingLine1, closingLine2; var grids = []; var overtakenObstacles = 0; var car; var obstacles = []; var carTypeLoadCounts = {}; var score = 0; var lastSpawnTick = 0; var scoreTxt, timeTxt; function countCarType(carType) { return obstacles.filter(function (obstacle) { return obstacle.constructor.name === carType; }).length; } // Add keyboard event listeners for controlling the player's car game.on('keydown', function (event) { keys[event.code] = true; if (gameStarted && car && event.code === 'KeyA') { car.x -= car.speed; } }); game.on('keyup', function (event) { keys[event.code] = false; }); function spawnObstacle() { if (obstacles.length >= 3) { return; } // Limit to a maximum of three cars on the track var carTypes = [RealBull, BlueBull, FerrAi, Willaims, MercedeszAiGPetronais, AiDU, AshtonMartin, BMiWWillaims, BMiWMotorsport50YearAnniversary, ALFRomeo, McLairenBrasil, Renaiult, RenaiultTelefonica, McLairen, Aipine, McLairenMercedesz, McLairenMP4, AiphaTauri, ForceIndAi, BarRonda, Jaguair, Jordain, TOTOYA, SaiberPetronais, McLairenRondaMP4302015, Mercedesz2000, SaiberKick, MercedeszAiGPerformance]; carTypes.forEach(function (carType) { if (!carTypeLoadCounts[carType.name]) { carTypeLoadCounts[carType.name] = 0; } }); var carTypeCounts = carTypes.map(function (carType) { return countCarType(carType.name); }); if (carTypeCounts.every(function (count) { return count >= 2; })) { return; } var carTypes = [RealBull, BlueBull, FerrAi, Willaims, MercedeszAiGPetronais, AiDU, AshtonMartin, BMiWWillaims, BMiWMotorsport50YearAnniversary, ALFRomeo, McLairenBrasil, Renaiult, RenaiultTelefonica, McLairen, Aipine, McLairenMercedesz, McLairenMP4, AiphaTauri, ForceIndAi, FRVR, BarRonda, Jaguair, Jordain, TOTOYA, SaiberPetronais, SaiberKick, BrainGP, Cadillaic, Porshe, MercedeszAiGPerformance]; var startX = 50 + 200; // Ensure at least 50 units from the left edge var spacing = (2048 - 100) / 4; // Adjust spacing to ensure at least 50 units from the right edge var carType; do { carType = carTypes[Math.floor(Math.random() * carTypes.length)]; } while (carTypeLoadCounts[carType.name] >= 2 || carType === FRVR && carTypeLoadCounts[carType.name] >= 1); carTypeLoadCounts[carType.name]++; if (Object.values(carTypeLoadCounts).every(function (count) { return count >= 2; })) { for (var key in carTypeLoadCounts) { carTypeLoadCounts[key] = 0; } } var car = new carType(); car.x = startX + Math.floor(Math.random() * 4) * spacing; car.y = 200; // Position all cars at the same y-coordinate obstacles.push(car); game.addChild(car); } function updateScore() { score += 1; scoreTxt.setText('OVERTAKING: ' + score); } game.move = function (x, y, obj) { if (gameStarted && car) { car.x = x; } }; game.update = function () { if (!gameStarted) { return; } car.update(); // Calculate elapsed time var totalMilliseconds = Math.floor(LK.ticks * (1000 / 60)); // Convert ticks to milliseconds var hours = Math.floor(totalMilliseconds / 3600000); var minutes = Math.floor(totalMilliseconds % 3600000 / 60000); var seconds = Math.floor(totalMilliseconds % 60000 / 1000); var tenths = Math.floor(totalMilliseconds % 1000 / 100); var hundredths = Math.floor(totalMilliseconds % 100 / 10); var feelingMinute = Math.floor(totalMilliseconds % 10); // Update time display timeTxt.setText("Current time: ".concat(hours, "-").concat(minutes, "-").concat(seconds, "-").concat(tenths, "-").concat(hundredths, "-").concat(feelingMinute)); // Update grid positions to match racetrack speed for (var i = grids.length - 1; i >= 0; i--) { grids[i].y += racetrackSpeed; if (grids[i].y > 2732) { grids[i].y = -1000; // Reset grid position for continuous scrolling } } racetrack.y += racetrackSpeed; racetrack2.y += racetrackSpeed; if (LK.ticks <= 60) { racetrackSpeed += racetrackAcceleration / 20; // Increase acceleration by one and a half times for the first second } else { racetrackSpeed += racetrackAcceleration / 60; // Normal acceleration } // Reset racetrack positions for continuous scrolling if (racetrack.y >= 2732) { racetrack.y = racetrack2.y - 2732; } if (racetrack2.y >= 2732) { racetrack2.y = racetrack.y - 2732; } // Update car position based on keyboard input if (keys['ArrowLeft'] || keys['KeyA']) { car.x -= car.speed; } if (keys['ArrowRight']) { car.x += car.speed; } if (keys['ArrowUp']) { car.accelerate(); } // Check if more than 51% of the car is out of bounds and apply drifting var carWidth = car.width; var carLeftEdge = car.x - carWidth / 2; var carRightEdge = car.x + carWidth / 2; var fieldLeftEdge = 0; var fieldRightEdge = 2048; if (carLeftEdge < fieldLeftEdge) { if (carRightEdge < fieldLeftEdge + carWidth * 0.49) { // More than 51% of the car is out of bounds on the left car.x += car.speed * 0.5; // Drift right } else { car.x = fieldLeftEdge + carWidth / 2; } } else if (carRightEdge > fieldRightEdge) { if (carLeftEdge > fieldRightEdge - carWidth * 0.49) { // More than 51% of the car is out of bounds on the right car.x -= car.speed * 0.5; // Drift left } else { car.x = fieldRightEdge - carWidth / 2; } } for (var i = obstacles.length - 1; i >= 0; i--) { obstacles[i].update(); if (car.intersects(obstacles[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (obstacles[i].y - obstacles[i].height > 2732) { overtakenObstacles++; obstacles[i].destroy(); obstacles.splice(i, 1); } } if (overtakenObstacles >= 10) { grid.visible = false; } if (LK.ticks > 240 && LK.ticks % 72 == 0) { // Spawn a car every 1.2 seconds (72 ticks) spawnObstacle(); updateScore(); } };
===================================================================
--- original.js
+++ change.js
@@ -711,18 +711,18 @@
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
- y: 1350
+ y: 1400
});
self.addChild(self.difficultySelectorBtn);
var difficultyBtnText = new Text2('DIFFICULTY', {
size: 160,
fill: 0xFFFFFF
});
difficultyBtnText.anchor.set(0.5, 0.5);
difficultyBtnText.x = 1024;
- difficultyBtnText.y = 1350;
+ difficultyBtnText.y = 1400;
self.addChild(difficultyBtnText);
// Start button
self.startBtn = LK.getAsset('shape', {
width: 1600,
@@ -731,18 +731,18 @@
shape: 'box',
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
- y: 1500
+ y: 1600
});
self.addChild(self.startBtn);
var startBtnText = new Text2('START RACE', {
size: 160,
fill: 0xFFFFFF
});
startBtnText.anchor.set(0.5, 0.5);
startBtnText.x = 1024;
- startBtnText.y = 1500;
+ startBtnText.y = 1600;
self.addChild(startBtnText);
// Animate stripes (handled by tween now)
self.update = function () {
// Stripe animation now handled by tween plugin
grass top view.
Add more dark carbon fiber background and resize the picture to 16:9
F1 race car. Glossy blue body painting and half covered with planet blue Earth. Blue front wing. myearthdream.com text on black rear wing. 7 number on the nose of the car. Red Honda logo with White R logo on the nose of the car. Top view.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
F1 Jaguair race car. Shiny green body. white Jaguar animal logo on body. thin red and white stripes. white front wings and white rear wing. TOP VIEW!. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
RedBull F1 race car. Top view. Royalblue body with Shinyred lines on sides. Silver bull-body. Silver ,,BlueBull" sponsors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Black McLaren MP4-29 F1 RACE CAR with red lines and white,,RONDA"text. TOP VIEW.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Photorealistic F1 McLaren race car, Top view. Orange coloured body and black thick stripe with white Chrome text where the o letter is Google chrome logo. Skyblue lines on nose sides. Silver 4 number on nose. Black OKX text on rear wing.
Photorealistic F1 race car without Halo safety device. Top view. White body with neongreen nose. Black BrainGP text on body sides. Red "Cainon" text on front wings. Neongreen rear wing with Orange "BRAWNDO" text.
Photorealistic RedBull f1 car top view. Replace RedBull text to RealBull text.
Photorealistic Cadillac F1 race car, top view. Replace Cadillac text to golden coloured ,,Cadillaic" text on black rear wing. Big American flag on white body. White ,,Andretti" and gm text on black front wing.
Photorealistic Porsche F1 race car, top view. Golden logo on car nose. White body with black rear and front wing. Very thick red lines on body from front wing to rear wing. Replace Porsche text to white coloured ,,Porshe" text on rear wing.
Photorealistic Renault F1 race car, top view. Bright skyblue body. Banana Yellow nose with blue sidelines. Royalblue Front and Rear wing. Neon-yellow ,,Telefonicai" text on rearwing. White ,,TEAM SPIRIT" text on nose. Blue ,,RENAIULT" text on body.