User prompt
make the infected material a whole different tool and step
User prompt
add names to the tools and add a different tool to get rid of the infected material
User prompt
I still cant remove the infected material
User prompt
Please fix the bug: 'Uncaught TypeError: child.getText is not a function' in or related to this line: 'if (child.getText && child.getText().indexOf('Syringe') === 0 || child.getText().indexOf('Scalpel') === 0 || child.getText().indexOf('Tweezers') === 0 || child.getText().indexOf('Antiseptic') === 0 || child.getText().indexOf('Bandage') === 0 || child.getText().indexOf('Apply') === 0 || child.getText().indexOf('Remove') === 0 || child.getText().indexOf('Clean') === 0 || child.getText().indexOf('Treat') === 0) {' Line Number: 558
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'down')' in or related to this line: 'tutorialNextButton.down = function (x, y, obj) {' Line Number: 411
User prompt
make a tutorial when you start and a title screen
User prompt
make me be able to remove the infected material with the tweezers
User prompt
make ui's for each tool
Code edit (1 edits merged)
Please save this source code
User prompt
Nail Doctor: Ingrown Toenail Surgery
Initial prompt
make a game were you fix someones ingrown toe tail
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Debris = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
var debrisGraphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'cleaning' || selectedTool !== 'tweezers' || self.removed) return;
LK.getSound('click').play();
// Remove debris
self.removed = true;
debrisGraphics.alpha = 0;
debrisRemoved++;
// Check if all debris and infected material removed
if (debrisRemoved >= totalDebris && infectedMaterialRemoved >= totalInfectedMaterial) {
currentPhase = 'treatment';
updateInstructions();
}
LK.setScore(LK.getScore() + 5);
scoreText.setText('Score: ' + LK.getScore());
};
return self;
});
var InfectedMaterial = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
var materialGraphics = self.attachAsset('debris', {
anchorX: 0.5,
anchorY: 0.5
});
// Make infected material look different from regular debris
materialGraphics.tint = 0xff6b6b; // Reddish tint to show infection
materialGraphics.scaleX = 1.2;
materialGraphics.scaleY = 1.2;
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'cleaning' || selectedTool !== 'tweezers' || self.removed) return;
LK.getSound('click').play();
// Remove infected material
self.removed = true;
materialGraphics.alpha = 0;
infectedMaterialRemoved++;
patientComfort = Math.min(100, patientComfort + 5);
updateComfortBar();
// Check if all infected material removed
if (infectedMaterialRemoved >= totalInfectedMaterial && debrisRemoved >= totalDebris) {
currentPhase = 'treatment';
updateInstructions();
}
LK.setScore(LK.getScore() + 8);
scoreText.setText('Score: ' + LK.getScore());
};
return self;
});
var Infection = Container.expand(function (x, y) {
var self = Container.call(this);
self.treated = false;
var infectionGraphics = self.attachAsset('infection', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'treatment' || selectedTool !== 'antiseptic' || self.treated) return;
LK.getSound('healing').play();
// Treat infection
self.treated = true;
infectionGraphics.alpha = 0.2;
infectionGraphics.tint = 0x90ee90;
infectionsHealed++;
patientComfort = Math.min(100, patientComfort + 10);
updateComfortBar();
// Check if all infections treated
if (infectionsHealed >= totalInfections) {
currentPhase = 'bandaging';
updateInstructions();
}
LK.setScore(LK.getScore() + 15);
scoreText.setText('Score: ' + LK.getScore());
};
return self;
});
var IngrownPart = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
var partGraphics = self.attachAsset('ingrownPart', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'surgery' || selectedTool !== 'scalpel' || self.removed) return;
LK.getSound('cut').play();
// Remove ingrown part
self.removed = true;
partGraphics.alpha = 0;
ingrownPartsRemoved++;
patientComfort = Math.max(0, patientComfort - 5);
updateComfortBar();
// Check if all ingrown parts removed
if (ingrownPartsRemoved >= totalIngrownParts) {
currentPhase = 'cleaning';
updateInstructions();
}
LK.setScore(LK.getScore() + 10);
scoreText.setText('Score: ' + LK.getScore());
};
return self;
});
var Tool = Container.expand(function (toolType, x, y) {
var self = Container.call(this);
self.toolType = toolType;
self.selected = false;
self.toolBackground = null; // Will be set when tool is created
var toolGraphics = self.attachAsset(toolType, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase === 'complete') return;
LK.getSound('click').play();
// Deselect all tools
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
// Reset background color
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
// Select this tool
self.selected = true;
toolGraphics.alpha = 1.0;
selectedTool = self.toolType;
// Highlight background
if (self.toolBackground) {
self.toolBackground.tint = 0x27ae60;
self.toolBackground.alpha = 0.9;
}
updateInstructions();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xe8f4f8
});
/****
* Game Code
****/
// Game state variables
var gameState = 'title'; // title, tutorial, playing
var gameStarted = false;
var currentPhase = 'assessment'; // assessment, anesthesia, surgery, cleaning, treatment, bandaging, complete
var currentLevel = 1;
var patientComfort = 100;
var selectedTool = null;
var tutorialStep = 0;
var maxTutorialSteps = 6;
// Game objects
var tools = [];
var ingrownParts = [];
var debrisPieces = [];
var infectedMaterialPieces = [];
var infections = [];
// Counters
var ingrownPartsRemoved = 0;
var totalIngrownParts = 3;
var debrisRemoved = 0;
var totalDebris = 5;
var infectedMaterialRemoved = 0;
var totalInfectedMaterial = 3;
var infectionsHealed = 0;
var totalInfections = 2;
var anesthesiaApplied = false;
var bandageApplied = false;
// Create patient's toe
var toe = game.addChild(LK.getAsset('toeBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200
}));
toe.alpha = 0; // Hidden initially
var toenail = game.addChild(LK.getAsset('toenail', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1150
}));
toenail.alpha = 0; // Hidden initially
// Create title screen elements
var titleText = new Text2('NAIL DOCTOR', {
size: 120,
fill: 0x2C3E50
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 1024;
titleText.y = 800;
game.addChild(titleText);
var subtitleText = new Text2('Ingrown Toenail Surgery Simulator', {
size: 60,
fill: 0x7F8C8D
});
subtitleText.anchor.set(0.5, 0.5);
subtitleText.x = 1024;
subtitleText.y = 900;
game.addChild(subtitleText);
var playButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1200,
scaleX: 1.2,
scaleY: 0.8
}));
playButton.tint = 0x27ae60;
var playButtonText = new Text2('START GAME', {
size: 60,
fill: 0xFFFFFF
});
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = 1024;
playButtonText.y = 1200;
game.addChild(playButtonText);
var tutorialButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
scaleX: 1.2,
scaleY: 0.8
}));
tutorialButton.tint = 0x3498db;
var tutorialButtonText = new Text2('HOW TO PLAY', {
size: 60,
fill: 0xFFFFFF
});
tutorialButtonText.anchor.set(0.5, 0.5);
tutorialButtonText.x = 1024;
tutorialButtonText.y = 1400;
game.addChild(tutorialButtonText);
// Create UI elements
var instructionText = new Text2('Examine the patient and assess the ingrown toenail severity', {
size: 60,
fill: 0x2C3E50
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 100;
instructionText.alpha = 0; // Hidden initially
game.addChild(instructionText);
var scoreText = new Text2('Score: 0', {
size: 50,
fill: 0x27AE60
});
scoreText.anchor.set(0, 0);
scoreText.x = 100;
scoreText.y = 200;
scoreText.alpha = 0; // Hidden initially
game.addChild(scoreText);
var levelText = new Text2('Level: 1', {
size: 50,
fill: 0x2980B9
});
levelText.anchor.set(1, 0);
levelText.x = 1948;
levelText.y = 200;
levelText.alpha = 0; // Hidden initially
game.addChild(levelText);
// Patient comfort bar
var comfortBarBg = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0,
x: 1024,
y: 300,
scaleX: 1.3,
scaleY: 0.3
}));
comfortBarBg.tint = 0x34495e;
comfortBarBg.alpha = 0; // Hidden initially
var comfortBar = game.addChild(LK.getAsset('patientComfortBar', {
anchorX: 0,
anchorY: 0,
x: 824,
y: 300
}));
comfortBar.alpha = 0; // Hidden initially
var comfortText = new Text2('Patient Comfort: 100%', {
size: 40,
fill: 0xFFFFFF
});
comfortText.anchor.set(0.5, 0.5);
comfortText.x = 1024;
comfortText.y = 320;
comfortText.alpha = 0; // Hidden initially
game.addChild(comfortText);
// Create tool selection area
var toolY = 2200;
var toolSpacing = 400;
var startX = 400;
// Tool names for UI labels
var toolNames = ['Syringe', 'Scalpel', 'Tweezers', 'Antiseptic', 'Bandage'];
var toolDescriptions = ['Apply anesthesia', 'Remove ingrown parts', 'Clean debris', 'Treat infections', 'Apply bandage'];
// Create tools with UI elements
var toolTypes = ['syringe', 'scalpel', 'tweezers', 'antiseptic', 'bandage'];
for (var i = 0; i < toolTypes.length; i++) {
// Create tool background button
var toolBg = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: startX + i * toolSpacing,
y: toolY,
scaleX: 0.8,
scaleY: 1.2
}));
toolBg.tint = 0x3498db;
toolBg.alpha = 0; // Hidden initially
// Create the actual tool
var tool = new Tool(toolTypes[i], startX + i * toolSpacing, toolY - 30);
tool.getChildAt(0).alpha = 0; // Hidden initially
tool.toolBackground = toolBg; // Store reference to background
tools.push(tool);
game.addChild(tool);
// Create tool name label
var toolLabel = new Text2(toolNames[i], {
size: 40,
fill: 0xFFFFFF
});
toolLabel.anchor.set(0.5, 0.5);
toolLabel.x = startX + i * toolSpacing;
toolLabel.y = toolY + 50;
toolLabel.alpha = 0; // Hidden initially
game.addChild(toolLabel);
// Create tool description
var toolDesc = new Text2(toolDescriptions[i], {
size: 30,
fill: 0xBDC3C7
});
toolDesc.anchor.set(0.5, 0.5);
toolDesc.x = startX + i * toolSpacing;
toolDesc.y = toolY + 90;
toolDesc.alpha = 0; // Hidden initially
game.addChild(toolDesc);
}
// Title screen button handlers
playButton.down = function (x, y, obj) {
if (gameState === 'title') {
showGameUI();
gameState = 'playing';
}
};
tutorialButton.down = function (x, y, obj) {
if (gameState === 'title') {
showTutorial();
gameState = 'tutorial';
}
};
// Tutorial elements
var tutorialText = new Text2('', {
size: 50,
fill: 0x2C3E50
});
tutorialText.anchor.set(0.5, 0.5);
tutorialText.x = 1024;
tutorialText.y = 400;
tutorialText.alpha = 0; // Hidden initially
game.addChild(tutorialText);
var tutorialNextButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1800,
scaleX: 1.0,
scaleY: 0.6
}));
tutorialNextButton.tint = 0x3498db;
tutorialNextButton.alpha = 0; // Hidden initially
var tutorialNextText = new Text2('NEXT', {
size: 50,
fill: 0xFFFFFF
});
tutorialNextText.anchor.set(0.5, 0.5);
tutorialNextText.x = 1024;
tutorialNextText.y = 1800;
tutorialNextText.alpha = 0; // Hidden initially
game.addChild(tutorialNextText);
var tutorialBackButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 824,
y: 1800,
scaleX: 1.0,
scaleY: 0.6
}));
tutorialBackButton.tint = 0x95a5a6;
tutorialBackButton.alpha = 0; // Hidden initially
var tutorialBackText = new Text2('BACK', {
size: 50,
fill: 0xFFFFFF
});
tutorialBackText.anchor.set(0.5, 0.5);
tutorialBackText.x = 824;
tutorialBackText.y = 1800;
tutorialBackText.alpha = 0; // Hidden initially
game.addChild(tutorialBackText);
var tutorialSkipButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1224,
y: 1800,
scaleX: 1.0,
scaleY: 0.6
}));
tutorialSkipButton.tint = 0xe74c3c;
tutorialSkipButton.alpha = 0; // Hidden initially
var tutorialSkipText = new Text2('SKIP', {
size: 50,
fill: 0xFFFFFF
});
tutorialSkipText.anchor.set(0.5, 0.5);
tutorialSkipText.x = 1224;
tutorialSkipText.y = 1800;
tutorialSkipText.alpha = 0; // Hidden initially
game.addChild(tutorialSkipText);
// Tutorial button handlers
tutorialNextButton.down = function (x, y, obj) {
if (gameState === 'tutorial') {
tutorialStep++;
if (tutorialStep >= maxTutorialSteps) {
hideTutorial();
showGameUI();
gameState = 'playing';
} else {
updateTutorialContent();
}
}
};
tutorialBackButton.down = function (x, y, obj) {
if (gameState === 'tutorial' && tutorialStep > 0) {
tutorialStep--;
updateTutorialContent();
}
};
tutorialSkipButton.down = function (x, y, obj) {
if (gameState === 'tutorial') {
hideTutorial();
showGameUI();
gameState = 'playing';
}
};
// Start button
var startButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600,
scaleX: 1.5,
scaleY: 0.8
}));
startButton.tint = 0x27ae60;
startButton.alpha = 0; // Hidden initially
var startText = new Text2('Start Treatment', {
size: 60,
fill: 0xFFFFFF
});
startText.anchor.set(0.5, 0.5);
startText.x = 1024;
startText.y = 1600;
startText.alpha = 0; // Hidden initially
game.addChild(startText);
startButton.down = function (x, y, obj) {
if (!gameStarted && gameState === 'playing') {
startGame();
}
};
function hideTitleScreen() {
titleText.alpha = 0;
subtitleText.alpha = 0;
playButton.alpha = 0;
playButtonText.alpha = 0;
tutorialButton.alpha = 0;
tutorialButtonText.alpha = 0;
}
function showGameUI() {
hideTitleScreen();
hideTutorial();
// Show game UI elements
instructionText.alpha = 1;
scoreText.alpha = 1;
levelText.alpha = 1;
comfortBarBg.alpha = 1;
comfortBar.alpha = 1;
comfortText.alpha = 1;
toe.alpha = 1;
toenail.alpha = 1;
startButton.alpha = 1;
startText.alpha = 1;
// Show tools
for (var i = 0; i < tools.length; i++) {
tools[i].getChildAt(0).alpha = 0.7;
tools[i].toolBackground.alpha = 0.6;
}
// Show tool labels and descriptions
for (var i = 0; i < game.children.length; i++) {
var child = game.children[i];
if (child.getText && child.getText().indexOf('Syringe') === 0 || child.getText().indexOf('Scalpel') === 0 || child.getText().indexOf('Tweezers') === 0 || child.getText().indexOf('Antiseptic') === 0 || child.getText().indexOf('Bandage') === 0 || child.getText().indexOf('Apply') === 0 || child.getText().indexOf('Remove') === 0 || child.getText().indexOf('Clean') === 0 || child.getText().indexOf('Treat') === 0) {
child.alpha = 1;
}
}
}
function showTutorial() {
hideTitleScreen();
tutorialStep = 0;
tutorialText.alpha = 1;
tutorialNextButton.alpha = 1;
tutorialNextText.alpha = 1;
tutorialBackButton.alpha = 1;
tutorialBackText.alpha = 1;
tutorialSkipButton.alpha = 1;
tutorialSkipText.alpha = 1;
updateTutorialContent();
}
function hideTutorial() {
tutorialText.alpha = 0;
tutorialNextButton.alpha = 0;
tutorialNextText.alpha = 0;
tutorialBackButton.alpha = 0;
tutorialBackText.alpha = 0;
tutorialSkipButton.alpha = 0;
tutorialSkipText.alpha = 0;
}
function updateTutorialContent() {
var content = '';
switch (tutorialStep) {
case 0:
content = 'Welcome to Nail Doctor!\nYou are a podiatrist treating ingrown toenails.';
break;
case 1:
content = 'Step 1: ANESTHESIA\nSelect the syringe and click the toe to numb the area\nbefore starting surgery.';
break;
case 2:
content = 'Step 2: SURGERY\nUse the scalpel to carefully remove the ingrown\nnail parts that are causing pain.';
break;
case 3:
content = 'Step 3: CLEANING\nUse tweezers to remove debris and infected material\n(the red pieces are infected!).';
break;
case 4:
content = 'Step 4: TREATMENT\nApply antiseptic to treat any remaining infections\nand prevent further complications.';
break;
case 5:
content = 'Step 5: BANDAGING\nFinally, apply a bandage to protect the treated area\nand complete the procedure. Good luck!';
break;
}
tutorialText.setText(content);
// Update button states
if (tutorialStep === 0) {
tutorialBackButton.alpha = 0.3;
tutorialBackText.alpha = 0.3;
} else {
tutorialBackButton.alpha = 1;
tutorialBackText.alpha = 1;
}
if (tutorialStep >= maxTutorialSteps - 1) {
tutorialNextText.setText('START');
} else {
tutorialNextText.setText('NEXT');
}
}
function startGame() {
gameStarted = true;
startButton.alpha = 0;
startText.alpha = 0;
currentPhase = 'anesthesia';
// Create ingrown nail parts
var ingrownPositions = [{
x: 900,
y: 1100
}, {
x: 1100,
y: 1080
}, {
x: 1050,
y: 1200
}];
for (var i = 0; i < ingrownPositions.length; i++) {
var ingrownPart = new IngrownPart(ingrownPositions[i].x, ingrownPositions[i].y);
ingrownParts.push(ingrownPart);
game.addChild(ingrownPart);
}
// Create debris pieces
var debrisPositions = [{
x: 950,
y: 1120
}, {
x: 1080,
y: 1130
}, {
x: 1020,
y: 1180
}, {
x: 990,
y: 1160
}, {
x: 1060,
y: 1170
}];
for (var i = 0; i < debrisPositions.length; i++) {
var debris = new Debris(debrisPositions[i].x, debrisPositions[i].y);
debrisPieces.push(debris);
game.addChild(debris);
}
// Create infected material pieces
var infectedMaterialPositions = [{
x: 930,
y: 1140
}, {
x: 1090,
y: 1150
}, {
x: 1010,
y: 1190
}];
for (var i = 0; i < infectedMaterialPositions.length; i++) {
var infectedMaterial = new InfectedMaterial(infectedMaterialPositions[i].x, infectedMaterialPositions[i].y);
infectedMaterialPieces.push(infectedMaterial);
game.addChild(infectedMaterial);
}
// Create infections
var infectionPositions = [{
x: 970,
y: 1140
}, {
x: 1070,
y: 1160
}];
for (var i = 0; i < infectionPositions.length; i++) {
var infection = new Infection(infectionPositions[i].x, infectionPositions[i].y);
infections.push(infection);
game.addChild(infection);
}
updateInstructions();
}
function updateInstructions() {
var instruction = '';
switch (currentPhase) {
case 'anesthesia':
instruction = 'Select the syringe and apply anesthesia to numb the area';
break;
case 'surgery':
instruction = 'Use the scalpel to carefully remove ingrown nail parts';
break;
case 'cleaning':
instruction = 'Use tweezers to remove debris and infected material (red pieces)';
break;
case 'treatment':
instruction = 'Apply antiseptic to treat infections';
break;
case 'bandaging':
instruction = 'Apply bandage to complete the treatment';
break;
case 'complete':
instruction = 'Treatment complete! Patient is healed.';
break;
}
instructionText.setText(instruction);
}
function updateComfortBar() {
var comfortWidth = patientComfort / 100 * 400;
comfortBar.width = comfortWidth;
if (patientComfort > 70) {
comfortBar.tint = 0x27ae60;
} else if (patientComfort > 40) {
comfortBar.tint = 0xf39c12;
} else {
comfortBar.tint = 0xe74c3c;
}
comfortText.setText('Patient Comfort: ' + Math.round(patientComfort) + '%');
}
// Handle toe click for anesthesia and bandaging
toe.down = function (x, y, obj) {
if (!gameStarted) return;
if (currentPhase === 'anesthesia' && selectedTool === 'syringe' && !anesthesiaApplied) {
LK.getSound('healing').play();
anesthesiaApplied = true;
currentPhase = 'surgery';
patientComfort = Math.min(100, patientComfort + 20);
updateComfortBar();
updateInstructions();
LK.setScore(LK.getScore() + 20);
scoreText.setText('Score: ' + LK.getScore());
// Visual feedback for anesthesia
LK.effects.flashObject(toe, 0x87ceeb, 1000);
}
if (currentPhase === 'bandaging' && selectedTool === 'bandage' && !bandageApplied) {
LK.getSound('healing').play();
bandageApplied = true;
currentPhase = 'complete';
// Create bandage visual
var bandageVisual = game.addChild(LK.getAsset('bandage', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1150
}));
bandageVisual.alpha = 0.8;
updateInstructions();
completeLevel();
}
};
function completeLevel() {
// Calculate final score based on patient comfort and efficiency
var comfortBonus = Math.round(patientComfort * 2);
LK.setScore(LK.getScore() + comfortBonus);
scoreText.setText('Score: ' + LK.getScore());
// Flash screen green for success
LK.effects.flashScreen(0x27ae60, 1500);
// Check win condition
if (LK.getScore() >= 300) {
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
} else {
// Show level complete and prepare next level
LK.setTimeout(function () {
nextLevel();
}, 3000);
}
}
function nextLevel() {
currentLevel++;
levelText.setText('Level: ' + currentLevel);
// Reset game state
resetGame();
// Increase difficulty
totalIngrownParts = Math.min(5, 3 + currentLevel - 1);
totalDebris = Math.min(8, 5 + currentLevel - 1);
totalInfectedMaterial = Math.min(6, 3 + currentLevel - 1);
totalInfections = Math.min(4, 2 + currentLevel - 1);
startGame();
}
function resetGame() {
// Reset counters
ingrownPartsRemoved = 0;
debrisRemoved = 0;
infectedMaterialRemoved = 0;
infectionsHealed = 0;
anesthesiaApplied = false;
bandageApplied = false;
// Reset patient comfort
patientComfort = 100;
updateComfortBar();
// Reset phase
currentPhase = 'anesthesia';
selectedTool = null;
// Clear old game objects
for (var i = 0; i < ingrownParts.length; i++) {
ingrownParts[i].destroy();
}
for (var i = 0; i < debrisPieces.length; i++) {
debrisPieces[i].destroy();
}
for (var i = 0; i < infectedMaterialPieces.length; i++) {
infectedMaterialPieces[i].destroy();
}
for (var i = 0; i < infections.length; i++) {
infections[i].destroy();
}
ingrownParts = [];
debrisPieces = [];
infectedMaterialPieces = [];
infections = [];
// Reset tool selection
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
// Reset tool background colors
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
}
game.update = function () {
// Gradually decrease patient comfort over time if surgery is taking too long
if (gameStarted && currentPhase !== 'complete' && LK.ticks % 300 === 0) {
patientComfort = Math.max(0, patientComfort - 1);
updateComfortBar();
// Game over if patient comfort drops too low
if (patientComfort <= 0) {
LK.effects.flashScreen(0xe74c3c, 1000);
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -376,34 +376,8 @@
showTutorial();
gameState = 'tutorial';
}
};
-// Tutorial button handlers
-tutorialNextButton.down = function (x, y, obj) {
- if (gameState === 'tutorial') {
- tutorialStep++;
- if (tutorialStep >= maxTutorialSteps) {
- hideTutorial();
- showGameUI();
- gameState = 'playing';
- } else {
- updateTutorialContent();
- }
- }
-};
-tutorialBackButton.down = function (x, y, obj) {
- if (gameState === 'tutorial' && tutorialStep > 0) {
- tutorialStep--;
- updateTutorialContent();
- }
-};
-tutorialSkipButton.down = function (x, y, obj) {
- if (gameState === 'tutorial') {
- hideTutorial();
- showGameUI();
- gameState = 'playing';
- }
-};
// Tutorial elements
var tutorialText = new Text2('', {
size: 50,
fill: 0x2C3E50
@@ -469,8 +443,34 @@
tutorialSkipText.x = 1224;
tutorialSkipText.y = 1800;
tutorialSkipText.alpha = 0; // Hidden initially
game.addChild(tutorialSkipText);
+// Tutorial button handlers
+tutorialNextButton.down = function (x, y, obj) {
+ if (gameState === 'tutorial') {
+ tutorialStep++;
+ if (tutorialStep >= maxTutorialSteps) {
+ hideTutorial();
+ showGameUI();
+ gameState = 'playing';
+ } else {
+ updateTutorialContent();
+ }
+ }
+};
+tutorialBackButton.down = function (x, y, obj) {
+ if (gameState === 'tutorial' && tutorialStep > 0) {
+ tutorialStep--;
+ updateTutorialContent();
+ }
+};
+tutorialSkipButton.down = function (x, y, obj) {
+ if (gameState === 'tutorial') {
+ hideTutorial();
+ showGameUI();
+ gameState = 'playing';
+ }
+};
// Start button
var startButton = game.addChild(LK.getAsset('toolButton', {
anchorX: 0.5,
anchorY: 0.5,