User prompt
Let's add another visual asset to the surprisedWoman page at the end of the game. Let's name it "What" and I will edit it from the assets later. Let's make this What 400x400 in size and let it be under surprisedWoman. Let's also create an asset for the background of the game. Let it be a light gray color to start with and I will edit it from the assets later.
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'removeChild')' in or related to this line: 'self.mouth.parent.removeChild(self.mouth);' Line Number: 62
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'removeChild')' in or related to this line: 'self.mouth.parent.removeChild(self.mouth);' Line Number: 62
Code edit (1 edits merged)
Please save this source code
User prompt
When "surprisedWoman" at the screen dont use the mouth. Only the surprisedWoman photo and 3 seconds later another photo named: "youwinWoman" 3 seconds and finish the game
Code edit (3 edits merged)
Please save this source code
User prompt
move mouth 5mm right. make background light grey. Show hearts down of the answer buttons.
User prompt
Move mouth 10mm left and 1cm up
User prompt
Move mouth 1cm up. And where is the hearts for lives. They arent shown.
User prompt
Mouth too much right. Move a little left and up
User prompt
Move mouth 1cm up and a little right.
User prompt
Why button backgrounds are woman? Change it to a black button asset. Dont change the questions and answers. Move mouth 1cm up and a little left.
Code edit (1 edits merged)
Please save this source code
User prompt
Who Am I? - A Visual Novel of Identity
Initial prompt
The game genre will be Visual Novel. There will be a red square on the screen. This will represent a woman. Let's name this asset "Happy Woman". I will assign the asset later. For the woman's mouth, there will be one line and one circle. The line represents a closed mouth, the circle represents an open mouth. Below the woman, there will be a question: "Do you know why you are here?" Immediately below it, there will be 3 choices: "Yes", "Of course, baby", "Who am I?" The correct answer is "Who am I?". The choices will be shuffled randomly each time. The other answers will remove one of the 3 hearts at the top right of the screen. When a wrong answer is selected, the red square will be replaced by a purple square for 3 seconds. The purple square asset is "Angry Woman". On the third wrong answer, the game will be lost. If the correct answer is selected, a new question will appear on the screen. The second question is "Do you think I don’t know who you are?": The answers are: "The Thunderstorm", "A curious caterpillar", "A helpless servant". The correct answer is "A curious caterpillar". The third question is: "Are you curious about me?", Answers: "No, about my fate", "No, about who I am", "Yes". The correct answer is "No, about who I am". This will be the last question for now. If the correct answer is selected, instead of the "Happy Woman", a yellow square will appear, which is "Surprised Woman". When the woman is speaking, that is, when the question first appears on the screen, the line and circle will alternate to simulate a talking mouth.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Woman character class var Woman = Container.expand(function () { var self = Container.call(this); // State: 'happy', 'angry', 'surprised' self.state = 'happy'; // Attach face (default: happy) self.face = self.attachAsset('happyWoman', { anchorX: 0.5, anchorY: 0.5 }); // Attach mouth self.mouth = self.attachAsset('mouth', { anchorX: 0.5, anchorY: 0.5, x: -15, // move 3.75mm left (35px left from center, 5mm right from previous) // centered horizontally, but offset slightly left y: 40 // move up 1cm (40px from woman's center) }); // Animate mouth open/close self.mouthTalking = false; self.mouthTween = null; self.setState = function (state) { if (self.state === state) { return; } self.state = state; // Remove old face self.face.destroy(); // Add new face var faceId = 'happyWoman'; if (state === 'angry') { faceId = 'angryWoman'; } if (state === 'surprised') { faceId = 'surprisedWoman'; } self.face = self.attachAsset(faceId, { anchorX: 0.5, anchorY: 0.5 }); // Keep mouth on top if (self.mouth && typeof self.mouth.parent !== "undefined" && self.mouth.parent !== null) { if (typeof self.mouth.parent.removeChild === "function") { self.mouth.parent.removeChild(self.mouth); } } self.addChild(self.mouth); }; self.startTalking = function () { if (self.mouthTalking) { return; } self.mouthTalking = true; animateMouth(); }; self.stopTalking = function () { self.mouthTalking = false; if (self.mouthTween) { tween.stop(self.mouth); self.mouthTween = null; } // Reset mouth to closed self.mouth.scaleY = 1; }; function animateMouth() { if (!self.mouthTalking) { return; } // Open self.mouthTween = tween(self.mouth, { scaleY: 2 }, { duration: 120, easing: tween.easeIn, onFinish: function onFinish() { // Close self.mouthTween = tween(self.mouth, { scaleY: 1 }, { duration: 120, easing: tween.easeOut, onFinish: function onFinish() { // Repeat if still talking animateMouth(); } }); } }); } return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf0f0f0 }); /**** * Game Code ****/ // New asset: 'background' (light gray, editable later) // New asset: 'What' (placeholder, 400x400, editable later) // Heart (for lives) // Mouth (Ellipse for talking) // Surprised Woman (Yellow Square) // Angry Woman (Purple Square) // Happy Woman (Red Square) // Questions and answers var questions = [{ text: "Do you know why you are here?", answers: [{ text: "Yes", correct: false }, { text: "Of course, baby!", correct: false }, { text: "Who am I?", correct: true }] }, { text: "Do you think I don’t know who you are?", answers: [{ text: "The Thunderstorm?", correct: false }, { text: "A helpless servant?", correct: false }, { text: "A curious caterpillar?", correct: true }] }, { text: "Are you curious about me?", answers: [{ text: "No, about who I am", correct: true }, { text: "No, about my fate", correct: false }, { text: "Yes", correct: false }] }, { text: "Are you a valuable person?", answers: [{ text: "Am I a person?", correct: true }, { text: "Shine bright like a diamond", correct: false }, { text: "I am the ONE!", correct: false }] }, { text: "Are you kidding me?", answers: [{ text: "No!", correct: true }, { text: "You are god damn right!", correct: false }, { text: "I am the Joker!", correct: false }] }]; // Shuffle answers for each question function shuffle(arr) { for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var t = arr[i]; arr[i] = arr[j]; arr[j] = t; } return arr; } for (var i = 0; i < questions.length; i++) { questions[i].answers = shuffle(questions[i].answers.slice()); } // Game state var currentQuestion = 0; var hearts = 3; var maxHearts = 3; var woman = null; var answerButtons = []; var questionText = null; var heartIcons = []; var angryTimeout = null; var surprisedShown = false; // Layout constants var womanCenterX = 2048 / 2; var womanCenterY = 900; var questionY = 1500; var answerStartY = 1750; var answerSpacing = 220; // Add background asset (behind all elements) var backgroundAsset = LK.getAsset('background', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 0 }); game.addChild(backgroundAsset); // Add woman character woman = new Woman(); game.addChild(woman); woman.x = womanCenterX; woman.y = womanCenterY; // Add hearts (below answer buttons, centered) for (var h = 0; h < maxHearts; h++) { var heart = LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); // Place below answer buttons, centered horizontally // Place hearts in a row, centered at 2048/2, below last answer button var totalWidth = (maxHearts - 1) * 100; heart.x = 2048 / 2 - totalWidth / 2 + h * 100; heart.y = answerStartY + 3 * answerSpacing + 100; // 100px below last answer button game.addChild(heart); heartIcons.push(heart); } // Add question text questionText = new Text2('', { size: 90, fill: 0x222222 }); questionText.anchor.set(0.5, 0); questionText.x = 2048 / 2; questionText.y = questionY; game.addChild(questionText); // Answer button class function createAnswerButton(idx) { var btn = new Container(); // Button background var bg = btn.attachAsset('box', { width: 900, height: 160, color: 0x000000, anchorX: 0.5, anchorY: 0.5 }); // Button text var txt = new Text2('', { size: 70, fill: 0x222222 }); txt.anchor.set(0.5, 0.5); txt.x = 0; txt.y = 0; btn.addChild(txt); // Position btn.x = 2048 / 2; btn.y = answerStartY + idx * answerSpacing; // Store for later btn.bg = bg; btn.txt = txt; btn.idx = idx; // Add to game game.addChild(btn); // Touch/click handler btn.down = function (x, y, obj) { handleAnswer(idx); }; return btn; } // Create answer buttons for (var i = 0; i < 3; i++) { var btn = createAnswerButton(i); answerButtons.push(btn); } // Update hearts display function updateHearts() { for (var i = 0; i < heartIcons.length; i++) { heartIcons[i].alpha = i < hearts ? 1 : 0.2; } } // Show question and answers function showQuestion() { if (currentQuestion >= questions.length) { // Show surprised woman showSurprised(); return; } var q = questions[currentQuestion]; questionText.setText(q.text); for (var i = 0; i < 3; i++) { var ans = q.answers[i]; answerButtons[i].txt.setText(ans ? ans.text : ''); answerButtons[i].visible = !!ans; answerButtons[i].bg.color = 0xf0f0f0; } // Woman happy woman.setState('happy'); woman.startTalking(); // Stop talking after 1.2s LK.setTimeout(function () { woman.stopTalking(); }, 1200); } // Handle answer selection function handleAnswer(idx) { if (currentQuestion >= questions.length) { return; } var q = questions[currentQuestion]; var ans = q.answers[idx]; if (!ans) { return; } // Disable buttons for now for (var i = 0; i < 3; i++) { answerButtons[i].down = null; } if (ans.correct) { // Correct: progress answerButtons[idx].bg.color = 0x83de44; // green woman.setState('happy'); woman.startTalking(); LK.setTimeout(function () { woman.stopTalking(); currentQuestion++; showQuestion(); // Re-enable buttons for (var i = 0; i < 3; i++) { answerButtons[i].down = function (i) { return function (x, y, obj) { handleAnswer(i); }; }(i); } }, 900); } else { // Wrong: lose heart, angry woman, flash answerButtons[idx].bg.color = 0xff3b3b; // red hearts--; updateHearts(); woman.setState('angry'); woman.startTalking(); LK.effects.flashObject(woman, 0x8e44ad, 300); // After 3s, return to happy or end game if (angryTimeout) { LK.clearTimeout(angryTimeout); } angryTimeout = LK.setTimeout(function () { woman.stopTalking(); if (hearts <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } woman.setState('happy'); // Re-enable buttons for (var i = 0; i < 3; i++) { answerButtons[i].down = function (i) { return function (x, y, obj) { handleAnswer(i); }; }(i); } }, 3000); } } // Show surprised woman (win) function showSurprised() { if (surprisedShown) { return; } surprisedShown = true; // Remove mouth if present and parent is not undefined/null if (woman.mouth && typeof woman.mouth.parent !== "undefined" && woman.mouth.parent !== null) { if (typeof woman.mouth.parent.removeChild === "function") { woman.mouth.parent.removeChild(woman.mouth); } } // Show only surprisedWoman face woman.setState('surprised'); // Add 'What' asset under surprisedWoman var whatAsset = LK.getAsset('What', { anchorX: 0.5, anchorY: 0.5, x: womanCenterX, y: womanCenterY + 500 // place under the woman face }); game.addChild(whatAsset); // Remove 'What' asset after 3s (when youwinWoman appears) LK.setTimeout(function () { if (whatAsset && typeof whatAsset.destroy === "function") { whatAsset.destroy(); } }, 3000); // Hide answer buttons for (var i = 0; i < 3; i++) { answerButtons[i].visible = false; } // Show message (optional, can be blank) questionText.setText(""); // After 3 seconds, show youwinWoman (no mouth) LK.setTimeout(function () { // Remove mouth if present (defensive) if (woman.mouth && typeof woman.mouth.parent !== "undefined" && woman.mouth.parent !== null) { if (typeof woman.mouth.parent.removeChild === "function") { woman.mouth.parent.removeChild(woman.mouth); } } // Swap to youwinWoman face (add asset if not present) if (woman.face) { woman.face.destroy(); } woman.face = woman.attachAsset('youwinWoman', { anchorX: 0.5, anchorY: 0.5 }); // After 3 more seconds, finish the game LK.setTimeout(function () { LK.showYouWin(); }, 3000); }, 3000); } // Initial state updateHearts(); showQuestion(); // Make sure answer buttons are re-enabled after each question for (var i = 0; i < 3; i++) { answerButtons[i].down = function (i) { return function (x, y, obj) { handleAnswer(i); }; }(i); } // No dragging or move events needed for this game // No update loop needed
===================================================================
--- original.js
+++ change.js
@@ -47,9 +47,13 @@
anchorX: 0.5,
anchorY: 0.5
});
// Keep mouth on top
- self.mouth.parent.removeChild(self.mouth);
+ if (self.mouth && typeof self.mouth.parent !== "undefined" && self.mouth.parent !== null) {
+ if (typeof self.mouth.parent.removeChild === "function") {
+ self.mouth.parent.removeChild(self.mouth);
+ }
+ }
self.addChild(self.mouth);
};
self.startTalking = function () {
if (self.mouthTalking) {
@@ -104,14 +108,16 @@
/****
* Game Code
****/
-// Questions and answers
-// Happy Woman (Red Square)
-// Angry Woman (Purple Square)
-// Surprised Woman (Yellow Square)
-// Mouth (Ellipse for talking)
+// New asset: 'background' (light gray, editable later)
+// New asset: 'What' (placeholder, 400x400, editable later)
// Heart (for lives)
+// Mouth (Ellipse for talking)
+// Surprised Woman (Yellow Square)
+// Angry Woman (Purple Square)
+// Happy Woman (Red Square)
+// Questions and answers
var questions = [{
text: "Do you know why you are here?",
answers: [{
text: "Yes",
@@ -200,8 +206,16 @@
var womanCenterY = 900;
var questionY = 1500;
var answerStartY = 1750;
var answerSpacing = 220;
+// Add background asset (behind all elements)
+var backgroundAsset = LK.getAsset('background', {
+ anchorX: 0.5,
+ anchorY: 0,
+ x: 2048 / 2,
+ y: 0
+});
+game.addChild(backgroundAsset);
// Add woman character
woman = new Woman();
game.addChild(woman);
woman.x = womanCenterX;
@@ -366,14 +380,30 @@
if (surprisedShown) {
return;
}
surprisedShown = true;
- // Remove mouth if present
- if (woman.mouth && woman.mouth.parent) {
- woman.mouth.parent.removeChild(woman.mouth);
+ // Remove mouth if present and parent is not undefined/null
+ if (woman.mouth && typeof woman.mouth.parent !== "undefined" && woman.mouth.parent !== null) {
+ if (typeof woman.mouth.parent.removeChild === "function") {
+ woman.mouth.parent.removeChild(woman.mouth);
+ }
}
// Show only surprisedWoman face
woman.setState('surprised');
+ // Add 'What' asset under surprisedWoman
+ var whatAsset = LK.getAsset('What', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: womanCenterX,
+ y: womanCenterY + 500 // place under the woman face
+ });
+ game.addChild(whatAsset);
+ // Remove 'What' asset after 3s (when youwinWoman appears)
+ LK.setTimeout(function () {
+ if (whatAsset && typeof whatAsset.destroy === "function") {
+ whatAsset.destroy();
+ }
+ }, 3000);
// Hide answer buttons
for (var i = 0; i < 3; i++) {
answerButtons[i].visible = false;
}
@@ -381,10 +411,12 @@
questionText.setText("");
// After 3 seconds, show youwinWoman (no mouth)
LK.setTimeout(function () {
// Remove mouth if present (defensive)
- if (woman.mouth && woman.mouth.parent) {
- woman.mouth.parent.removeChild(woman.mouth);
+ if (woman.mouth && typeof woman.mouth.parent !== "undefined" && woman.mouth.parent !== null) {
+ if (typeof woman.mouth.parent.removeChild === "function") {
+ woman.mouth.parent.removeChild(woman.mouth);
+ }
}
// Swap to youwinWoman face (add asset if not present)
if (woman.face) {
woman.face.destroy();
Delete the mouth. Woman have no mouth. Just same skin color.
An anime womans mouth. Just mouth.. In-Game asset. 2d. High contrast. No shadows
Fill it red. Its a red rectangle. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Delete the mouth. Woman have no mouth. Just same skin color.
Make her shy and seksier
Show her from a little further away and make a victory sign with her hand and smiley face
same photo but make a victory sign with her hand and smile
Same style bu write: DON'T YOU KNOW WHO YOU ARE
Write "TAP TO START" with a comic font. In-Game asset. 2d. High contrast. No shadows
Write comics style What? in golden color. In-Game asset. 2d. High contrast. No shadows
make same heath like a woman
delete blacks