User prompt
Que el piso de plaga sea en el nivel 4
User prompt
Crea el nivel cuatro que haigan un monton de pelotas de futbol estorbando y hay un laberinto unico para llegar ala puerta
User prompt
Que la placa este en el nivel 4
User prompt
crea un piso de placa
User prompt
Crea nivel 4 suelo de baloncesto minijuego de encholar la pelota de baloncesto antes que el profesor llegue en 20 segundos
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'if (student.update) {' Line Number: 414
User prompt
Boton de empezar
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'var isIntersecting = profesor.intersects(student);' Line Number: 554
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'if (profesor.update) {' Line Number: 524
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'if (student.update) {' Line Number: 442
User prompt
Pantalla de inicio
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'intersects')' in or related to this line: 'var isIntersecting = profesor.intersects(student);' Line Number: 545
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'if (profesor.update) {' Line Number: 515
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'if (student.update) {' Line Number: 433
User prompt
Pantalla de inicio boton de inicio
User prompt
Que en el 3 nivel este el otro piso
User prompt
Que haigan suelos diferentes
User prompt
Crea 3 nivel que sea en un parque con otro pico un parque royoso
User prompt
Que cada puerta tenga una pregunta diferente
User prompt
En el segundo nivel que la pregunta sea 7×22
User prompt
Quita un poco de obstaculos
User prompt
Que el ostaculo no deje pasar al jugador
User prompt
Que el pasillo no se pueda traspasar
User prompt
Que sea un pasillo angosto
User prompt
Que el segundo nivel sea un pasillo con puertas abiertas que son obstaculos y que al fondo este la puerya y atras este el profesor más lento persiguido al jugador
/**** * Classes ****/ // ProfesorMonster class: AI-driven monster that chases the student var ProfesorMonster = Container.expand(function () { var self = Container.call(this); // Attach profesor asset var profesorSprite = self.attachAsset('profesor', { anchorX: 0.5, anchorY: 0.5 }); // Track last position for event logic self.lastX = self.x; self.lastY = self.y; self.lastWasIntersecting = false; // Update method: chase the student self.update = function () { // Store last position self.lastX = self.x; self.lastY = self.y; // Immobilize profesor if student is touching the door (popup active) if (typeof showMathQuestion !== "undefined" && showMathQuestion || typeof student !== "undefined" && typeof student.lastWasIntersectingDoor !== "undefined" && student.lastWasIntersectingDoor) { // Profesor stays still, do not move return; } // Use global student variable if (typeof student === "undefined" || !student) return; // Simple AI: move towards the student var dx = student.x - self.x; var dy = student.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); var speed = 6; // profesor speed, now much slower than student if (dist > speed) { self.x += dx / dist * speed; self.y += dy / dist * speed; } else { self.x = student.x; self.y = student.y; } }; return self; }); // Student class: controllable player character var Student = Container.expand(function () { var self = Container.call(this); // Attach student asset var studentSprite = self.attachAsset('student', { anchorX: 0.5, anchorY: 0.5 }); // Initial target position is current position self.targetX = 300; self.targetY = 2732 / 2; // Track last position for event logic self.lastX = self.x; self.lastY = self.y; // Update method: move towards target position self.update = function () { // Store last position self.lastX = self.x; self.lastY = self.y; // Move towards targetX, targetY var dx = self.targetX - self.x; var dy = self.targetY - self.y; var dist = Math.sqrt(dx * dx + dy * dy); var speed = 18; // pixels per frame if (dist > speed) { self.x += dx / dist * speed; self.y += dy / dist * speed; } else { self.x = self.targetX; self.y = self.targetY; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Level system var currentLevel = 1; var maxLevel = 2; // Helper to clear all children except joystick and overlays function clearGameObjects() { // Remove all children except overlays and joystick for (var i = game.children.length - 1; i >= 0; i--) { var child = game.children[i]; // Don't remove overlays or joystick (which are in LK.gui) game.removeChild(child); } // Clear level 2 obstacles array if present if (game.level2Obstacles) { game.level2Obstacles.length = 0; } } // Helper to setup a level function setupLevel(level) { clearGameObjects(); // Main floor (covers the whole map) var floor = LK.getAsset('floor', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); game.addChild(floor); // Top and bottom walls (main corridor) var wallTop = LK.getAsset('wall', { x: 0, y: 0, anchorX: 0, anchorY: 0 }); var wallBottom = LK.getAsset('wall', { x: 0, y: 2732 - 40, anchorX: 0, anchorY: 0 }); game.addChild(wallTop); game.addChild(wallBottom); // Left and right walls (vertical boundaries) var wallLeft = LK.getAsset('wall', { width: 40, height: 2732, x: 0, y: 0, anchorX: 0, anchorY: 0 }); var wallRight = LK.getAsset('wall', { width: 40, height: 2732, x: 2048 - 40, y: 0, anchorX: 0, anchorY: 0 }); game.addChild(wallLeft); game.addChild(wallRight); // Add door (exit) at far right, near the sports field if (level === 1) { door = LK.getAsset('door', { x: 2048 - 200, y: 2200, anchorX: 0, anchorY: 0 }); } else if (level === 2) { // Level 2: Hallway with open doors as obstacles, exit at the end, profesor behind // Place the exit door at the far right end of the hallway door = LK.getAsset('door', { x: 2048 - 200, y: 2732 / 2 - 200, anchorX: 0, anchorY: 0 }); // Add open doors as obstacles along the hallway // We'll use furniture assets as open doors (obstacles) var numObstacles = 6; var spacing = (2048 - 400) / (numObstacles + 1); for (var i = 1; i <= numObstacles; i++) { var obsX = i * spacing + 100; var obsY = i % 2 === 0 ? 2732 / 2 - 350 : 2732 / 2 + 200; var obstacle = LK.getAsset('furniture', { width: 180, height: 60, anchorX: 0.5, anchorY: 0.5, x: obsX, y: obsY }); game.addChild(obstacle); // Store obstacles for collision in global array if (!game.level2Obstacles) game.level2Obstacles = []; game.level2Obstacles.push(obstacle); } } game.addChild(door); // Add student (player) and center camera on them student = new Student(); if (level === 1) { student.x = 300; student.y = 2732 / 2; } else if (level === 2) { // Start at the far left of the hallway student.x = 200; student.y = 2732 / 2; } game.addChild(student); // Add profesor (monster) as an AI-driven monster profesor = new ProfesorMonster(); if (level === 1) { profesor.x = 1600; profesor.y = 2732 / 2; } else if (level === 2) { // Profesor starts behind the student, at the left edge profesor.x = 60; profesor.y = 2732 / 2; // Make profesor slower for this level profesor.level2Slow = true; } game.addChild(profesor); // Camera offset for 3rd person (centered on student) cameraOffsetX = 1024; // half width cameraOffsetY = 1366; // half height // Reset popup/question state showMathQuestion = false; mathQuestionPopup = null; } var door, student, profesor, cameraOffsetX, cameraOffsetY; setupLevel(currentLevel); // Camera follow logic game.update = function () { // Update student if (student.update) student.update(); // Level 2: Check collision with obstacles (open doors) if (currentLevel === 2 && game.level2Obstacles && student) { for (var i = 0; i < game.level2Obstacles.length; i++) { var obs = game.level2Obstacles[i]; if (student.intersects(obs)) { // Push student back to previous position (simple block) student.x = student.lastX; student.y = student.lastY; // Optionally, add a small shake or effect } } } // Update profesor monster AI if (profesor.update) { // Slow profesor in level 2 if (currentLevel === 2 && profesor.level2Slow) { // Temporarily override update to move slower var oldSpeed = 6; profesor.update = function () { this.lastX = this.x; this.lastY = this.y; if (typeof showMathQuestion !== "undefined" && showMathQuestion || typeof student !== "undefined" && typeof student.lastWasIntersectingDoor !== "undefined" && student.lastWasIntersectingDoor) { return; } if (typeof student === "undefined" || !student) return; var dx = student.x - this.x; var dy = student.y - this.y; var dist = Math.sqrt(dx * dx + dy * dy); var speed = 3; // slower speed for level 2 if (dist > speed) { this.x += dx / dist * speed; this.y += dy / dist * speed; } else { this.x = student.x; this.y = student.y; } }; } profesor.update(); } // Check for kill: profesor touches student (collision) var isIntersecting = profesor.intersects(student); if (!profesor.lastWasIntersecting && isIntersecting) { // Profesor kills student: show game over LK.effects.flashScreen(0xff0000, 1000); // Reset to level 1 after game over currentLevel = 1; LK.setTimeout(function () { setupLevel(currentLevel); }, 1200); LK.showGameOver(); } profesor.lastWasIntersecting = isIntersecting; // Check if student touches the door (minimum contact triggers question) if ((typeof showMathQuestion === "undefined" || !showMathQuestion) && door && student && !student.lastWasIntersectingDoor && student.intersects(door)) { showMathQuestion = true; student.lastWasIntersectingDoor = true; // Show the math question in-game as a fullscreen overlay with large, high-contrast text and options if (typeof mathQuestionPopup === "undefined" || !mathQuestionPopup) { mathQuestionPopup = new Container(); // Fullscreen transparent background (no purple, just to block input) var bg = LK.getAsset('furniture', { width: 2048, height: 2732, color: 0x000000, anchorX: 0, anchorY: 0 }); bg.alpha = 0.01; // almost invisible, just to block input mathQuestionPopup.addChild(bg); // Question text - very large, high-contrast, centered var questionText = new Text2("¿Cuánto es 7 × 2?", { size: 180, fill: 0xFFF700 // bright yellow for contrast }); questionText.anchor.set(0.5, 0); questionText.x = 2048 / 2; questionText.y = 320; mathQuestionPopup.addChild(questionText); // Option 1: 13 var option1 = new Text2("1) 13", { size: 140, fill: 0xFFFFFF }); option1.anchor.set(0.5, 0); option1.x = 2048 / 2; option1.y = 800; mathQuestionPopup.addChild(option1); // Option 2: 14 (correct) var option2 = new Text2("2) 14", { size: 140, fill: 0xFFFFFF // visually matches the incorrect answers }); option2.anchor.set(0.5, 0); option2.x = 2048 / 2; option2.y = 1100; mathQuestionPopup.addChild(option2); // Option 3: 2 var option3 = new Text2("3) 2", { size: 140, fill: 0xFFFFFF }); option3.anchor.set(0.5, 0); option3.x = 2048 / 2; option3.y = 1400; mathQuestionPopup.addChild(option3); // Add interaction for options option1.interactive = true; option1.buttonMode = true; option1.down = function () { LK.effects.flashScreen(0xff0000, 800); // Reset to level 1 after game over currentLevel = 1; LK.setTimeout(function () { setupLevel(currentLevel); }, 1000); LK.showGameOver(); if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup); mathQuestionPopup = null; showMathQuestion = false; }; option2.interactive = true; option2.buttonMode = true; option2.down = function () { LK.effects.flashScreen(0x00ff00, 800); // Open the door: remove it from the game scene if (door && door.parent) { door.parent.removeChild(door); door = null; } if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup); mathQuestionPopup = null; showMathQuestion = false; // Advance to next level or win if (typeof currentLevel !== "undefined" && typeof maxLevel !== "undefined") { if (currentLevel < maxLevel) { currentLevel += 1; setupLevel(currentLevel); } else { LK.showYouWin(); } } }; option3.interactive = true; option3.buttonMode = true; option3.down = function () { LK.effects.flashScreen(0xff0000, 800); // Reset to level 1 after game over currentLevel = 1; LK.setTimeout(function () { setupLevel(currentLevel); }, 1000); LK.showGameOver(); if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup); mathQuestionPopup = null; showMathQuestion = false; }; // Fullscreen, no pivot, top-left at (0,0) mathQuestionPopup.x = 0; mathQuestionPopup.y = 0; game.addChild(mathQuestionPopup); } } // Track lastX for student for event logic student.lastX = student.x; student.lastY = student.y; // Track last intersection with door for event logic if (door && student) { if (typeof student.lastWasIntersectingDoor === "undefined") student.lastWasIntersectingDoor = false; var nowIntersectingDoor = student.intersects(door); student.lastWasIntersectingDoor = nowIntersectingDoor; } // Camera follows student from behind (3rd person, offset behind student direction) var dx = student.targetX - student.x; var dy = student.targetY - student.y; var dist = Math.sqrt(dx * dx + dy * dy); var camBehindDist = 350; // Distance behind the student var camX, camY; if (dist > 10) { // Camera is offset behind the student, in the opposite direction of movement camX = student.x - dx / dist * camBehindDist; camY = student.y - dy / dist * camBehindDist; } else { // If not moving, camera stays slightly above/behind camX = student.x - camBehindDist; camY = student.y; } // Clamp camera to map bounds camX = Math.max(0, Math.min(camX, 2048 - 2048)); camY = Math.max(0, Math.min(camY, 2732 - 2732)); game.x = -camX; game.y = -camY; }; // On-screen joystick controls for student movement // Joystick visual base var joystickBase = LK.getAsset('furniture', { width: 260, height: 260, color: 0x222222, anchorX: 0.5, anchorY: 0.5, x: 260, y: 2732 - 260 }); joystickBase.alpha = 0.25; LK.gui.left.addChild(joystickBase); // Joystick thumb var joystickThumb = LK.getAsset('furniture', { width: 120, height: 120, color: 0xffffff, anchorX: 0.5, anchorY: 0.5, x: 260, y: 2732 - 260 }); joystickThumb.alpha = 0.7; LK.gui.left.addChild(joystickThumb); var joystickActive = false; var joystickStartX = 0; var joystickStartY = 0; var joystickRadius = 110; // Helper to convert GUI to game coordinates function guiToGameCoords(guiX, guiY) { // For this game, joystick is always at bottom left, so just return as is return { x: guiX, y: guiY }; } // Joystick down joystickBase.interactive = true; joystickBase.buttonMode = true; joystickBase.down = function (x, y, obj) { joystickActive = true; joystickStartX = joystickBase.x; joystickStartY = joystickBase.y; joystickThumb.x = x; joystickThumb.y = y; }; // Joystick move joystickBase.move = function (x, y, obj) { if (!joystickActive) return; var dx = x - joystickStartX; var dy = y - joystickStartY; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > joystickRadius) { dx = dx / dist * joystickRadius; dy = dy / dist * joystickRadius; } joystickThumb.x = joystickStartX + dx; joystickThumb.y = joystickStartY + dy; // Move student target relative to joystick direction var moveStrength = dist > 20 ? 1 : 0; // Deadzone if (moveStrength) { // Map joystick to game area var moveX = student.x + dx * 3; var moveY = student.y + dy * 3; student.targetX = Math.max(60, Math.min(2048 - 60, moveX)); student.targetY = Math.max(60, Math.min(2732 - 60, moveY)); } }; // Joystick up joystickBase.up = function (x, y, obj) { joystickActive = false; joystickThumb.x = joystickBase.x; joystickThumb.y = joystickBase.y; }; // Also allow drag-to-move for desktop or direct touch game.down = function (x, y, obj) { if (!joystickActive) { student.targetX = x; student.targetY = y; } }; game.move = function (x, y, obj) { if (!joystickActive) { student.targetX = x; student.targetY = y; } }; game.up = function (x, y, obj) { // No-op for now };
/****
* Classes
****/
// ProfesorMonster class: AI-driven monster that chases the student
var ProfesorMonster = Container.expand(function () {
var self = Container.call(this);
// Attach profesor asset
var profesorSprite = self.attachAsset('profesor', {
anchorX: 0.5,
anchorY: 0.5
});
// Track last position for event logic
self.lastX = self.x;
self.lastY = self.y;
self.lastWasIntersecting = false;
// Update method: chase the student
self.update = function () {
// Store last position
self.lastX = self.x;
self.lastY = self.y;
// Immobilize profesor if student is touching the door (popup active)
if (typeof showMathQuestion !== "undefined" && showMathQuestion || typeof student !== "undefined" && typeof student.lastWasIntersectingDoor !== "undefined" && student.lastWasIntersectingDoor) {
// Profesor stays still, do not move
return;
}
// Use global student variable
if (typeof student === "undefined" || !student) return;
// Simple AI: move towards the student
var dx = student.x - self.x;
var dy = student.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var speed = 6; // profesor speed, now much slower than student
if (dist > speed) {
self.x += dx / dist * speed;
self.y += dy / dist * speed;
} else {
self.x = student.x;
self.y = student.y;
}
};
return self;
});
// Student class: controllable player character
var Student = Container.expand(function () {
var self = Container.call(this);
// Attach student asset
var studentSprite = self.attachAsset('student', {
anchorX: 0.5,
anchorY: 0.5
});
// Initial target position is current position
self.targetX = 300;
self.targetY = 2732 / 2;
// Track last position for event logic
self.lastX = self.x;
self.lastY = self.y;
// Update method: move towards target position
self.update = function () {
// Store last position
self.lastX = self.x;
self.lastY = self.y;
// Move towards targetX, targetY
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var speed = 18; // pixels per frame
if (dist > speed) {
self.x += dx / dist * speed;
self.y += dy / dist * speed;
} else {
self.x = self.targetX;
self.y = self.targetY;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Level system
var currentLevel = 1;
var maxLevel = 2;
// Helper to clear all children except joystick and overlays
function clearGameObjects() {
// Remove all children except overlays and joystick
for (var i = game.children.length - 1; i >= 0; i--) {
var child = game.children[i];
// Don't remove overlays or joystick (which are in LK.gui)
game.removeChild(child);
}
// Clear level 2 obstacles array if present
if (game.level2Obstacles) {
game.level2Obstacles.length = 0;
}
}
// Helper to setup a level
function setupLevel(level) {
clearGameObjects();
// Main floor (covers the whole map)
var floor = LK.getAsset('floor', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
game.addChild(floor);
// Top and bottom walls (main corridor)
var wallTop = LK.getAsset('wall', {
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
});
var wallBottom = LK.getAsset('wall', {
x: 0,
y: 2732 - 40,
anchorX: 0,
anchorY: 0
});
game.addChild(wallTop);
game.addChild(wallBottom);
// Left and right walls (vertical boundaries)
var wallLeft = LK.getAsset('wall', {
width: 40,
height: 2732,
x: 0,
y: 0,
anchorX: 0,
anchorY: 0
});
var wallRight = LK.getAsset('wall', {
width: 40,
height: 2732,
x: 2048 - 40,
y: 0,
anchorX: 0,
anchorY: 0
});
game.addChild(wallLeft);
game.addChild(wallRight);
// Add door (exit) at far right, near the sports field
if (level === 1) {
door = LK.getAsset('door', {
x: 2048 - 200,
y: 2200,
anchorX: 0,
anchorY: 0
});
} else if (level === 2) {
// Level 2: Hallway with open doors as obstacles, exit at the end, profesor behind
// Place the exit door at the far right end of the hallway
door = LK.getAsset('door', {
x: 2048 - 200,
y: 2732 / 2 - 200,
anchorX: 0,
anchorY: 0
});
// Add open doors as obstacles along the hallway
// We'll use furniture assets as open doors (obstacles)
var numObstacles = 6;
var spacing = (2048 - 400) / (numObstacles + 1);
for (var i = 1; i <= numObstacles; i++) {
var obsX = i * spacing + 100;
var obsY = i % 2 === 0 ? 2732 / 2 - 350 : 2732 / 2 + 200;
var obstacle = LK.getAsset('furniture', {
width: 180,
height: 60,
anchorX: 0.5,
anchorY: 0.5,
x: obsX,
y: obsY
});
game.addChild(obstacle);
// Store obstacles for collision in global array
if (!game.level2Obstacles) game.level2Obstacles = [];
game.level2Obstacles.push(obstacle);
}
}
game.addChild(door);
// Add student (player) and center camera on them
student = new Student();
if (level === 1) {
student.x = 300;
student.y = 2732 / 2;
} else if (level === 2) {
// Start at the far left of the hallway
student.x = 200;
student.y = 2732 / 2;
}
game.addChild(student);
// Add profesor (monster) as an AI-driven monster
profesor = new ProfesorMonster();
if (level === 1) {
profesor.x = 1600;
profesor.y = 2732 / 2;
} else if (level === 2) {
// Profesor starts behind the student, at the left edge
profesor.x = 60;
profesor.y = 2732 / 2;
// Make profesor slower for this level
profesor.level2Slow = true;
}
game.addChild(profesor);
// Camera offset for 3rd person (centered on student)
cameraOffsetX = 1024; // half width
cameraOffsetY = 1366; // half height
// Reset popup/question state
showMathQuestion = false;
mathQuestionPopup = null;
}
var door, student, profesor, cameraOffsetX, cameraOffsetY;
setupLevel(currentLevel);
// Camera follow logic
game.update = function () {
// Update student
if (student.update) student.update();
// Level 2: Check collision with obstacles (open doors)
if (currentLevel === 2 && game.level2Obstacles && student) {
for (var i = 0; i < game.level2Obstacles.length; i++) {
var obs = game.level2Obstacles[i];
if (student.intersects(obs)) {
// Push student back to previous position (simple block)
student.x = student.lastX;
student.y = student.lastY;
// Optionally, add a small shake or effect
}
}
}
// Update profesor monster AI
if (profesor.update) {
// Slow profesor in level 2
if (currentLevel === 2 && profesor.level2Slow) {
// Temporarily override update to move slower
var oldSpeed = 6;
profesor.update = function () {
this.lastX = this.x;
this.lastY = this.y;
if (typeof showMathQuestion !== "undefined" && showMathQuestion || typeof student !== "undefined" && typeof student.lastWasIntersectingDoor !== "undefined" && student.lastWasIntersectingDoor) {
return;
}
if (typeof student === "undefined" || !student) return;
var dx = student.x - this.x;
var dy = student.y - this.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var speed = 3; // slower speed for level 2
if (dist > speed) {
this.x += dx / dist * speed;
this.y += dy / dist * speed;
} else {
this.x = student.x;
this.y = student.y;
}
};
}
profesor.update();
}
// Check for kill: profesor touches student (collision)
var isIntersecting = profesor.intersects(student);
if (!profesor.lastWasIntersecting && isIntersecting) {
// Profesor kills student: show game over
LK.effects.flashScreen(0xff0000, 1000);
// Reset to level 1 after game over
currentLevel = 1;
LK.setTimeout(function () {
setupLevel(currentLevel);
}, 1200);
LK.showGameOver();
}
profesor.lastWasIntersecting = isIntersecting;
// Check if student touches the door (minimum contact triggers question)
if ((typeof showMathQuestion === "undefined" || !showMathQuestion) && door && student && !student.lastWasIntersectingDoor && student.intersects(door)) {
showMathQuestion = true;
student.lastWasIntersectingDoor = true;
// Show the math question in-game as a fullscreen overlay with large, high-contrast text and options
if (typeof mathQuestionPopup === "undefined" || !mathQuestionPopup) {
mathQuestionPopup = new Container();
// Fullscreen transparent background (no purple, just to block input)
var bg = LK.getAsset('furniture', {
width: 2048,
height: 2732,
color: 0x000000,
anchorX: 0,
anchorY: 0
});
bg.alpha = 0.01; // almost invisible, just to block input
mathQuestionPopup.addChild(bg);
// Question text - very large, high-contrast, centered
var questionText = new Text2("¿Cuánto es 7 × 2?", {
size: 180,
fill: 0xFFF700 // bright yellow for contrast
});
questionText.anchor.set(0.5, 0);
questionText.x = 2048 / 2;
questionText.y = 320;
mathQuestionPopup.addChild(questionText);
// Option 1: 13
var option1 = new Text2("1) 13", {
size: 140,
fill: 0xFFFFFF
});
option1.anchor.set(0.5, 0);
option1.x = 2048 / 2;
option1.y = 800;
mathQuestionPopup.addChild(option1);
// Option 2: 14 (correct)
var option2 = new Text2("2) 14", {
size: 140,
fill: 0xFFFFFF // visually matches the incorrect answers
});
option2.anchor.set(0.5, 0);
option2.x = 2048 / 2;
option2.y = 1100;
mathQuestionPopup.addChild(option2);
// Option 3: 2
var option3 = new Text2("3) 2", {
size: 140,
fill: 0xFFFFFF
});
option3.anchor.set(0.5, 0);
option3.x = 2048 / 2;
option3.y = 1400;
mathQuestionPopup.addChild(option3);
// Add interaction for options
option1.interactive = true;
option1.buttonMode = true;
option1.down = function () {
LK.effects.flashScreen(0xff0000, 800);
// Reset to level 1 after game over
currentLevel = 1;
LK.setTimeout(function () {
setupLevel(currentLevel);
}, 1000);
LK.showGameOver();
if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup);
mathQuestionPopup = null;
showMathQuestion = false;
};
option2.interactive = true;
option2.buttonMode = true;
option2.down = function () {
LK.effects.flashScreen(0x00ff00, 800);
// Open the door: remove it from the game scene
if (door && door.parent) {
door.parent.removeChild(door);
door = null;
}
if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup);
mathQuestionPopup = null;
showMathQuestion = false;
// Advance to next level or win
if (typeof currentLevel !== "undefined" && typeof maxLevel !== "undefined") {
if (currentLevel < maxLevel) {
currentLevel += 1;
setupLevel(currentLevel);
} else {
LK.showYouWin();
}
}
};
option3.interactive = true;
option3.buttonMode = true;
option3.down = function () {
LK.effects.flashScreen(0xff0000, 800);
// Reset to level 1 after game over
currentLevel = 1;
LK.setTimeout(function () {
setupLevel(currentLevel);
}, 1000);
LK.showGameOver();
if (mathQuestionPopup && mathQuestionPopup.parent) mathQuestionPopup.parent.removeChild(mathQuestionPopup);
mathQuestionPopup = null;
showMathQuestion = false;
};
// Fullscreen, no pivot, top-left at (0,0)
mathQuestionPopup.x = 0;
mathQuestionPopup.y = 0;
game.addChild(mathQuestionPopup);
}
}
// Track lastX for student for event logic
student.lastX = student.x;
student.lastY = student.y;
// Track last intersection with door for event logic
if (door && student) {
if (typeof student.lastWasIntersectingDoor === "undefined") student.lastWasIntersectingDoor = false;
var nowIntersectingDoor = student.intersects(door);
student.lastWasIntersectingDoor = nowIntersectingDoor;
}
// Camera follows student from behind (3rd person, offset behind student direction)
var dx = student.targetX - student.x;
var dy = student.targetY - student.y;
var dist = Math.sqrt(dx * dx + dy * dy);
var camBehindDist = 350; // Distance behind the student
var camX, camY;
if (dist > 10) {
// Camera is offset behind the student, in the opposite direction of movement
camX = student.x - dx / dist * camBehindDist;
camY = student.y - dy / dist * camBehindDist;
} else {
// If not moving, camera stays slightly above/behind
camX = student.x - camBehindDist;
camY = student.y;
}
// Clamp camera to map bounds
camX = Math.max(0, Math.min(camX, 2048 - 2048));
camY = Math.max(0, Math.min(camY, 2732 - 2732));
game.x = -camX;
game.y = -camY;
};
// On-screen joystick controls for student movement
// Joystick visual base
var joystickBase = LK.getAsset('furniture', {
width: 260,
height: 260,
color: 0x222222,
anchorX: 0.5,
anchorY: 0.5,
x: 260,
y: 2732 - 260
});
joystickBase.alpha = 0.25;
LK.gui.left.addChild(joystickBase);
// Joystick thumb
var joystickThumb = LK.getAsset('furniture', {
width: 120,
height: 120,
color: 0xffffff,
anchorX: 0.5,
anchorY: 0.5,
x: 260,
y: 2732 - 260
});
joystickThumb.alpha = 0.7;
LK.gui.left.addChild(joystickThumb);
var joystickActive = false;
var joystickStartX = 0;
var joystickStartY = 0;
var joystickRadius = 110;
// Helper to convert GUI to game coordinates
function guiToGameCoords(guiX, guiY) {
// For this game, joystick is always at bottom left, so just return as is
return {
x: guiX,
y: guiY
};
}
// Joystick down
joystickBase.interactive = true;
joystickBase.buttonMode = true;
joystickBase.down = function (x, y, obj) {
joystickActive = true;
joystickStartX = joystickBase.x;
joystickStartY = joystickBase.y;
joystickThumb.x = x;
joystickThumb.y = y;
};
// Joystick move
joystickBase.move = function (x, y, obj) {
if (!joystickActive) return;
var dx = x - joystickStartX;
var dy = y - joystickStartY;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist > joystickRadius) {
dx = dx / dist * joystickRadius;
dy = dy / dist * joystickRadius;
}
joystickThumb.x = joystickStartX + dx;
joystickThumb.y = joystickStartY + dy;
// Move student target relative to joystick direction
var moveStrength = dist > 20 ? 1 : 0; // Deadzone
if (moveStrength) {
// Map joystick to game area
var moveX = student.x + dx * 3;
var moveY = student.y + dy * 3;
student.targetX = Math.max(60, Math.min(2048 - 60, moveX));
student.targetY = Math.max(60, Math.min(2732 - 60, moveY));
}
};
// Joystick up
joystickBase.up = function (x, y, obj) {
joystickActive = false;
joystickThumb.x = joystickBase.x;
joystickThumb.y = joystickBase.y;
};
// Also allow drag-to-move for desktop or direct touch
game.down = function (x, y, obj) {
if (!joystickActive) {
student.targetX = x;
student.targetY = y;
}
};
game.move = function (x, y, obj) {
if (!joystickActive) {
student.targetX = x;
student.targetY = y;
}
};
game.up = function (x, y, obj) {
// No-op for now
};
Modern App Store icon, high definition, square with rounded corners, for a game titled "San Luis: El Monstruo del Colegio" and with the description "Juego de escondite en el colegio San Luis de Yarumal, donde debes evitar a un profesor monstruoso y escapar del colegio.". No text on icon!
Puerta. In-Game asset. 2d. High contrast. No shadows
Piso liso. In-Game asset. 2d. High contrast. No shadows
Un solo pupitre. In-Game asset. 2d. High contrast. No shadows
Niño pequeño con uniforme blanco y sudadera azul. In-Game asset. 2d. High contrast. No shadows
Suelo de concreto. In-Game asset. 2d. High contrast. No shadows