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);
/****
* 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);