User prompt
make only 10 levels then make a win screen
User prompt
get rid of all of the wound hemostat steps and tool
User prompt
fix the wound hemostat bug
Code edit (1 edits merged)
Please save this source code
User prompt
fix every bug in the game
User prompt
make the blood visible when you use the syringe ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
make visible blood that you have to patch ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
when you use the syringe make it were the patient bleeds and you have to use the wound hemostat
User prompt
make the new tool at the bottom of the screen
User prompt
add one more tool that patches blood wound if you stab them to much
User prompt
make the game more realistic
User prompt
fix all bugs in the game
User prompt
make it were Every time you go to the next level don't keep the bandage on the toe until they put it on again
User prompt
make each level only have the steps of what is on the toe
User prompt
make 20 levels 1 being easy and the higher the level the more tools you need to use
User prompt
make 20 levels 1 being easy and the higher the level the more tools you need to use
User prompt
make different levels of patients
User prompt
make all of the injuries spawn in random locations on the toe
User prompt
make me have to drag the pieces into a tray that puts them in a trash can ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
fix every bug in the game but make sure the game is actually playable
User prompt
get rid of the very dark brown pieces
User prompt
make it when all of the debris is gone go to the next step
User prompt
make the cleaning tweezers get rid of all of the brown circles when that's done go to next step
User prompt
add names to the tools
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Debris = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
self.pickedUp = false;
self.originalX = x;
self.originalY = y;
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;
if (!self.pickedUp) {
LK.getSound('click').play();
self.pickedUp = true;
draggedPiece = self;
// Visual feedback for pickup
tween(debrisGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
debrisGraphics.tint = 0x27ae60;
}
};
return self;
});
var InfectedMaterial = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
self.pickedUp = false;
self.originalX = x;
self.originalY = y;
var materialGraphics = self.attachAsset('infectedMaterial', {
anchorX: 0.5,
anchorY: 0.5
});
// Infected material is already very dark brown and larger
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'infected_removal' || selectedTool !== 'infectedScalpel' || self.removed) return;
if (!self.pickedUp) {
LK.getSound('click').play();
self.pickedUp = true;
draggedPiece = self;
// Visual feedback for pickup
tween(materialGraphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
materialGraphics.tint = 0x27ae60;
}
};
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';
// Reset tool selection for next phase
selectedTool = null;
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
if (selectedToolText) {
selectedToolText.alpha = 0;
}
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';
// Reset tool selection for next phase
selectedTool = null;
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
if (selectedToolText) {
selectedToolText.alpha = 0;
}
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;
}
// Update selected tool name display
var toolIndex = toolTypes.indexOf(self.toolType);
if (toolIndex !== -1 && selectedToolText) {
selectedToolText.setText('Selected: ' + toolNames[toolIndex]);
selectedToolText.alpha = 1;
}
updateInstructions();
};
return self;
});
var TrashTray = Container.expand(function (x, y) {
var self = Container.call(this);
var trayGraphics = self.attachAsset('trashTray', {
anchorX: 0.5,
anchorY: 0.5
});
var canGraphics = self.attachAsset('trashCan', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -50
});
self.x = x;
self.y = y;
// Visual feedback when pieces are dragged over
self.highlightTray = function () {
trayGraphics.tint = 0x27ae60;
tween(trayGraphics, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200
});
};
self.unhighlightTray = function () {
trayGraphics.tint = 0xffffff;
tween(trayGraphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
};
self.disposePiece = function (piece) {
// Animate piece falling into trash can
tween(piece, {
x: self.x,
y: self.y - 50,
scaleX: 0.3,
scaleY: 0.3,
alpha: 0
}, {
duration: 500,
onFinish: function onFinish() {
piece.destroy();
}
});
};
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, infected_removal, treatment, bandaging, complete
var currentLevel = 1;
var patientComfort = 100;
var selectedTool = null;
var tutorialStep = 0;
var maxTutorialSteps = 7;
// 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;
// Trash tray system
var trashTray = null;
var draggedPiece = null;
// 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 = 320;
var startX = 200;
// Tool names for UI labels
var toolNames = ['Anesthesia Syringe', 'Surgical Scalpel', 'Cleaning Tweezers', 'Infected Material Scalpel', 'Antiseptic Spray', 'Medical Bandage'];
var toolDescriptions = ['Apply anesthesia', 'Remove ingrown parts', 'Clean debris', 'Remove infected material', 'Treat infections', 'Apply bandage'];
// Selected tool name display
var selectedToolText = new Text2('', {
size: 70,
fill: 0x27AE60
});
selectedToolText.anchor.set(0.5, 0);
selectedToolText.x = 1024;
selectedToolText.y = 2000;
selectedToolText.alpha = 0; // Hidden initially
game.addChild(selectedToolText);
// Create tools with UI elements
var toolTypes = ['syringe', 'scalpel', 'tweezers', 'infectedScalpel', '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;
selectedToolText.alpha = 0; // Initially hidden until tool selected
// 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) {
var text = child.getText();
if (text.indexOf('Anesthesia') === 0 || text.indexOf('Surgical') === 0 || text.indexOf('Cleaning') === 0 || text.indexOf('Infected') === 0 || text.indexOf('Antiseptic') === 0 || text.indexOf('Medical') === 0 || text.indexOf('Apply') === 0 || text.indexOf('Remove') === 0 || text.indexOf('Clean') === 0 || text.indexOf('Treat') === 0) {
child.alpha = 1;
}
}
}
// Create trash tray
if (!trashTray) {
trashTray = new TrashTray(1700, 1800);
game.addChild(trashTray);
}
}
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;
selectedToolText.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 all debris pieces\nfrom the wound area.';
break;
case 4:
content = 'Step 4: INFECTED REMOVAL\nUse the infected material scalpel to remove\nred infected tissue pieces.';
break;
case 5:
content = 'Step 5: TREATMENT\nApply antiseptic to treat any remaining infections\nand prevent further complications.';
break;
case 6:
content = 'Step 6: 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 all debris pieces';
break;
case 'infected_removal':
instruction = 'Use infected material scalpel to remove red infected material';
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';
// Reset tool selection for next phase
selectedTool = null;
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
if (selectedToolText) {
selectedToolText.alpha = 0;
}
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;
}
}
}
// Global drag handlers
game.move = function (x, y, obj) {
if (draggedPiece) {
draggedPiece.x = x;
draggedPiece.y = y;
// Check if over trash tray
if (trashTray && Math.abs(draggedPiece.x - trashTray.x) < 150 && Math.abs(draggedPiece.y - trashTray.y) < 100) {
trashTray.highlightTray();
} else if (trashTray) {
trashTray.unhighlightTray();
}
}
};
game.up = function (x, y, obj) {
if (draggedPiece && trashTray) {
// Check if piece is dropped on trash tray
if (Math.abs(draggedPiece.x - trashTray.x) < 150 && Math.abs(draggedPiece.y - trashTray.y) < 100) {
// Successfully disposed
trashTray.disposePiece(draggedPiece);
trashTray.unhighlightTray();
if (draggedPiece.attachAsset && draggedPiece.attachAsset === 'debris') {
debrisRemoved++;
// Check if all debris removed
if (debrisRemoved >= totalDebris) {
currentPhase = 'infected_removal';
// Reset tool selection for next phase
selectedTool = null;
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
if (selectedToolText) {
selectedToolText.alpha = 0;
}
updateInstructions();
}
LK.setScore(LK.getScore() + 5);
} else {
infectedMaterialRemoved++;
patientComfort = Math.min(100, patientComfort + 5);
updateComfortBar();
// Check if all infected material removed
if (infectedMaterialRemoved >= totalInfectedMaterial) {
currentPhase = 'treatment';
// Reset tool selection for next phase
selectedTool = null;
for (var i = 0; i < tools.length; i++) {
tools[i].selected = false;
tools[i].getChildAt(0).alpha = 0.7;
if (tools[i].toolBackground) {
tools[i].toolBackground.tint = 0x3498db;
tools[i].toolBackground.alpha = 0.6;
}
}
if (selectedToolText) {
selectedToolText.alpha = 0;
}
updateInstructions();
}
LK.setScore(LK.getScore() + 8);
}
scoreText.setText('Score: ' + LK.getScore());
} else {
// Return piece to original position
tween(draggedPiece, {
x: draggedPiece.originalX,
y: draggedPiece.originalY,
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 300
});
draggedPiece.getChildAt(0).tint = 0xffffff;
draggedPiece.pickedUp = false;
}
draggedPiece = null;
}
};
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
@@ -8,47 +8,41 @@
****/
var Debris = Container.expand(function (x, y) {
var self = Container.call(this);
self.removed = false;
+ self.pickedUp = false;
+ self.originalX = x;
+ self.originalY = y;
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 removed
- if (debrisRemoved >= totalDebris) {
- currentPhase = 'infected_removal';
- // Reset tool selection for next phase
- selectedTool = null;
- for (var i = 0; i < tools.length; i++) {
- tools[i].selected = false;
- tools[i].getChildAt(0).alpha = 0.7;
- if (tools[i].toolBackground) {
- tools[i].toolBackground.tint = 0x3498db;
- tools[i].toolBackground.alpha = 0.6;
- }
- }
- if (selectedToolText) {
- selectedToolText.alpha = 0;
- }
- updateInstructions();
+ if (!self.pickedUp) {
+ LK.getSound('click').play();
+ self.pickedUp = true;
+ draggedPiece = self;
+ // Visual feedback for pickup
+ tween(debrisGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200
+ });
+ debrisGraphics.tint = 0x27ae60;
}
- 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;
+ self.pickedUp = false;
+ self.originalX = x;
+ self.originalY = y;
var materialGraphics = self.attachAsset('infectedMaterial', {
anchorX: 0.5,
anchorY: 0.5
});
@@ -56,35 +50,21 @@
self.x = x;
self.y = y;
self.down = function (x, y, obj) {
if (!gameStarted || currentPhase !== 'infected_removal' || selectedTool !== 'infectedScalpel' || 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) {
- currentPhase = 'treatment';
- // Reset tool selection for next phase
- selectedTool = null;
- for (var i = 0; i < tools.length; i++) {
- tools[i].selected = false;
- tools[i].getChildAt(0).alpha = 0.7;
- if (tools[i].toolBackground) {
- tools[i].toolBackground.tint = 0x3498db;
- tools[i].toolBackground.alpha = 0.6;
- }
- }
- if (selectedToolText) {
- selectedToolText.alpha = 0;
- }
- updateInstructions();
+ if (!self.pickedUp) {
+ LK.getSound('click').play();
+ self.pickedUp = true;
+ draggedPiece = self;
+ // Visual feedback for pickup
+ tween(materialGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200
+ });
+ materialGraphics.tint = 0x27ae60;
}
- LK.setScore(LK.getScore() + 8);
- scoreText.setText('Score: ' + LK.getScore());
};
return self;
});
var Infection = Container.expand(function (x, y) {
@@ -212,8 +192,58 @@
updateInstructions();
};
return self;
});
+var TrashTray = Container.expand(function (x, y) {
+ var self = Container.call(this);
+ var trayGraphics = self.attachAsset('trashTray', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var canGraphics = self.attachAsset('trashCan', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 0,
+ y: -50
+ });
+ self.x = x;
+ self.y = y;
+ // Visual feedback when pieces are dragged over
+ self.highlightTray = function () {
+ trayGraphics.tint = 0x27ae60;
+ tween(trayGraphics, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 200
+ });
+ };
+ self.unhighlightTray = function () {
+ trayGraphics.tint = 0xffffff;
+ tween(trayGraphics, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 200
+ });
+ };
+ self.disposePiece = function (piece) {
+ // Animate piece falling into trash can
+ tween(piece, {
+ x: self.x,
+ y: self.y - 50,
+ scaleX: 0.3,
+ scaleY: 0.3,
+ alpha: 0
+ }, {
+ duration: 500,
+ onFinish: function onFinish() {
+ piece.destroy();
+ }
+ });
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -249,8 +279,11 @@
var infectionsHealed = 0;
var totalInfections = 2;
var anesthesiaApplied = false;
var bandageApplied = false;
+// Trash tray system
+var trashTray = null;
+var draggedPiece = null;
// Create patient's toe
var toe = game.addChild(LK.getAsset('toeBackground', {
anchorX: 0.5,
anchorY: 0.5,
@@ -598,8 +631,13 @@
child.alpha = 1;
}
}
}
+ // Create trash tray
+ if (!trashTray) {
+ trashTray = new TrashTray(1700, 1800);
+ game.addChild(trashTray);
+ }
}
function showTutorial() {
hideTitleScreen();
tutorialStep = 0;
@@ -891,8 +929,90 @@
tools[i].toolBackground.alpha = 0.6;
}
}
}
+// Global drag handlers
+game.move = function (x, y, obj) {
+ if (draggedPiece) {
+ draggedPiece.x = x;
+ draggedPiece.y = y;
+ // Check if over trash tray
+ if (trashTray && Math.abs(draggedPiece.x - trashTray.x) < 150 && Math.abs(draggedPiece.y - trashTray.y) < 100) {
+ trashTray.highlightTray();
+ } else if (trashTray) {
+ trashTray.unhighlightTray();
+ }
+ }
+};
+game.up = function (x, y, obj) {
+ if (draggedPiece && trashTray) {
+ // Check if piece is dropped on trash tray
+ if (Math.abs(draggedPiece.x - trashTray.x) < 150 && Math.abs(draggedPiece.y - trashTray.y) < 100) {
+ // Successfully disposed
+ trashTray.disposePiece(draggedPiece);
+ trashTray.unhighlightTray();
+ if (draggedPiece.attachAsset && draggedPiece.attachAsset === 'debris') {
+ debrisRemoved++;
+ // Check if all debris removed
+ if (debrisRemoved >= totalDebris) {
+ currentPhase = 'infected_removal';
+ // Reset tool selection for next phase
+ selectedTool = null;
+ for (var i = 0; i < tools.length; i++) {
+ tools[i].selected = false;
+ tools[i].getChildAt(0).alpha = 0.7;
+ if (tools[i].toolBackground) {
+ tools[i].toolBackground.tint = 0x3498db;
+ tools[i].toolBackground.alpha = 0.6;
+ }
+ }
+ if (selectedToolText) {
+ selectedToolText.alpha = 0;
+ }
+ updateInstructions();
+ }
+ LK.setScore(LK.getScore() + 5);
+ } else {
+ infectedMaterialRemoved++;
+ patientComfort = Math.min(100, patientComfort + 5);
+ updateComfortBar();
+ // Check if all infected material removed
+ if (infectedMaterialRemoved >= totalInfectedMaterial) {
+ currentPhase = 'treatment';
+ // Reset tool selection for next phase
+ selectedTool = null;
+ for (var i = 0; i < tools.length; i++) {
+ tools[i].selected = false;
+ tools[i].getChildAt(0).alpha = 0.7;
+ if (tools[i].toolBackground) {
+ tools[i].toolBackground.tint = 0x3498db;
+ tools[i].toolBackground.alpha = 0.6;
+ }
+ }
+ if (selectedToolText) {
+ selectedToolText.alpha = 0;
+ }
+ updateInstructions();
+ }
+ LK.setScore(LK.getScore() + 8);
+ }
+ scoreText.setText('Score: ' + LK.getScore());
+ } else {
+ // Return piece to original position
+ tween(draggedPiece, {
+ x: draggedPiece.originalX,
+ y: draggedPiece.originalY,
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 300
+ });
+ draggedPiece.getChildAt(0).tint = 0xffffff;
+ draggedPiece.pickedUp = false;
+ }
+ draggedPiece = null;
+ }
+};
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);