User prompt
Arregla todos los errores
User prompt
Arregla todos los errores
User prompt
Haz que se puedan ver los botones de girar y el botón de arrancar
User prompt
Añade un poco más de obstáculos
User prompt
Elimina las paredes en todo el centro de la pantalla
User prompt
Añade un límite de 3 vidas al jugador, que pierda una vida cada vez que choque con un obstáculo
User prompt
Haz que las paredes estén al borde de los escenarios
User prompt
Repara todos los errores
User prompt
Haz que cada pared de cada pista esté sincronizada con su respectiva imagen
User prompt
Añade 3 pistas diferentes con diferentes fondos
User prompt
Agrega una animación para el fondo del menú ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrégale una foto al fondo del menú
User prompt
Ahora agrégale multijugador
User prompt
Please fix the bug: 'Uncaught TypeError: Failed to execute 'attachShader' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLShader'.' in or related to this line: 'if (gameState === 'racing' && player) {' Line Number: 522
User prompt
Please fix the bug: 'TypeError: setTimeout is not a function' in or related to this line: 'setTimeout(function () {' Line Number: 444
Code edit (1 edits merged)
Please save this source code
User prompt
Freddy's Racing Championship
Initial prompt
I would like to create a multiplayer and storymode game in the style of Mario Kart for Android, a racing game set in the animations of the 80s with 6 characters: a bear named Freddy, a blue rabbit named Bonnie, a yellow chicken named Chica, a red fox named Foxy, an animatronic endoskeleton named Endo and another yellow bear named Golden Freddy (Golden Freddy and Endo are difficult characters to unlock). That each player can create their own nickname and can enter their Google Play account, that the game has the following achievements: make a race in the shortest possible time, win 5 races with Foxy, win 5 races with Freddy, win 5 races with Endo or Golden Freddy, unlock Endo and unlock Golden Freddy. That there are 3 race tracks: first track: Candy Kingdom: a pink race track themed around candy and sweets, second track: Family Dinner: a track themed around Fredbear's Family Dinner pizzeria and third track: Funtime!: a race track themed around the Fnaf sister location animatronics that each race track has its obstacles: such as an animatronic endoskeleton, broken Freddy heads, wrenches, and knives.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Button = Container.expand(function (text, callback) {
var self = Container.call(this);
self.callback = callback;
var bg = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2(text, {
size: 40,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.down = function () {
LK.getSound('select').play();
if (self.callback) {
self.callback();
}
};
return self;
});
var Character = Container.expand(function (characterType) {
var self = Container.call(this);
self.characterType = characterType || 'freddy';
self.speed = 0;
self.maxSpeed = 8;
self.acceleration = 0.3;
self.deceleration = 0.2;
self.turnSpeed = 0.1;
self.direction = 0;
self.isUnlocked = true;
// Set unlock status
if (self.characterType === 'endo') {
self.isUnlocked = storage.endoUnlocked || false;
} else if (self.characterType === 'golden_freddy') {
self.isUnlocked = storage.goldenFreddyUnlocked || false;
}
var sprite = self.attachAsset(self.characterType, {
anchorX: 0.5,
anchorY: 0.5
});
self.moveForward = function () {
if (self.speed < self.maxSpeed) {
self.speed += self.acceleration;
}
};
self.moveBackward = function () {
if (self.speed > -self.maxSpeed * 0.5) {
self.speed -= self.acceleration;
}
};
self.turnLeft = function () {
self.direction -= self.turnSpeed;
sprite.rotation = self.direction;
};
self.turnRight = function () {
self.direction += self.turnSpeed;
sprite.rotation = self.direction;
};
self.applyDeceleration = function () {
if (self.speed > 0) {
self.speed -= self.deceleration;
if (self.speed < 0) self.speed = 0;
} else if (self.speed < 0) {
self.speed += self.deceleration;
if (self.speed > 0) self.speed = 0;
}
};
self.update = function () {
// Move based on current speed and direction
self.x += Math.sin(self.direction) * self.speed;
self.y -= Math.cos(self.direction) * self.speed;
// Keep within track bounds
if (self.x < 100) self.x = 100;
if (self.x > 1948) self.x = 1948;
if (self.y < 100) self.y = 100;
if (self.y > 2632) self.y = 2632;
};
return self;
});
var CharacterCard = Container.expand(function (characterType) {
var self = Container.call(this);
self.characterType = characterType;
var bg = self.attachAsset('character_card', {
anchorX: 0.5,
anchorY: 0.5
});
var character = new Character(characterType);
character.x = 0;
character.y = -50;
self.addChild(character);
var nameText = new Text2(characterType.toUpperCase(), {
size: 24,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameText.y = 80;
self.addChild(nameText);
// Show locked status
if (!character.isUnlocked) {
bg.tint = 0x666666;
var lockText = new Text2("LOCKED", {
size: 20,
fill: 0xFF0000
});
lockText.anchor.set(0.5, 0.5);
lockText.y = 100;
self.addChild(lockText);
}
self.down = function () {
if (character.isUnlocked) {
LK.getSound('select').play();
selectedCharacter = self.characterType;
startRace();
}
};
return self;
});
var Obstacle = Container.expand(function (obstacleType, x, y) {
var self = Container.call(this);
self.obstacleType = obstacleType || 'endoskeleton';
self.x = x || 0;
self.y = y || 0;
var sprite = self.attachAsset(self.obstacleType, {
anchorX: 0.5,
anchorY: 0.5
});
// Add some rotation for visual variety
sprite.rotation = Math.random() * Math.PI * 2;
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001122
});
/****
* Game Code
****/
// Sounds
// UI elements
// Obstacles
// Track elements
// Character sprites
var gameState = 'menu'; // 'menu', 'character_select', 'racing', 'results'
var selectedCharacter = 'freddy';
var player = null;
var obstacles = [];
var lapTime = 0;
var startTime = 0;
var bestTime = storage.bestTime || 999999;
var raceDistance = 0;
var totalRaceDistance = 3000;
// Initialize storage defaults
if (storage.gamesPlayed === undefined) storage.gamesPlayed = 0;
if (storage.wins === undefined) storage.wins = 0;
if (storage.endoUnlocked === undefined) storage.endoUnlocked = false;
if (storage.goldenFreddyUnlocked === undefined) storage.goldenFreddyUnlocked = false;
// UI Elements
var titleText = new Text2("FREDDY'S RACING\nCHAMPIONSHIP", {
size: 80,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 400;
var timeText = new Text2("", {
size: 60,
fill: 0xFFFFFF
});
timeText.anchor.set(0.5, 0);
LK.gui.top.addChild(timeText);
var speedText = new Text2("", {
size: 40,
fill: 0x00FF00
});
speedText.anchor.set(0, 0);
LK.gui.bottomLeft.addChild(speedText);
var progressText = new Text2("", {
size: 40,
fill: 0xFFFF00
});
progressText.anchor.set(1, 0);
LK.gui.bottomRight.addChild(progressText);
function showMenu() {
gameState = 'menu';
game.removeChildren();
game.addChild(titleText);
var playButton = new Button("START RACE", function () {
showCharacterSelect();
});
playButton.x = 1024;
playButton.y = 800;
game.addChild(playButton);
var statsButton = new Button("STATS", function () {
showStats();
});
statsButton.x = 1024;
statsButton.y = 920;
game.addChild(statsButton);
// Show best time
if (bestTime < 999999) {
var bestTimeText = new Text2("Best Time: " + (bestTime / 1000).toFixed(2) + "s", {
size: 40,
fill: 0x00FF00
});
bestTimeText.anchor.set(0.5, 0.5);
bestTimeText.x = 1024;
bestTimeText.y = 1200;
game.addChild(bestTimeText);
}
}
function showCharacterSelect() {
gameState = 'character_select';
game.removeChildren();
var selectText = new Text2("SELECT CHARACTER", {
size: 60,
fill: 0xFFD700
});
selectText.anchor.set(0.5, 0.5);
selectText.x = 1024;
selectText.y = 300;
game.addChild(selectText);
var characters = ['freddy', 'bonnie', 'chica', 'foxy', 'endo', 'golden_freddy'];
var startX = 300;
var spacing = 300;
for (var i = 0; i < characters.length; i++) {
var card = new CharacterCard(characters[i]);
card.x = startX + i % 3 * spacing;
card.y = 600 + Math.floor(i / 3) * 400;
game.addChild(card);
}
var backButton = new Button("BACK", function () {
showMenu();
});
backButton.x = 200;
backButton.y = 200;
game.addChild(backButton);
}
function showStats() {
game.removeChildren();
var statsText = new Text2("STATISTICS", {
size: 60,
fill: 0xFFD700
});
statsText.anchor.set(0.5, 0.5);
statsText.x = 1024;
statsText.y = 300;
game.addChild(statsText);
var gamesText = new Text2("Games Played: " + storage.gamesPlayed, {
size: 40,
fill: 0xFFFFFF
});
gamesText.anchor.set(0.5, 0.5);
gamesText.x = 1024;
gamesText.y = 500;
game.addChild(gamesText);
var winsText = new Text2("Wins: " + storage.wins, {
size: 40,
fill: 0xFFFFFF
});
winsText.anchor.set(0.5, 0.5);
winsText.x = 1024;
winsText.y = 600;
game.addChild(winsText);
var backButton = new Button("BACK", function () {
showMenu();
});
backButton.x = 1024;
backButton.y = 800;
game.addChild(backButton);
}
function startRace() {
gameState = 'racing';
game.removeChildren();
// Create player
player = new Character(selectedCharacter);
player.x = 1024;
player.y = 2400;
game.addChild(player);
// Create track elements
createTrack();
createObstacles();
// Start race timer
startTime = Date.now();
lapTime = 0;
raceDistance = 0;
// Play race music
LK.playMusic('race_music');
storage.gamesPlayed++;
}
function createTrack() {
// Create simple track walls
for (var i = 0; i < 20; i++) {
var leftWall = LK.getAsset('track_wall', {
anchorX: 0.5,
anchorY: 0.5
});
leftWall.x = 50;
leftWall.y = i * 150;
game.addChild(leftWall);
var rightWall = LK.getAsset('track_wall', {
anchorX: 0.5,
anchorY: 0.5
});
rightWall.x = 1998;
rightWall.y = i * 150;
game.addChild(rightWall);
}
// Create finish line
var finishLine = LK.getAsset('finish_line', {
anchorX: 0.5,
anchorY: 0.5
});
finishLine.x = 1024;
finishLine.y = 100;
game.addChild(finishLine);
}
function createObstacles() {
obstacles = [];
var obstacleTypes = ['endoskeleton', 'broken_head', 'wrench', 'knife'];
for (var i = 0; i < 15; i++) {
var type = obstacleTypes[Math.floor(Math.random() * obstacleTypes.length)];
var x = 200 + Math.random() * 1648;
var y = 200 + Math.random() * 2200;
var obstacle = new Obstacle(type, x, y);
obstacles.push(obstacle);
game.addChild(obstacle);
}
}
function checkCollisions() {
if (!player) return;
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
if (player.intersects(obstacle)) {
// Crash effect
LK.getSound('crash').play();
LK.effects.flashObject(player, 0xFF0000, 500);
// Slow down player
player.speed *= 0.5;
// Move obstacle away
obstacle.x = -1000;
obstacle.y = -1000;
}
}
}
function updateRace() {
if (!player) return;
// Update race distance based on forward progress
var progress = (2400 - player.y) / 2300;
if (progress > raceDistance / totalRaceDistance) {
raceDistance = progress * totalRaceDistance;
}
// Check if race is finished
if (player.y <= 100) {
finishRace();
}
// Update UI
lapTime = Date.now() - startTime;
timeText.setText("Time: " + (lapTime / 1000).toFixed(2) + "s");
speedText.setText("Speed: " + Math.floor(player.speed * 10));
progressText.setText("Progress: " + Math.floor(raceDistance / totalRaceDistance * 100) + "%");
}
function finishRace() {
gameState = 'results';
// Stop music
LK.stopMusic();
// Check for new best time
var isNewBest = lapTime < bestTime;
if (isNewBest) {
bestTime = lapTime;
storage.bestTime = bestTime;
storage.wins++;
}
// Check for unlock conditions
if (lapTime < 30000 && !storage.endoUnlocked) {
// Under 30 seconds
storage.endoUnlocked = true;
LK.effects.flashScreen(0x00FF00, 1000);
}
if (storage.wins >= 5 && !storage.goldenFreddyUnlocked) {
storage.goldenFreddyUnlocked = true;
LK.effects.flashScreen(0xDAA520, 1000);
}
// Show results
LK.setTimeout(function () {
showResults(isNewBest);
}, 1000);
}
function showResults(isNewBest) {
game.removeChildren();
var resultsText = new Text2("RACE COMPLETE!", {
size: 60,
fill: 0xFFD700
});
resultsText.anchor.set(0.5, 0.5);
resultsText.x = 1024;
resultsText.y = 400;
game.addChild(resultsText);
var timeResultText = new Text2("Your Time: " + (lapTime / 1000).toFixed(2) + "s", {
size: 50,
fill: isNewBest ? "#00FF00" : "#FFFFFF"
});
timeResultText.anchor.set(0.5, 0.5);
timeResultText.x = 1024;
timeResultText.y = 600;
game.addChild(timeResultText);
if (isNewBest) {
var newBestText = new Text2("NEW BEST TIME!", {
size: 40,
fill: 0x00FF00
});
newBestText.anchor.set(0.5, 0.5);
newBestText.x = 1024;
newBestText.y = 700;
game.addChild(newBestText);
}
var playAgainButton = new Button("RACE AGAIN", function () {
showCharacterSelect();
});
playAgainButton.x = 1024;
playAgainButton.y = 900;
game.addChild(playAgainButton);
var menuButton = new Button("MAIN MENU", function () {
showMenu();
});
menuButton.x = 1024;
menuButton.y = 1020;
game.addChild(menuButton);
}
// Touch controls
var isAccelerating = false;
var isBraking = false;
var isTurningLeft = false;
var isTurningRight = false;
game.down = function (x, y, obj) {
if (gameState !== 'racing' || !player) return;
// Divide screen into control zones
if (y > 2000) {
// Bottom area for acceleration/braking
if (x < 1024) {
isBraking = true;
} else {
isAccelerating = true;
}
} else {
// Upper area for steering
if (x < 1024) {
isTurningLeft = true;
} else {
isTurningRight = true;
}
}
};
game.up = function (x, y, obj) {
isAccelerating = false;
isBraking = false;
isTurningLeft = false;
isTurningRight = false;
};
game.update = function () {
if (gameState === 'racing' && player) {
// Handle controls
if (isAccelerating) {
player.moveForward();
if (LK.ticks % 20 === 0) {
LK.getSound('engine').play();
}
} else if (isBraking) {
player.moveBackward();
} else {
player.applyDeceleration();
}
if (isTurningLeft) {
player.turnLeft();
}
if (isTurningRight) {
player.turnRight();
}
checkCollisions();
updateRace();
}
};
// Initialize game
showMenu(); ===================================================================
--- original.js
+++ change.js
@@ -394,9 +394,9 @@
storage.goldenFreddyUnlocked = true;
LK.effects.flashScreen(0xDAA520, 1000);
}
// Show results
- setTimeout(function () {
+ LK.setTimeout(function () {
showResults(isNewBest);
}, 1000);
}
function showResults(isNewBest) {
Fullscreen modern App Store landscape banner, 16:9, high definition, for a game titled "Freddy's Racing Championship" and with the description "Kart racing game featuring FNAF animatronic characters racing through 80s-themed tracks with unique obstacles and unlockable characters.". No text on banner!
Un conejo morado animatronico en un kart. In-Game asset. No shadows
Un oso dorado animatronico en un kart. In-Game asset. High contrast. No shadows
Un endoesqueleto animatronico en un kart. In-Game asset. 2d. High contrast. No shadows
Un pollo amarillo animatronico en un kart. In-Game asset. 2d. High contrast. No shadows
Un oso animatronico en un kart. In-Game asset. 2d. High contrast. No shadows
Un zorro rojo animatronico en un kart. In-Game asset. 2d. High contrast. No shadows
Mascara de Freddy Fazbear. In-Game asset. 2d. High contrast. No shadows
Llave inglesa. In-Game asset. 2d. High contrast. No shadows
Endoesqueleto animatronico. In-Game asset. 2d. High contrast. No shadows
Línea de meta. In-Game asset. 2d. High contrast. No shadows
Cuchillo con sangre. In-Game asset. 2d. High contrast. No shadows
Pared de ladrillos. In-Game asset. 2d. High contrast. No shadows
Botón rojo. In-Game asset. 2d. High contrast. No shadows
Imagen de bandera de carrera. In-Game asset. 2d. High contrast. No shadows
Pista de carreras desde arriba. In-Game asset. 2d. High contrast. No shadows