Code edit (2 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Pants Dash: Sneak Past Mom!
Initial prompt
my game is like this, there is a young boy who starts the day in the toilet, he probably masturbated but his panties are left in his room and he has to put his pants on without getting caught by his mother who is walking around the house.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Bathroom (start) class var Bathroom = Container.expand(function () { var self = Container.call(this); var bathSprite = self.attachAsset('bathroom', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Bedroom (goal) class var Bedroom = Container.expand(function () { var self = Container.call(this); var bedSprite = self.attachAsset('bedroom', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Boy (player) class var Boy = Container.expand(function () { var self = Container.call(this); var boySprite = self.attachAsset('boy', { anchorX: 0.5, anchorY: 0.5 }); self.isHiding = false; self.hasPants = false; self.update = function () { // No auto-movement, movement is handled by game.move }; return self; }); // Furniture (hiding spot) class var Furniture = Container.expand(function () { var self = Container.call(this); var furnSprite = self.attachAsset('furniture', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // Mom (enemy) class var Mom = Container.expand(function () { var self = Container.call(this); var momSprite = self.attachAsset('mom', { anchorX: 0.5, anchorY: 0.5 }); self.visionCone = null; // For detection logic self.patrolPoints = []; self.currentPatrol = 0; self.speed = 6; self.waitTicks = 0; self.patrolPause = 60; // Pause at each point (in ticks) self.update = function () { if (self.patrolPoints.length < 2) { return; } if (self.waitTicks > 0) { self.waitTicks--; return; } var target = self.patrolPoints[self.currentPatrol]; var dx = target.x - self.x; var dy = target.y - self.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist < self.speed) { self.x = target.x; self.y = target.y; // Pick a new random patrol point (not the current one) if (self.patrolPoints.length > 1) { var nextPatrol = self.currentPatrol; while (nextPatrol === self.currentPatrol) { nextPatrol = Math.floor(Math.random() * self.patrolPoints.length); } self.currentPatrol = nextPatrol; } self.waitTicks = self.patrolPause; } else { self.x += self.speed * dx / dist; self.y += self.speed * dy / dist; } }; return self; }); // Pants (collectible) class var Pants = Container.expand(function () { var self = Container.call(this); var pantsSprite = self.attachAsset('pants', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf5f5dc // light beige for home }); /**** * Game Code ****/ // --- Layout constants --- // Boy (player) - red box // Mom (enemy) - purple ellipse // Pants (collectible) - green box // Hiding spot (furniture) - brown box // Bathroom door (start) - blue box // Bedroom door (goal) - yellow box var GAME_W = 2048, GAME_H = 2732; // Place rooms var bathroom = new Bathroom(); bathroom.x = 300; bathroom.y = GAME_H - 350; game.addChild(bathroom); var bedroom = new Bedroom(); bedroom.x = GAME_W - 300; bedroom.y = 350; game.addChild(bedroom); // Place pants (collectible) somewhere in the house var pants = new Pants(); pants.x = GAME_W / 2; pants.y = GAME_H / 2 + 200; game.addChild(pants); // Place furniture (hiding spots) var furnitureList = []; var furn1 = new Furniture(); furn1.x = 700; furn1.y = 1100; game.addChild(furn1); furnitureList.push(furn1); var furn2 = new Furniture(); furn2.x = 1500; furn2.y = 1700; game.addChild(furn2); furnitureList.push(furn2); var furn3 = new Furniture(); furn3.x = 1200; furn3.y = 600; game.addChild(furn3); furnitureList.push(furn3); // Place boy (player) at bathroom var boy = new Boy(); boy.x = bathroom.x; boy.y = bathroom.y; game.addChild(boy); // Place mom (enemy) and set patrol path var mom = new Mom(); mom.x = GAME_W / 2; mom.y = 700; game.addChild(mom); // Mom patrols between 3 points mom.patrolPoints = [{ x: GAME_W / 2, y: 700 }, { x: 400, y: 1800 }, { x: GAME_W - 400, y: 2000 }]; // --- GUI --- var statusTxt = new Text2('Kilotunu Al!', { size: 90, fill: "#222" }); statusTxt.anchor.set(0.5, 0); LK.gui.top.addChild(statusTxt); // --- Game state --- var dragNode = null; var lastBoyHiding = false; var lastBoyHasPants = false; var lastCaught = false; var gameState = 'playing'; // 'playing', 'caught', 'win' // --- Helper: check if boy is hiding --- function isBoyHiding() { for (var i = 0; i < furnitureList.length; ++i) { if (boy.intersects(furnitureList[i])) { return true; } } return false; } // --- Helper: check if boy is in mom's vision cone --- function isBoySeenByMom() { // Mom's vision: 400px in front, 120deg cone var dx = boy.x - mom.x; var dy = boy.y - mom.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 400) { return false; } var momDir = 0; // Mom's facing direction: toward next patrol point if (mom.patrolPoints.length > 0) { var next = mom.patrolPoints[mom.currentPatrol]; momDir = Math.atan2(next.y - mom.y, next.x - mom.x); } var angleToBoy = Math.atan2(dy, dx); var diff = Math.abs(angleToBoy - momDir); if (diff > Math.PI) { diff = 2 * Math.PI - diff; } return diff < Math.PI / 3; // 60deg either side } // --- Helper: check if boy is at pants --- function isBoyAtPants() { return boy.intersects(pants); } // --- Helper: check if boy is at bedroom (goal) --- function isBoyAtBedroom() { return boy.intersects(bedroom); } // --- Helper: check if boy is at bathroom (start) --- function isBoyAtBathroom() { return boy.intersects(bathroom); } // --- Move handler (drag to move boy) --- function handleMove(x, y, obj) { if (gameState !== 'playing') { return; } if (dragNode) { // Clamp to game area var bx = Math.max(60, Math.min(GAME_W - 60, x)); var by = Math.max(60, Math.min(GAME_H - 60, y)); dragNode.x = bx; dragNode.y = by; } } game.move = handleMove; // --- Down/Up handlers (touch to drag boy) --- game.down = function (x, y, obj) { // Only allow drag if touch is on boy var local = boy.toLocal(game.toGlobal({ x: x, y: y })); if (Math.abs(local.x) <= 60 && Math.abs(local.y) <= 60) { dragNode = boy; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // --- Main update loop --- game.update = function () { if (gameState !== 'playing') { return; } // Update classes mom.update(); boy.update(); // Hiding logic boy.isHiding = isBoyHiding(); // Pants pickup if (!boy.hasPants && isBoyAtPants()) { boy.hasPants = true; pants.visible = false; statusTxt.setText('Hamzaya yakalanmadan odana koş!'); // Animate boy color to green for a moment tween(boy.children[0], { tint: 0x27ae60 }, { duration: 300, onFinish: function onFinish() { tween(boy.children[0], { tint: 0xd83318 }, { duration: 400 }); } }); } // Mom detection var caught = false; if (!boy.isHiding && isBoySeenByMom()) { caught = true; } // Caught logic if (!lastCaught && caught) { gameState = 'caught'; statusTxt.setText('Hamza seni patlatırken yakaladı!'); LK.effects.flashScreen(0xff0000, 1000); tween(boy.children[0], { tint: 0x000000 }, { duration: 600 }); LK.setTimeout(function () { LK.showGameOver(); }, 1200); } lastCaught = caught; // Win logic if (boy.hasPants && isBoyAtBedroom()) { gameState = 'win'; statusTxt.setText('Hala kimse patlattığını farketmedi.'); LK.effects.flashScreen(0x27ae60, 800); tween(boy.children[0], { tint: 0xf1c40f }, { duration: 500 }); LK.setTimeout(function () { LK.showYouWin(); }, 1000); } }; // --- Visual hint: show hiding status --- var hidingTxt = new Text2('', { size: 70, fill: "#555" }); hidingTxt.anchor.set(0.5, 0); LK.gui.bottom.addChild(hidingTxt); var hidingHintTimer = LK.setInterval(function () { if (gameState !== 'playing') { hidingTxt.setText(''); return; } if (boy.isHiding) { hidingTxt.setText('Hiding...'); } else { hidingTxt.setText(''); } }, 100); // --- Visual hint: show pants status --- var pantsTxt = new Text2('', { size: 70, fill: "#222" }); pantsTxt.anchor.set(0.5, 0); LK.gui.bottom.addChild(pantsTxt); var pantsHintTimer = LK.setInterval(function () { if (gameState !== 'playing') { pantsTxt.setText(''); return; } if (!boy.hasPants) { pantsTxt.setText('Find your pants!'); } else { pantsTxt.setText('Get to your bedroom!'); } }, 100); // --- Prevent elements in top left 100x100 --- bathroom.x = Math.max(bathroom.x, 100); bathroom.y = Math.max(bathroom.y, 100);
===================================================================
--- original.js
+++ change.js
@@ -5,332 +5,358 @@
/****
* Classes
****/
+// Bathroom (start) class
+var Bathroom = Container.expand(function () {
+ var self = Container.call(this);
+ var bathSprite = self.attachAsset('bathroom', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+// Bedroom (goal) class
+var Bedroom = Container.expand(function () {
+ var self = Container.call(this);
+ var bedSprite = self.attachAsset('bedroom', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
// Boy (player) class
var Boy = Container.expand(function () {
var self = Container.call(this);
var boySprite = self.attachAsset('boy', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.isHiding = false;
self.hasPants = false;
- self.isMoving = false;
- self.moveTween = null;
self.update = function () {
- // No per-frame logic for now
+ // No auto-movement, movement is handled by game.move
};
- // Flash boy when caught
- self.flash = function () {
- LK.effects.flashObject(self, 0xff0000, 600);
- };
return self;
});
-// Mother (enemy) class
-var Mother = Container.expand(function () {
+// Furniture (hiding spot) class
+var Furniture = Container.expand(function () {
var self = Container.call(this);
- var motherSprite = self.attachAsset('mother', {
+ var furnSprite = self.attachAsset('furniture', {
anchorX: 0.5,
anchorY: 0.5
});
- // Patrol points (set in game code)
+ return self;
+});
+// Mom (enemy) class
+var Mom = Container.expand(function () {
+ var self = Container.call(this);
+ var momSprite = self.attachAsset('mom', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.visionCone = null; // For detection logic
self.patrolPoints = [];
- self.patrolIndex = 0;
- self.patrolDir = 1; // 1: forward, -1: backward
- self.speed = 4; // px per frame
- self.visionLength = 350; // px
- self.visionWidth = 220; // px
- self.visionColor = 0xffe0e0;
- self.visionAlpha = 0.18;
- self.visionAsset = null;
- self.isPaused = false;
- self.pauseTimer = null;
- // Draw vision cone as a translucent rectangle in front of mother
- self.updateVision = function () {
- if (self.visionAsset) {
- self.removeChild(self.visionAsset);
- }
- var vision = LK.getAsset('hallway', {
- width: self.visionLength,
- height: self.visionWidth,
- color: self.visionColor,
- anchorX: 0,
- anchorY: 0.5,
- x: 0,
- y: 0
- });
- vision.alpha = self.visionAlpha;
- vision.x = 0;
- vision.y = 0;
- vision.rotation = 0;
- // Place vision in front of mother
- vision.x = motherSprite.width * 0.5;
- self.visionAsset = vision;
- self.addChild(vision);
- };
+ self.currentPatrol = 0;
+ self.speed = 6;
+ self.waitTicks = 0;
+ self.patrolPause = 60; // Pause at each point (in ticks)
self.update = function () {
- if (self.isPaused) return;
- if (self.patrolPoints.length < 2) return;
- var target = self.patrolPoints[self.patrolIndex];
+ if (self.patrolPoints.length < 2) {
+ return;
+ }
+ if (self.waitTicks > 0) {
+ self.waitTicks--;
+ return;
+ }
+ var target = self.patrolPoints[self.currentPatrol];
var dx = target.x - self.x;
var dy = target.y - self.y;
var dist = Math.sqrt(dx * dx + dy * dy);
if (dist < self.speed) {
- // Arrived at patrol point
self.x = target.x;
self.y = target.y;
- // Pause at ends
- if (self.patrolIndex === 0 || self.patrolIndex === self.patrolPoints.length - 1) {
- self.isPaused = true;
- self.pauseTimer = LK.setTimeout(function () {
- self.isPaused = false;
- }, 700);
+ // Pick a new random patrol point (not the current one)
+ if (self.patrolPoints.length > 1) {
+ var nextPatrol = self.currentPatrol;
+ while (nextPatrol === self.currentPatrol) {
+ nextPatrol = Math.floor(Math.random() * self.patrolPoints.length);
+ }
+ self.currentPatrol = nextPatrol;
}
- // Reverse direction at ends
- if (self.patrolIndex === 0) self.patrolDir = 1;
- if (self.patrolIndex === self.patrolPoints.length - 1) self.patrolDir = -1;
- self.patrolIndex += self.patrolDir;
+ self.waitTicks = self.patrolPause;
} else {
- // Move toward target
- self.x += dx / dist * self.speed;
- self.y += dy / dist * self.speed;
+ self.x += self.speed * dx / dist;
+ self.y += self.speed * dy / dist;
}
- // Update vision cone
- self.updateVision();
};
return self;
});
-// Pants class
+// Pants (collectible) class
var Pants = Container.expand(function () {
var self = Container.call(this);
var pantsSprite = self.attachAsset('pants', {
anchorX: 0.5,
anchorY: 0.5
});
- self.update = function () {};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0xffffff
+ backgroundColor: 0xf5f5dc // light beige for home
});
/****
* Game Code
****/
-// Hallway - gray box
-// Bedroom (goal) - light yellow box
-// Bathroom (start) - light blue box
-// Bedroom door - brown box
-// Pants - blue box
-// Mother - purple ellipse
-// Boy (player) - red box
// --- Layout constants ---
+// Boy (player) - red box
+// Mom (enemy) - purple ellipse
+// Pants (collectible) - green box
+// Hiding spot (furniture) - brown box
+// Bathroom door (start) - blue box
+// Bedroom door (goal) - yellow box
var GAME_W = 2048,
GAME_H = 2732;
-var hallwayY = 1100;
-var hallwayH = 300;
-var hallwayW = 1200;
-var hallwayX = (GAME_W - hallwayW) / 2;
-// Bathroom (start) at left end of hallway
-var bathroomX = hallwayX - 220;
-var bathroomY = hallwayY + hallwayH / 2 - 100;
-// Bedroom (goal) at right end of hallway
-var bedroomX = hallwayX + hallwayW + 20;
-var bedroomY = hallwayY + hallwayH / 2 - 100;
-// Door (goal) at bedroom entrance
-var doorX = hallwayX + hallwayW + 10;
-var doorY = hallwayY + hallwayH / 2 - 10;
-// Pants location (random in hallway, not too close to ends)
-var pantsX = hallwayX + 300 + Math.floor(Math.random() * (hallwayW - 600));
-var pantsY = hallwayY + hallwayH / 2;
-// --- Draw static elements ---
-// Hallway
-var hallway = LK.getAsset('hallway', {
- anchorX: 0,
- anchorY: 0,
- x: hallwayX,
- y: hallwayY,
- width: hallwayW,
- height: hallwayH
-});
-game.addChild(hallway);
-// Bathroom (start)
-var bathroom = LK.getAsset('bathroom', {
- anchorX: 0,
- anchorY: 0,
- x: bathroomX,
- y: bathroomY
-});
+// Place rooms
+var bathroom = new Bathroom();
+bathroom.x = 300;
+bathroom.y = GAME_H - 350;
game.addChild(bathroom);
-// Bedroom (goal)
-var bedroom = LK.getAsset('bedroom', {
- anchorX: 0,
- anchorY: 0,
- x: bedroomX,
- y: bedroomY
-});
+var bedroom = new Bedroom();
+bedroom.x = GAME_W - 300;
+bedroom.y = 350;
game.addChild(bedroom);
-// Door (goal)
-var door = LK.getAsset('door', {
- anchorX: 0,
- anchorY: 0.5,
- x: doorX,
- y: doorY
-});
-game.addChild(door);
-// --- Create game objects ---
-// Boy (player)
-var boy = new Boy();
-boy.x = bathroomX + 100;
-boy.y = bathroomY + 100;
-game.addChild(boy);
-// Pants
+// Place pants (collectible) somewhere in the house
var pants = new Pants();
-pants.x = pantsX;
-pants.y = pantsY;
+pants.x = GAME_W / 2;
+pants.y = GAME_H / 2 + 200;
game.addChild(pants);
-// Mother (enemy)
-var mother = new Mother();
-mother.x = hallwayX + hallwayW / 2;
-mother.y = hallwayY + hallwayH / 2;
-game.addChild(mother);
-// Set patrol points: left and right ends of hallway
-mother.patrolPoints = [{
- x: hallwayX + 120,
- y: hallwayY + hallwayH / 2
+// Place furniture (hiding spots)
+var furnitureList = [];
+var furn1 = new Furniture();
+furn1.x = 700;
+furn1.y = 1100;
+game.addChild(furn1);
+furnitureList.push(furn1);
+var furn2 = new Furniture();
+furn2.x = 1500;
+furn2.y = 1700;
+game.addChild(furn2);
+furnitureList.push(furn2);
+var furn3 = new Furniture();
+furn3.x = 1200;
+furn3.y = 600;
+game.addChild(furn3);
+furnitureList.push(furn3);
+// Place boy (player) at bathroom
+var boy = new Boy();
+boy.x = bathroom.x;
+boy.y = bathroom.y;
+game.addChild(boy);
+// Place mom (enemy) and set patrol path
+var mom = new Mom();
+mom.x = GAME_W / 2;
+mom.y = 700;
+game.addChild(mom);
+// Mom patrols between 3 points
+mom.patrolPoints = [{
+ x: GAME_W / 2,
+ y: 700
}, {
- x: hallwayX + hallwayW - 120,
- y: hallwayY + hallwayH / 2
+ x: 400,
+ y: 1800
+}, {
+ x: GAME_W - 400,
+ y: 2000
}];
-mother.patrolIndex = 0;
-mother.patrolDir = 1;
-mother.updateVision();
-// --- GUI: Instructions and status ---
-var infoTxt = new Text2('Sneak to your bedroom, collect your pants, and avoid your mother!', {
- size: 70,
- fill: 0x222222
-});
-infoTxt.anchor.set(0.5, 0);
-LK.gui.top.addChild(infoTxt);
-var statusTxt = new Text2('Get your pants!', {
+// --- GUI ---
+var statusTxt = new Text2('Kilotunu Al!', {
size: 90,
- fill: 0x2980B9
+ fill: "#222"
});
statusTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(statusTxt);
// --- Game state ---
-var gameState = {
- hasPants: false,
- isMoving: false,
- isCaught: false,
- isAtGoal: false,
- lastBoyPos: {
- x: boy.x,
- y: boy.y
- }
-};
-// --- Touch controls: tap and hold to move, release to stop ---
var dragNode = null;
+var lastBoyHiding = false;
+var lastBoyHasPants = false;
+var lastCaught = false;
+var gameState = 'playing'; // 'playing', 'caught', 'win'
+// --- Helper: check if boy is hiding ---
+function isBoyHiding() {
+ for (var i = 0; i < furnitureList.length; ++i) {
+ if (boy.intersects(furnitureList[i])) {
+ return true;
+ }
+ }
+ return false;
+}
+// --- Helper: check if boy is in mom's vision cone ---
+function isBoySeenByMom() {
+ // Mom's vision: 400px in front, 120deg cone
+ var dx = boy.x - mom.x;
+ var dy = boy.y - mom.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist > 400) {
+ return false;
+ }
+ var momDir = 0;
+ // Mom's facing direction: toward next patrol point
+ if (mom.patrolPoints.length > 0) {
+ var next = mom.patrolPoints[mom.currentPatrol];
+ momDir = Math.atan2(next.y - mom.y, next.x - mom.x);
+ }
+ var angleToBoy = Math.atan2(dy, dx);
+ var diff = Math.abs(angleToBoy - momDir);
+ if (diff > Math.PI) {
+ diff = 2 * Math.PI - diff;
+ }
+ return diff < Math.PI / 3; // 60deg either side
+}
+// --- Helper: check if boy is at pants ---
+function isBoyAtPants() {
+ return boy.intersects(pants);
+}
+// --- Helper: check if boy is at bedroom (goal) ---
+function isBoyAtBedroom() {
+ return boy.intersects(bedroom);
+}
+// --- Helper: check if boy is at bathroom (start) ---
+function isBoyAtBathroom() {
+ return boy.intersects(bathroom);
+}
+// --- Move handler (drag to move boy) ---
function handleMove(x, y, obj) {
- if (dragNode && !gameState.isCaught && !gameState.isAtGoal) {
- // Clamp movement to hallway area
- var bx = x,
- by = y;
- // Only allow movement inside hallway, bathroom, or bedroom
- // Allow vertical movement only within hallwayH
- if (bx < hallwayX - 100) bx = hallwayX - 100;
- if (bx > hallwayX + hallwayW + 100) bx = hallwayX + hallwayW + 100;
- if (by < hallwayY - 60) by = hallwayY - 60;
- if (by > hallwayY + hallwayH + 60) by = hallwayY + hallwayH + 60;
- // Tween to new position for smoothness
- if (boy.moveTween) tween.stop(boy);
- boy.moveTween = tween(boy, {
- x: bx,
- y: by
- }, {
- duration: 120,
- easing: tween.linear
- });
- gameState.lastBoyPos.x = bx;
- gameState.lastBoyPos.y = by;
+ if (gameState !== 'playing') {
+ return;
}
+ if (dragNode) {
+ // Clamp to game area
+ var bx = Math.max(60, Math.min(GAME_W - 60, x));
+ var by = Math.max(60, Math.min(GAME_H - 60, y));
+ dragNode.x = bx;
+ dragNode.y = by;
+ }
}
game.move = handleMove;
+// --- Down/Up handlers (touch to drag boy) ---
game.down = function (x, y, obj) {
- if (gameState.isCaught || gameState.isAtGoal) return;
- dragNode = boy;
- handleMove(x, y, obj);
+ // Only allow drag if touch is on boy
+ var local = boy.toLocal(game.toGlobal({
+ x: x,
+ y: y
+ }));
+ if (Math.abs(local.x) <= 60 && Math.abs(local.y) <= 60) {
+ dragNode = boy;
+ handleMove(x, y, obj);
+ }
};
game.up = function (x, y, obj) {
dragNode = null;
- if (boy.moveTween) tween.stop(boy);
};
-// --- Collision helpers ---
-function intersects(a, b) {
- // Use .intersects if both are containers
- if (a && b && a.intersects && b.intersects) return a.intersects(b);
- return false;
-}
-// --- Main game update loop ---
+// --- Main update loop ---
game.update = function () {
- // Update mother patrol
- mother.update();
- // Check if boy is in mother's vision cone
- if (!gameState.isCaught && !gameState.isAtGoal) {
- // Vision cone: rectangle in front of mother
- var dx = Math.cos(0) * mother.visionLength;
- var dy = Math.sin(0) * mother.visionWidth;
- var visionRect = {
- x: mother.x + 70,
- y: mother.y - mother.visionWidth / 2,
- w: mother.visionLength,
- h: mother.visionWidth
- };
- // If boy is inside visionRect and not in bathroom or bedroom, caught!
- var inVision = boy.x > visionRect.x && boy.x < visionRect.x + visionRect.w && boy.y > visionRect.y && boy.y < visionRect.y + visionRect.h;
- // Not caught if in bathroom or bedroom
- var inBathroom = boy.x > bathroomX && boy.x < bathroomX + 200 && boy.y > bathroomY && boy.y < bathroomY + 200;
- var inBedroom = boy.x > bedroomX && boy.x < bedroomX + 200 && boy.y > bedroomY && boy.y < bedroomY + 200;
- if (inVision && !inBathroom && !inBedroom) {
- // Caught!
- gameState.isCaught = true;
- boy.flash();
- statusTxt.setText('Oh no! Mom caught you!');
- statusTxt.style.fill = "#e74c3c";
- LK.effects.flashScreen(0xff0000, 900);
- LK.setTimeout(function () {
- LK.showGameOver();
- }, 1200);
- return;
- }
+ if (gameState !== 'playing') {
+ return;
}
- // Check if boy collects pants
- if (!gameState.hasPants && intersects(boy, pants)) {
- gameState.hasPants = true;
+ // Update classes
+ mom.update();
+ boy.update();
+ // Hiding logic
+ boy.isHiding = isBoyHiding();
+ // Pants pickup
+ if (!boy.hasPants && isBoyAtPants()) {
boy.hasPants = true;
pants.visible = false;
- statusTxt.setText('Now get to your bedroom!');
- statusTxt.style.fill = "#27ae60";
+ statusTxt.setText('Hamzaya yakalanmadan odana koş!');
+ // Animate boy color to green for a moment
+ tween(boy.children[0], {
+ tint: 0x27ae60
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ tween(boy.children[0], {
+ tint: 0xd83318
+ }, {
+ duration: 400
+ });
+ }
+ });
}
- // Check if boy reaches bedroom with pants
- var atDoor = boy.x > doorX && boy.x < doorX + 180 && boy.y > doorY - 60 && boy.y < doorY + 60;
- if (!gameState.isAtGoal && atDoor && gameState.hasPants) {
- gameState.isAtGoal = true;
- statusTxt.setText('You made it! You got dressed!');
- statusTxt.style.fill = "#f1c40f";
- LK.effects.flashScreen(0x00ff00, 900);
+ // Mom detection
+ var caught = false;
+ if (!boy.isHiding && isBoySeenByMom()) {
+ caught = true;
+ }
+ // Caught logic
+ if (!lastCaught && caught) {
+ gameState = 'caught';
+ statusTxt.setText('Hamza seni patlatırken yakaladı!');
+ LK.effects.flashScreen(0xff0000, 1000);
+ tween(boy.children[0], {
+ tint: 0x000000
+ }, {
+ duration: 600
+ });
LK.setTimeout(function () {
- LK.showYouWin();
+ LK.showGameOver();
}, 1200);
- return;
}
+ lastCaught = caught;
+ // Win logic
+ if (boy.hasPants && isBoyAtBedroom()) {
+ gameState = 'win';
+ statusTxt.setText('Hala kimse patlattığını farketmedi.');
+ LK.effects.flashScreen(0x27ae60, 800);
+ tween(boy.children[0], {
+ tint: 0xf1c40f
+ }, {
+ duration: 500
+ });
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 1000);
+ }
};
-// --- Place GUI elements ---
-infoTxt.setText('Sneak to your bedroom, collect your pants, and avoid your mother!');
-infoTxt.x = LK.gui.width / 2;
-infoTxt.y = 120;
-statusTxt.x = LK.gui.width / 2;
-statusTxt.y = 220;
\ No newline at end of file
+// --- Visual hint: show hiding status ---
+var hidingTxt = new Text2('', {
+ size: 70,
+ fill: "#555"
+});
+hidingTxt.anchor.set(0.5, 0);
+LK.gui.bottom.addChild(hidingTxt);
+var hidingHintTimer = LK.setInterval(function () {
+ if (gameState !== 'playing') {
+ hidingTxt.setText('');
+ return;
+ }
+ if (boy.isHiding) {
+ hidingTxt.setText('Hiding...');
+ } else {
+ hidingTxt.setText('');
+ }
+}, 100);
+// --- Visual hint: show pants status ---
+var pantsTxt = new Text2('', {
+ size: 70,
+ fill: "#222"
+});
+pantsTxt.anchor.set(0.5, 0);
+LK.gui.bottom.addChild(pantsTxt);
+var pantsHintTimer = LK.setInterval(function () {
+ if (gameState !== 'playing') {
+ pantsTxt.setText('');
+ return;
+ }
+ if (!boy.hasPants) {
+ pantsTxt.setText('Find your pants!');
+ } else {
+ pantsTxt.setText('Get to your bedroom!');
+ }
+}, 100);
+// --- Prevent elements in top left 100x100 ---
+bathroom.x = Math.max(bathroom.x, 100);
+bathroom.y = Math.max(bathroom.y, 100);
\ No newline at end of file