User prompt
que te dije sobre el texto? porque no se ve el texto de los demas? osea te dije que pongas el texto y se ve tipo con opacidad al 20%, tambien arregla de q si eres un impostor no puedas hacer misiones, y tambien añade el boton del mapa para ver las misiones, (el boton estara abajo a la izquierda) y
User prompt
que paso? , y lo que tedije? quiero que el texto q digan los demas se vea clarito, y q puedas votar a los demas, y q añadas el boton donde diga jugar y al darle jugar te saldra de cual bando eressss
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'x')' in or related to this line: 'player.x = 1024;' Line Number: 278
User prompt
entonces haz lo q te dije pero no cambies nada ni añadas el joystick
Code edit (1 edits merged)
Please save this source code
User prompt
Among Us: IA Edition
Initial prompt
quiero que hables en español desde ahora ok?, el juego que vamos a hacer esta inspirado en un juego que ya fue hecho, el juego se llama Among Us.Este es un juego de deducción social para un solo jugador humano, inmerso en un mundo donde el resto de los participantes son controlados por una sofisticada inteligencia artificial. El mapa del juego es The Skeld, el clásico de Among Us, que se muestra en la imagen que proporcionaste. Inicio de la Partida Al iniciar el juego, verás un botón que dice "Jugar". Al presionarlo, serás transportado a una sala de espera junto a 14 personajes de IA. Después de 10 segundos, una pantalla de carga aparecerá por 3 segundos. Luego, se te revelará tu rol en la partida. Si eres un Tripulante: Se te notificará con el texto "Eres un tripulante, cumple tus misiones para ganar el juego". Si eres un Impostor: Se te dirá "Impostor, mata a los demás para ganar". Roles y Jugadores Tú (Jugador Humano): El único jugador real. Inteligencia Artificial (IA): Hay 14 personajes de IA, que pueden ser tanto Tripulantes como Impostores. Impostores (IA): Hay 2 impostores en total. Si te toca ser el Impostor, tendrás un compañero impostor de IA, y el nombre de este será de color rojo. Los impostores de IA solo pueden matar a otros tripulantes de IA, y no al jugador real. Solo matan cuando se encuentran cerca de un tripulante de IA. Tripulantes (IA): Hay 13 tripulantes. Si eres un Tripulante, los nombres de los demás personajes (tripulantes o impostores de IA) se verán de color gris. Misiones y Mecánicas del Jugador Real Si eres Tripulante: Tu objetivo es completar 8 misiones repartidas por el mapa. Para saber dónde se encuentran, puedes abrir el mapa, que se mostrará en un tono amarillo. Las misiones estarán marcadas con cuadrados azules. Al llegar a la ubicación, podrás interactuar para completar la tarea. Las misiones son: limpiar la cocina sucia, sumar 2+2, reciclar residuos, cargar los propulsores y ajustar la antena de comunicación, además de otras tres tareas que pueden ser aleatorias, como reajustar los escudos o limpiar el filtro de O2. Si eres Impostor: Tu objetivo es matar a los Tripulantes. A diferencia de las IA, tú puedes matar a cualquier tripulante (IA o humano, si hubiera) en cualquier momento, con un tiempo de recarga de 15 segundos. El botón para matar solo aparece cuando eres Impostor. El Botón de Emergencia y el Chat Cuando se reporta un cuerpo o se presiona el botón de emergencia, se iniciará una fase de votación. Se mostrará una pantalla con el texto "¡TIEMPO DE VOTACIÓN!". Habrá un tiempo límite de 30 segundos para la discusión y la votación. A continuación, podrás ver a todos los tripulantes para votar. Arriba habrá un icono de chat donde podrás escribir libremente con tu teclado. Los personajes de IA, en cambio, solo enviarán una serie de mensajes predeterminados, que aparecerán cada 2 segundos, con sus nombres de usuario delante. Los nombres de usuario y los mensajes son los siguientes: Nombres de IA: Mroxito Donpollo123 newplayerXD Luzbelito Sr_Bigotes Anonymus Fabi_gamer xX_ProKiller_Xx Lupita_la_mejor el_pana_misterio Elver_Galarga Pato_Ganso Kevinoo CheemsXD Padoru Soy_pro_amigo Chupito Ado_XD Bicho_sano El_de_la_capa Pepito_el_grande Mensajes Aleatorios de IA: Hola! Donde? q paso busco novia hubieron muertos? donde fue hola xd espera todos somos inteligencias artificiales? MUSTAAAARD alguien juega roba un brainrot? presto server priv de roba un brainrot Skibidi Brrr dejense de bromas, saben quien fue? donde? dnd? XD te acuerdas de mi? amogus sus no era yo es el, lo vi voten por mi, no fui yo hola xd donde estabas voten por el rojo era el amarillo estaba en la sala de las tareas vote por ti xd que paso? saben quien es? que se siente ser el impostor? creo que es el impostor era el de verde, lo vi siganme voten era yo... mentira xd no fui yo no se, estaba en la nave hola :v Me gusta el pan Quiero mi pizza Creo que fue el amarillo No sé quién es, no lo vi ¿Alguien me ayuda con las tareas? ¡Qué aburrido es esto! ¿Cuándo termina? Voté por el negro Él estaba en la sala de cámaras ¿Quién era? Creo que me persiguen El impostor está entre nosotros Era el de azul Mensaje Exclusivo de Impostor (IA): Con una probabilidad del 5%, cuando una IA que es impostor chatea, puede escribir el siguiente mensaje en lugar de uno de los anteriores: "soy nuevo, y nose como pero me meti en la alcantarilla, porque?" Votación y Resultado Las IA votarán aleatoriamente por otros tripulantes. El personaje que más votos reciba será expulsado de la nave. Una vez que los 30 segundos se acaban, el modo de chat se cerrará y se mostrará quién fue expulsado. Un texto en pantalla te informará sobre el resultado: "X (nombre del tripulante) ha sido expulsado de la nave." "X (nombre del impostor) fue un impostor y lo votaron :v" El juego continúa hasta que se cumplan las condiciones de victoria de cualquiera de los bandos.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var AICharacter = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('crewmate', { anchorX: 0.5, anchorY: 0.5 }); self.isImpostor = false; self.isDead = false; self.killCooldown = 0; self.moveTimer = 0; self.targetX = 0; self.targetY = 0; self.username = ''; self.speed = 2; self.update = function () { if (self.isDead) return; if (self.killCooldown > 0) { self.killCooldown--; } self.moveTimer--; if (self.moveTimer <= 0) { self.targetX = Math.random() * 1800 + 100; self.targetY = Math.random() * 1500 + 200; self.moveTimer = Math.random() * 300 + 120; } var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } if (self.isImpostor && self.killCooldown <= 0) { for (var i = 0; i < aiCharacters.length; i++) { var target = aiCharacters[i]; if (!target.isImpostor && !target.isDead && target !== self) { var killDistance = Math.sqrt((target.x - self.x) * (target.x - self.x) + (target.y - self.y) * (target.y - self.y)); if (killDistance < 100) { target.isDead = true; target.visible = false; var deadBody = new DeadBody(); deadBody.x = target.x; deadBody.y = target.y; deadBodies.push(deadBody); game.addChild(deadBody); self.killCooldown = 900; LK.getSound('kill').play(); break; } } } } }; return self; }); var DeadBody = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('body', { anchorX: 0.5, anchorY: 0.5 }); return self; }); var EmergencyButton = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('emergencyButton', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { if (!votingPhase && !gameEnded) { startVotingPhase(); } }; return self; }); var Mission = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('mission', { anchorX: 0.5, anchorY: 0.5 }); self.completed = false; self.missionType = ''; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.isImpostor = false; self.isDead = false; self.killCooldown = 0; self.speed = 3; self.completedMissions = 0; self.update = function () { if (self.killCooldown > 0) { self.killCooldown--; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x111111 }); /**** * Game Code ****/ var gameState = 'waiting'; // waiting, playing, voting, ended var gameTimer = 0; var votingPhase = false; var votingTimer = 0; var gameEnded = false; var player; var aiCharacters = []; var missions = []; var deadBodies = []; var emergencyButton; var chatMessages = []; var votingResults = {}; var totalMissions = 8; var aiNames = ['RedPlayer', 'BlueGamer', 'GreenBean', 'PinkSus', 'OrangeJuice', 'YellowStar', 'BlackCat', 'WhiteCloud', 'PurpleRain', 'BrownBear', 'CyanWave', 'LimeLight', 'MaroonMoon', 'RosePetal']; var missionTypes = ['Limpiar cocina', 'Sumar 2+2', 'Reciclar basura', 'Cargar propulsores', 'Ajustar antena', 'Calibrar motor', 'Inspeccionar muestras', 'Reparar cables']; var chatPhrases = ['Yo vi a {player} cerca del cuerpo', 'Creo que {player} es sospechoso', 'Estaba haciendo misiones en {location}', 'No he visto nada raro', 'Alguien vio algo?', 'Yo vote por {player}', 'No estoy seguro de quien votar', 'Tenemos que encontrar al impostor', '{player} actuaba extraño', 'Yo confío en {player}']; var mapLocations = ['cocina', 'motores', 'electricidad', 'navegación', 'comunicaciones', 'almacén', 'armería', 'escudos', 'oxígeno', 'reactor']; var statusText; var missionText; var timerText; var chatContainer; var voteContainer; function initGame() { game.setBackgroundColor(0x111111); var background = game.attachAsset('mapBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); statusText = new Text2('Esperando...', { size: 60, fill: 0xFFFFFF }); statusText.anchor.set(0.5, 0); LK.gui.top.addChild(statusText); statusText.y = 100; missionText = new Text2('Misiones: 0/' + totalMissions, { size: 50, fill: 0xFFFF00 }); missionText.anchor.set(0, 0); LK.gui.topLeft.addChild(missionText); missionText.x = 150; missionText.y = 50; timerText = new Text2('', { size: 45, fill: 0xFF6666 }); timerText.anchor.set(1, 0); LK.gui.topRight.addChild(timerText); timerText.x = -50; timerText.y = 50; chatContainer = new Container(); LK.gui.left.addChild(chatContainer); chatContainer.x = 50; chatContainer.y = -200; voteContainer = new Container(); LK.gui.center.addChild(voteContainer); emergencyButton = game.addChild(new EmergencyButton()); emergencyButton.x = 1024; emergencyButton.y = 400; player = game.addChild(new Player()); player.x = 1024; player.y = 1366; player.isImpostor = Math.random() < 0.3; for (var i = 0; i < 14; i++) { var ai = game.addChild(new AICharacter()); ai.x = Math.random() * 1800 + 100; ai.y = Math.random() * 1500 + 200; ai.username = aiNames[i]; ai.isImpostor = i < 2; if (ai.isImpostor) { var impostorGraphics = ai.attachAsset('impostor', { anchorX: 0.5, anchorY: 0.5 }); ai.removeChild(ai.children[0]); ai.addChild(impostorGraphics); } aiCharacters.push(ai); } createMissions(); if (player.isImpostor) { statusText.setText('Eres IMPOSTOR - Elimina a los tripulantes'); statusText.tint = 0xff0000; missionText.setText('Cooldown: 15s'); } else { statusText.setText('Eres TRIPULANTE - Completa las misiones'); statusText.tint = 0x00ff00; } gameState = 'playing'; } function createMissions() { for (var i = 0; i < totalMissions; i++) { var mission = game.addChild(new Mission()); mission.x = Math.random() * 1600 + 200; mission.y = Math.random() * 1400 + 300; mission.missionType = missionTypes[i % missionTypes.length]; missions.push(mission); } } function startVotingPhase() { if (votingPhase || gameEnded) return; votingPhase = true; votingTimer = 1800; chatMessages = []; votingResults = {}; LK.getSound('emergency').play(); statusText.setText('REUNIÓN DE EMERGENCIA'); statusText.tint = 0xffff00; timerText.setText('30s'); for (var i = 0; i < aiCharacters.length; i++) { if (!aiCharacters[i].isDead) { votingResults[aiCharacters[i].username] = 0; } } votingResults['Player'] = 0; votingResults['skip'] = 0; showVotingUI(); } function showVotingUI() { voteContainer.removeChildren(); var voteBackground = LK.getAsset('mapBackground', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.6, alpha: 0.9 }); voteContainer.addChild(voteBackground); var voteTitle = new Text2('VOTAR PARA EXPULSAR', { size: 50, fill: 0xFFFFFF }); voteTitle.anchor.set(0.5, 0.5); voteTitle.x = 0; voteTitle.y = -200; voteContainer.addChild(voteTitle); var yPos = -100; var aliveCharacters = []; if (!player.isDead) { aliveCharacters.push({ name: 'Player', isPlayer: true }); } for (var i = 0; i < aiCharacters.length; i++) { if (!aiCharacters[i].isDead) { aliveCharacters.push({ name: aiCharacters[i].username, isPlayer: false }); } } for (var j = 0; j < aliveCharacters.length; j++) { var character = aliveCharacters[j]; var voteButton = new Container(); var buttonBg = LK.getAsset('crewmate', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8, scaleY: 0.8 }); var buttonText = new Text2(character.name, { size: 35, fill: 0xFFFFFF }); buttonText.anchor.set(0.5, 0.5); buttonText.y = 60; voteButton.addChild(buttonBg); voteButton.addChild(buttonText); voteButton.x = (j % 4 - 1.5) * 200; voteButton.y = yPos + Math.floor(j / 4) * 120; voteButton.targetName = character.name; voteButton.down = function (x, y, obj) { if (votingPhase && votingTimer > 900) { castVote(obj.targetName); } }; voteContainer.addChild(voteButton); } var skipButton = new Container(); var skipBg = LK.getAsset('mission', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.2, scaleY: 1.2 }); var skipText = new Text2('SALTAR', { size: 35, fill: 0x000000 }); skipText.anchor.set(0.5, 0.5); skipButton.addChild(skipBg); skipButton.addChild(skipText); skipButton.x = 0; skipButton.y = yPos + Math.floor(aliveCharacters.length / 4 + 1) * 120; skipButton.down = function (x, y, obj) { if (votingPhase && votingTimer > 900) { castVote('skip'); } }; voteContainer.addChild(skipButton); } function castVote(target) { LK.getSound('vote').play(); votingResults[target]++; votingTimer = 900; } function processAIChat() { if (!votingPhase || votingTimer < 900) return; var alivePlayers = []; if (!player.isDead) alivePlayers.push('Player'); for (var i = 0; i < aiCharacters.length; i++) { if (!aiCharacters[i].isDead) { alivePlayers.push(aiCharacters[i].username); } } if (alivePlayers.length === 0) return; var randomAI = aiCharacters[Math.floor(Math.random() * aiCharacters.length)]; if (randomAI.isDead) return; var phrase = chatPhrases[Math.floor(Math.random() * chatPhrases.length)]; var randomPlayer = alivePlayers[Math.floor(Math.random() * alivePlayers.length)]; var randomLocation = mapLocations[Math.floor(Math.random() * mapLocations.length)]; phrase = phrase.replace('{player}', randomPlayer); phrase = phrase.replace('{location}', randomLocation); addChatMessage(randomAI.username + ': ' + phrase); } function addChatMessage(message) { var chatText = new Text2(message, { size: 30, fill: 0xFFFFFF }); chatText.anchor.set(0, 0); chatText.y = chatMessages.length * 35; chatContainer.addChild(chatText); chatMessages.push(chatText); if (chatMessages.length > 10) { chatContainer.removeChild(chatMessages[0]); chatMessages.shift(); for (var i = 0; i < chatMessages.length; i++) { chatMessages[i].y = i * 35; } } } function endVotingPhase() { votingPhase = false; voteContainer.removeChildren(); chatContainer.removeChildren(); chatMessages = []; var maxVotes = 0; var votedOut = ''; var tied = false; for (var name in votingResults) { if (votingResults[name] > maxVotes) { maxVotes = votingResults[name]; votedOut = name; tied = false; } else if (votingResults[name] === maxVotes && maxVotes > 0) { tied = true; } } if (tied || votedOut === 'skip' || maxVotes === 0) { statusText.setText('Nadie fue expulsado'); statusText.tint = 0xffffff; } else { if (votedOut === 'Player') { player.isDead = true; player.visible = false; statusText.setText('Fuiste expulsado!'); statusText.tint = 0xff0000; } else { for (var i = 0; i < aiCharacters.length; i++) { if (aiCharacters[i].username === votedOut) { aiCharacters[i].isDead = true; aiCharacters[i].visible = false; var wasImpostor = aiCharacters[i].isImpostor ? ' (IMPOSTOR)' : ' (TRIPULANTE)'; statusText.setText(votedOut + ' fue expulsado' + wasImpostor); statusText.tint = 0xff6666; break; } } } } LK.setTimeout(function () { if (player.isImpostor) { statusText.setText('Eres IMPOSTOR - Elimina a los tripulantes'); statusText.tint = 0xff0000; } else { statusText.setText('Eres TRIPULANTE - Completa las misiones'); statusText.tint = 0x00ff00; } checkGameEnd(); }, 3000); } function checkGameEnd() { if (gameEnded) return; var aliveCrewmates = 0; var aliveImpostors = 0; if (!player.isDead) { if (player.isImpostor) { aliveImpostors++; } else { aliveCrewmates++; } } for (var i = 0; i < aiCharacters.length; i++) { if (!aiCharacters[i].isDead) { if (aiCharacters[i].isImpostor) { aliveImpostors++; } else { aliveCrewmates++; } } } if (aliveImpostors >= aliveCrewmates && aliveImpostors > 0) { gameEnded = true; statusText.setText('LOS IMPOSTORES GANAN!'); statusText.tint = 0xff0000; if (player.isImpostor && !player.isDead) { LK.showYouWin(); } else { LK.showGameOver(); } return; } if (aliveImpostors === 0) { gameEnded = true; statusText.setText('LOS TRIPULANTES GANAN!'); statusText.tint = 0x00ff00; if (!player.isImpostor && !player.isDead) { LK.showYouWin(); } else { LK.showGameOver(); } return; } if (!player.isImpostor && player.completedMissions >= totalMissions) { gameEnded = true; statusText.setText('TODAS LAS MISIONES COMPLETADAS!'); statusText.tint = 0x00ff00; LK.showYouWin(); return; } } game.move = function (x, y, obj) { if (gameState !== 'playing' || votingPhase || gameEnded || player.isDead) return; var dx = x - player.x; var dy = y - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > player.speed) { player.x += dx / distance * player.speed; player.y += dy / distance * player.speed; } else { player.x = x; player.y = y; } player.x = Math.max(50, Math.min(1998, player.x)); player.y = Math.max(150, Math.min(2682, player.y)); for (var i = 0; i < missions.length; i++) { var mission = missions[i]; if (!mission.completed && player.intersects(mission)) { mission.completed = true; mission.visible = false; player.completedMissions++; LK.getSound('missionComplete').play(); missionText.setText('Misiones: ' + player.completedMissions + '/' + totalMissions); break; } } if (player.isImpostor && player.killCooldown <= 0) { for (var j = 0; j < aiCharacters.length; j++) { var target = aiCharacters[j]; if (!target.isImpostor && !target.isDead) { var killDistance = Math.sqrt((target.x - player.x) * (target.x - player.x) + (target.y - player.y) * (target.y - player.y)); if (killDistance < 120) { target.isDead = true; target.visible = false; var deadBody = new DeadBody(); deadBody.x = target.x; deadBody.y = target.y; deadBodies.push(deadBody); game.addChild(deadBody); player.killCooldown = 900; LK.getSound('kill').play(); break; } } } } }; game.update = function () { if (gameState === 'waiting') { gameTimer++; if (gameTimer >= 180) { initGame(); } return; } if (gameState !== 'playing') return; if (votingPhase) { votingTimer--; timerText.setText(Math.ceil(votingTimer / 60) + 's'); if (votingTimer > 900 && votingTimer % 120 === 0) { processAIChat(); } if (votingTimer === 900) { for (var i = 0; i < aiCharacters.length; i++) { if (!aiCharacters[i].isDead) { var voteOptions = []; if (!player.isDead) voteOptions.push('Player'); for (var j = 0; j < aiCharacters.length; j++) { if (!aiCharacters[j].isDead && i !== j) { voteOptions.push(aiCharacters[j].username); } } voteOptions.push('skip'); var aiVote = voteOptions[Math.floor(Math.random() * voteOptions.length)]; votingResults[aiVote]++; } } } if (votingTimer <= 0) { endVotingPhase(); } } else { if (player.isImpostor && player.killCooldown > 0) { missionText.setText('Cooldown: ' + Math.ceil(player.killCooldown / 60) + 's'); } else if (player.isImpostor) { missionText.setText('Cooldown: Listo'); } checkGameEnd(); } }; initGame();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,560 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/****
+* Classes
+****/
+var AICharacter = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('crewmate', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isImpostor = false;
+ self.isDead = false;
+ self.killCooldown = 0;
+ self.moveTimer = 0;
+ self.targetX = 0;
+ self.targetY = 0;
+ self.username = '';
+ self.speed = 2;
+ self.update = function () {
+ if (self.isDead) return;
+ if (self.killCooldown > 0) {
+ self.killCooldown--;
+ }
+ self.moveTimer--;
+ if (self.moveTimer <= 0) {
+ self.targetX = Math.random() * 1800 + 100;
+ self.targetY = Math.random() * 1500 + 200;
+ self.moveTimer = Math.random() * 300 + 120;
+ }
+ var dx = self.targetX - self.x;
+ var dy = self.targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ if (self.isImpostor && self.killCooldown <= 0) {
+ for (var i = 0; i < aiCharacters.length; i++) {
+ var target = aiCharacters[i];
+ if (!target.isImpostor && !target.isDead && target !== self) {
+ var killDistance = Math.sqrt((target.x - self.x) * (target.x - self.x) + (target.y - self.y) * (target.y - self.y));
+ if (killDistance < 100) {
+ target.isDead = true;
+ target.visible = false;
+ var deadBody = new DeadBody();
+ deadBody.x = target.x;
+ deadBody.y = target.y;
+ deadBodies.push(deadBody);
+ game.addChild(deadBody);
+ self.killCooldown = 900;
+ LK.getSound('kill').play();
+ break;
+ }
+ }
+ }
+ }
+ };
+ return self;
+});
+var DeadBody = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('body', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+var EmergencyButton = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('emergencyButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.down = function (x, y, obj) {
+ if (!votingPhase && !gameEnded) {
+ startVotingPhase();
+ }
+ };
+ return self;
+});
+var Mission = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('mission', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.completed = false;
+ self.missionType = '';
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.isImpostor = false;
+ self.isDead = false;
+ self.killCooldown = 0;
+ self.speed = 3;
+ self.completedMissions = 0;
+ self.update = function () {
+ if (self.killCooldown > 0) {
+ self.killCooldown--;
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x111111
+});
+
+/****
+* Game Code
+****/
+var gameState = 'waiting'; // waiting, playing, voting, ended
+var gameTimer = 0;
+var votingPhase = false;
+var votingTimer = 0;
+var gameEnded = false;
+var player;
+var aiCharacters = [];
+var missions = [];
+var deadBodies = [];
+var emergencyButton;
+var chatMessages = [];
+var votingResults = {};
+var totalMissions = 8;
+var aiNames = ['RedPlayer', 'BlueGamer', 'GreenBean', 'PinkSus', 'OrangeJuice', 'YellowStar', 'BlackCat', 'WhiteCloud', 'PurpleRain', 'BrownBear', 'CyanWave', 'LimeLight', 'MaroonMoon', 'RosePetal'];
+var missionTypes = ['Limpiar cocina', 'Sumar 2+2', 'Reciclar basura', 'Cargar propulsores', 'Ajustar antena', 'Calibrar motor', 'Inspeccionar muestras', 'Reparar cables'];
+var chatPhrases = ['Yo vi a {player} cerca del cuerpo', 'Creo que {player} es sospechoso', 'Estaba haciendo misiones en {location}', 'No he visto nada raro', 'Alguien vio algo?', 'Yo vote por {player}', 'No estoy seguro de quien votar', 'Tenemos que encontrar al impostor', '{player} actuaba extraño', 'Yo confío en {player}'];
+var mapLocations = ['cocina', 'motores', 'electricidad', 'navegación', 'comunicaciones', 'almacén', 'armería', 'escudos', 'oxígeno', 'reactor'];
+var statusText;
+var missionText;
+var timerText;
+var chatContainer;
+var voteContainer;
+function initGame() {
+ game.setBackgroundColor(0x111111);
+ var background = game.attachAsset('mapBackground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+ });
+ statusText = new Text2('Esperando...', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ statusText.anchor.set(0.5, 0);
+ LK.gui.top.addChild(statusText);
+ statusText.y = 100;
+ missionText = new Text2('Misiones: 0/' + totalMissions, {
+ size: 50,
+ fill: 0xFFFF00
+ });
+ missionText.anchor.set(0, 0);
+ LK.gui.topLeft.addChild(missionText);
+ missionText.x = 150;
+ missionText.y = 50;
+ timerText = new Text2('', {
+ size: 45,
+ fill: 0xFF6666
+ });
+ timerText.anchor.set(1, 0);
+ LK.gui.topRight.addChild(timerText);
+ timerText.x = -50;
+ timerText.y = 50;
+ chatContainer = new Container();
+ LK.gui.left.addChild(chatContainer);
+ chatContainer.x = 50;
+ chatContainer.y = -200;
+ voteContainer = new Container();
+ LK.gui.center.addChild(voteContainer);
+ emergencyButton = game.addChild(new EmergencyButton());
+ emergencyButton.x = 1024;
+ emergencyButton.y = 400;
+ player = game.addChild(new Player());
+ player.x = 1024;
+ player.y = 1366;
+ player.isImpostor = Math.random() < 0.3;
+ for (var i = 0; i < 14; i++) {
+ var ai = game.addChild(new AICharacter());
+ ai.x = Math.random() * 1800 + 100;
+ ai.y = Math.random() * 1500 + 200;
+ ai.username = aiNames[i];
+ ai.isImpostor = i < 2;
+ if (ai.isImpostor) {
+ var impostorGraphics = ai.attachAsset('impostor', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ ai.removeChild(ai.children[0]);
+ ai.addChild(impostorGraphics);
+ }
+ aiCharacters.push(ai);
+ }
+ createMissions();
+ if (player.isImpostor) {
+ statusText.setText('Eres IMPOSTOR - Elimina a los tripulantes');
+ statusText.tint = 0xff0000;
+ missionText.setText('Cooldown: 15s');
+ } else {
+ statusText.setText('Eres TRIPULANTE - Completa las misiones');
+ statusText.tint = 0x00ff00;
+ }
+ gameState = 'playing';
+}
+function createMissions() {
+ for (var i = 0; i < totalMissions; i++) {
+ var mission = game.addChild(new Mission());
+ mission.x = Math.random() * 1600 + 200;
+ mission.y = Math.random() * 1400 + 300;
+ mission.missionType = missionTypes[i % missionTypes.length];
+ missions.push(mission);
+ }
+}
+function startVotingPhase() {
+ if (votingPhase || gameEnded) return;
+ votingPhase = true;
+ votingTimer = 1800;
+ chatMessages = [];
+ votingResults = {};
+ LK.getSound('emergency').play();
+ statusText.setText('REUNIÓN DE EMERGENCIA');
+ statusText.tint = 0xffff00;
+ timerText.setText('30s');
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (!aiCharacters[i].isDead) {
+ votingResults[aiCharacters[i].username] = 0;
+ }
+ }
+ votingResults['Player'] = 0;
+ votingResults['skip'] = 0;
+ showVotingUI();
+}
+function showVotingUI() {
+ voteContainer.removeChildren();
+ var voteBackground = LK.getAsset('mapBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8,
+ scaleY: 0.6,
+ alpha: 0.9
+ });
+ voteContainer.addChild(voteBackground);
+ var voteTitle = new Text2('VOTAR PARA EXPULSAR', {
+ size: 50,
+ fill: 0xFFFFFF
+ });
+ voteTitle.anchor.set(0.5, 0.5);
+ voteTitle.x = 0;
+ voteTitle.y = -200;
+ voteContainer.addChild(voteTitle);
+ var yPos = -100;
+ var aliveCharacters = [];
+ if (!player.isDead) {
+ aliveCharacters.push({
+ name: 'Player',
+ isPlayer: true
+ });
+ }
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (!aiCharacters[i].isDead) {
+ aliveCharacters.push({
+ name: aiCharacters[i].username,
+ isPlayer: false
+ });
+ }
+ }
+ for (var j = 0; j < aliveCharacters.length; j++) {
+ var character = aliveCharacters[j];
+ var voteButton = new Container();
+ var buttonBg = LK.getAsset('crewmate', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8,
+ scaleY: 0.8
+ });
+ var buttonText = new Text2(character.name, {
+ size: 35,
+ fill: 0xFFFFFF
+ });
+ buttonText.anchor.set(0.5, 0.5);
+ buttonText.y = 60;
+ voteButton.addChild(buttonBg);
+ voteButton.addChild(buttonText);
+ voteButton.x = (j % 4 - 1.5) * 200;
+ voteButton.y = yPos + Math.floor(j / 4) * 120;
+ voteButton.targetName = character.name;
+ voteButton.down = function (x, y, obj) {
+ if (votingPhase && votingTimer > 900) {
+ castVote(obj.targetName);
+ }
+ };
+ voteContainer.addChild(voteButton);
+ }
+ var skipButton = new Container();
+ var skipBg = LK.getAsset('mission', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.2,
+ scaleY: 1.2
+ });
+ var skipText = new Text2('SALTAR', {
+ size: 35,
+ fill: 0x000000
+ });
+ skipText.anchor.set(0.5, 0.5);
+ skipButton.addChild(skipBg);
+ skipButton.addChild(skipText);
+ skipButton.x = 0;
+ skipButton.y = yPos + Math.floor(aliveCharacters.length / 4 + 1) * 120;
+ skipButton.down = function (x, y, obj) {
+ if (votingPhase && votingTimer > 900) {
+ castVote('skip');
+ }
+ };
+ voteContainer.addChild(skipButton);
+}
+function castVote(target) {
+ LK.getSound('vote').play();
+ votingResults[target]++;
+ votingTimer = 900;
+}
+function processAIChat() {
+ if (!votingPhase || votingTimer < 900) return;
+ var alivePlayers = [];
+ if (!player.isDead) alivePlayers.push('Player');
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (!aiCharacters[i].isDead) {
+ alivePlayers.push(aiCharacters[i].username);
+ }
+ }
+ if (alivePlayers.length === 0) return;
+ var randomAI = aiCharacters[Math.floor(Math.random() * aiCharacters.length)];
+ if (randomAI.isDead) return;
+ var phrase = chatPhrases[Math.floor(Math.random() * chatPhrases.length)];
+ var randomPlayer = alivePlayers[Math.floor(Math.random() * alivePlayers.length)];
+ var randomLocation = mapLocations[Math.floor(Math.random() * mapLocations.length)];
+ phrase = phrase.replace('{player}', randomPlayer);
+ phrase = phrase.replace('{location}', randomLocation);
+ addChatMessage(randomAI.username + ': ' + phrase);
+}
+function addChatMessage(message) {
+ var chatText = new Text2(message, {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ chatText.anchor.set(0, 0);
+ chatText.y = chatMessages.length * 35;
+ chatContainer.addChild(chatText);
+ chatMessages.push(chatText);
+ if (chatMessages.length > 10) {
+ chatContainer.removeChild(chatMessages[0]);
+ chatMessages.shift();
+ for (var i = 0; i < chatMessages.length; i++) {
+ chatMessages[i].y = i * 35;
+ }
+ }
+}
+function endVotingPhase() {
+ votingPhase = false;
+ voteContainer.removeChildren();
+ chatContainer.removeChildren();
+ chatMessages = [];
+ var maxVotes = 0;
+ var votedOut = '';
+ var tied = false;
+ for (var name in votingResults) {
+ if (votingResults[name] > maxVotes) {
+ maxVotes = votingResults[name];
+ votedOut = name;
+ tied = false;
+ } else if (votingResults[name] === maxVotes && maxVotes > 0) {
+ tied = true;
+ }
+ }
+ if (tied || votedOut === 'skip' || maxVotes === 0) {
+ statusText.setText('Nadie fue expulsado');
+ statusText.tint = 0xffffff;
+ } else {
+ if (votedOut === 'Player') {
+ player.isDead = true;
+ player.visible = false;
+ statusText.setText('Fuiste expulsado!');
+ statusText.tint = 0xff0000;
+ } else {
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (aiCharacters[i].username === votedOut) {
+ aiCharacters[i].isDead = true;
+ aiCharacters[i].visible = false;
+ var wasImpostor = aiCharacters[i].isImpostor ? ' (IMPOSTOR)' : ' (TRIPULANTE)';
+ statusText.setText(votedOut + ' fue expulsado' + wasImpostor);
+ statusText.tint = 0xff6666;
+ break;
+ }
+ }
+ }
+ }
+ LK.setTimeout(function () {
+ if (player.isImpostor) {
+ statusText.setText('Eres IMPOSTOR - Elimina a los tripulantes');
+ statusText.tint = 0xff0000;
+ } else {
+ statusText.setText('Eres TRIPULANTE - Completa las misiones');
+ statusText.tint = 0x00ff00;
+ }
+ checkGameEnd();
+ }, 3000);
+}
+function checkGameEnd() {
+ if (gameEnded) return;
+ var aliveCrewmates = 0;
+ var aliveImpostors = 0;
+ if (!player.isDead) {
+ if (player.isImpostor) {
+ aliveImpostors++;
+ } else {
+ aliveCrewmates++;
+ }
+ }
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (!aiCharacters[i].isDead) {
+ if (aiCharacters[i].isImpostor) {
+ aliveImpostors++;
+ } else {
+ aliveCrewmates++;
+ }
+ }
+ }
+ if (aliveImpostors >= aliveCrewmates && aliveImpostors > 0) {
+ gameEnded = true;
+ statusText.setText('LOS IMPOSTORES GANAN!');
+ statusText.tint = 0xff0000;
+ if (player.isImpostor && !player.isDead) {
+ LK.showYouWin();
+ } else {
+ LK.showGameOver();
+ }
+ return;
+ }
+ if (aliveImpostors === 0) {
+ gameEnded = true;
+ statusText.setText('LOS TRIPULANTES GANAN!');
+ statusText.tint = 0x00ff00;
+ if (!player.isImpostor && !player.isDead) {
+ LK.showYouWin();
+ } else {
+ LK.showGameOver();
+ }
+ return;
+ }
+ if (!player.isImpostor && player.completedMissions >= totalMissions) {
+ gameEnded = true;
+ statusText.setText('TODAS LAS MISIONES COMPLETADAS!');
+ statusText.tint = 0x00ff00;
+ LK.showYouWin();
+ return;
+ }
+}
+game.move = function (x, y, obj) {
+ if (gameState !== 'playing' || votingPhase || gameEnded || player.isDead) return;
+ var dx = x - player.x;
+ var dy = y - player.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > player.speed) {
+ player.x += dx / distance * player.speed;
+ player.y += dy / distance * player.speed;
+ } else {
+ player.x = x;
+ player.y = y;
+ }
+ player.x = Math.max(50, Math.min(1998, player.x));
+ player.y = Math.max(150, Math.min(2682, player.y));
+ for (var i = 0; i < missions.length; i++) {
+ var mission = missions[i];
+ if (!mission.completed && player.intersects(mission)) {
+ mission.completed = true;
+ mission.visible = false;
+ player.completedMissions++;
+ LK.getSound('missionComplete').play();
+ missionText.setText('Misiones: ' + player.completedMissions + '/' + totalMissions);
+ break;
+ }
+ }
+ if (player.isImpostor && player.killCooldown <= 0) {
+ for (var j = 0; j < aiCharacters.length; j++) {
+ var target = aiCharacters[j];
+ if (!target.isImpostor && !target.isDead) {
+ var killDistance = Math.sqrt((target.x - player.x) * (target.x - player.x) + (target.y - player.y) * (target.y - player.y));
+ if (killDistance < 120) {
+ target.isDead = true;
+ target.visible = false;
+ var deadBody = new DeadBody();
+ deadBody.x = target.x;
+ deadBody.y = target.y;
+ deadBodies.push(deadBody);
+ game.addChild(deadBody);
+ player.killCooldown = 900;
+ LK.getSound('kill').play();
+ break;
+ }
+ }
+ }
+ }
+};
+game.update = function () {
+ if (gameState === 'waiting') {
+ gameTimer++;
+ if (gameTimer >= 180) {
+ initGame();
+ }
+ return;
+ }
+ if (gameState !== 'playing') return;
+ if (votingPhase) {
+ votingTimer--;
+ timerText.setText(Math.ceil(votingTimer / 60) + 's');
+ if (votingTimer > 900 && votingTimer % 120 === 0) {
+ processAIChat();
+ }
+ if (votingTimer === 900) {
+ for (var i = 0; i < aiCharacters.length; i++) {
+ if (!aiCharacters[i].isDead) {
+ var voteOptions = [];
+ if (!player.isDead) voteOptions.push('Player');
+ for (var j = 0; j < aiCharacters.length; j++) {
+ if (!aiCharacters[j].isDead && i !== j) {
+ voteOptions.push(aiCharacters[j].username);
+ }
+ }
+ voteOptions.push('skip');
+ var aiVote = voteOptions[Math.floor(Math.random() * voteOptions.length)];
+ votingResults[aiVote]++;
+ }
+ }
+ }
+ if (votingTimer <= 0) {
+ endVotingPhase();
+ }
+ } else {
+ if (player.isImpostor && player.killCooldown > 0) {
+ missionText.setText('Cooldown: ' + Math.ceil(player.killCooldown / 60) + 's');
+ } else if (player.isImpostor) {
+ missionText.setText('Cooldown: Listo');
+ }
+ checkGameEnd();
+ }
+};
+initGame();
\ No newline at end of file