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
****/
// 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.hasPants = false;
self.isMoving = false;
self.moveTween = null;
self.update = function () {
// No per-frame logic for now
};
// Flash boy when caught
self.flash = function () {
LK.effects.flashObject(self, 0xff0000, 600);
};
return self;
});
// Mother (enemy) class
var Mother = Container.expand(function () {
var self = Container.call(this);
var motherSprite = self.attachAsset('mother', {
anchorX: 0.5,
anchorY: 0.5
});
// Patrol points (set in game code)
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.update = function () {
if (self.isPaused) return;
if (self.patrolPoints.length < 2) return;
var target = self.patrolPoints[self.patrolIndex];
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);
}
// 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;
} else {
// Move toward target
self.x += dx / dist * self.speed;
self.y += dy / dist * self.speed;
}
// Update vision cone
self.updateVision();
};
return self;
});
// Pants 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
});
/****
* 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 ---
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
});
game.addChild(bathroom);
// Bedroom (goal)
var bedroom = LK.getAsset('bedroom', {
anchorX: 0,
anchorY: 0,
x: bedroomX,
y: bedroomY
});
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
var pants = new Pants();
pants.x = pantsX;
pants.y = pantsY;
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
}, {
x: hallwayX + hallwayW - 120,
y: hallwayY + hallwayH / 2
}];
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!', {
size: 90,
fill: 0x2980B9
});
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;
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;
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (gameState.isCaught || gameState.isAtGoal) return;
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 ---
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;
}
}
// Check if boy collects pants
if (!gameState.hasPants && intersects(boy, pants)) {
gameState.hasPants = true;
boy.hasPants = true;
pants.visible = false;
statusTxt.setText('Now get to your bedroom!');
statusTxt.style.fill = "#27ae60";
}
// 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);
LK.setTimeout(function () {
LK.showYouWin();
}, 1200);
return;
}
};
// --- 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; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,336 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// 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.hasPants = false;
+ self.isMoving = false;
+ self.moveTween = null;
+ self.update = function () {
+ // No per-frame logic for now
+ };
+ // Flash boy when caught
+ self.flash = function () {
+ LK.effects.flashObject(self, 0xff0000, 600);
+ };
+ return self;
+});
+// Mother (enemy) class
+var Mother = Container.expand(function () {
+ var self = Container.call(this);
+ var motherSprite = self.attachAsset('mother', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Patrol points (set in game code)
+ 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.update = function () {
+ if (self.isPaused) return;
+ if (self.patrolPoints.length < 2) return;
+ var target = self.patrolPoints[self.patrolIndex];
+ 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);
+ }
+ // 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;
+ } else {
+ // Move toward target
+ self.x += dx / dist * self.speed;
+ self.y += dy / dist * self.speed;
+ }
+ // Update vision cone
+ self.updateVision();
+ };
+ return self;
+});
+// Pants 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: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xffffff
+});
+
+/****
+* 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 ---
+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
+});
+game.addChild(bathroom);
+// Bedroom (goal)
+var bedroom = LK.getAsset('bedroom', {
+ anchorX: 0,
+ anchorY: 0,
+ x: bedroomX,
+ y: bedroomY
+});
+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
+var pants = new Pants();
+pants.x = pantsX;
+pants.y = pantsY;
+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
+}, {
+ x: hallwayX + hallwayW - 120,
+ y: hallwayY + hallwayH / 2
+}];
+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!', {
+ size: 90,
+ fill: 0x2980B9
+});
+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;
+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;
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ if (gameState.isCaught || gameState.isAtGoal) return;
+ 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 ---
+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;
+ }
+ }
+ // Check if boy collects pants
+ if (!gameState.hasPants && intersects(boy, pants)) {
+ gameState.hasPants = true;
+ boy.hasPants = true;
+ pants.visible = false;
+ statusTxt.setText('Now get to your bedroom!');
+ statusTxt.style.fill = "#27ae60";
+ }
+ // 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);
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 1200);
+ return;
+ }
+};
+// --- 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