User prompt
Alt kolları da hemen üst kol hizasina çek
User prompt
Sol üst kol ile sağ dirsek bağla
User prompt
Sağ Üst kol ile sağ dirseki bağla
User prompt
Alt kolların üst kenarının tam ortasını dirseklerin alt kenarına bağla ve alt kollar bu noktadan hereket edebilsin.bütün pozları güncelle.
User prompt
Sol alt kol ve sağ alt kol yer değiştir.
User prompt
Üst kolları sağ ve sol yer değiştir.
User prompt
Üst kolları biraz aç
User prompt
Üst kolların alt kenarının tam ortasını dirseklerin üst kenarına bağla ve üst kollar bu noktadan hereket edebilsin.bütün pozları güncelle.
User prompt
Üst kolların üst kenarının tam ortasını omuzların alt kenarına bağla ve üst kollar bu noktadan hereket edebilsin. bütün pozları güncelle.
User prompt
Üst kolların üst kenarının tam ortası omuzlara bağla ve üst kollar bu noktadan hereket edebilsin.bütün pozları güncelle.
User prompt
Üst kolun hemen alt kenarının tam ortasını dirseke bağla
User prompt
Üst Kolların alt kısımlarını dirseklere bağla.
User prompt
Tüm pozları gözden geçir ik sorunlarını gider zorla
User prompt
Zıplama pozuda oturma pozuyla benzer olsun.
User prompt
Kuklaya tıkladıgımda tüm pozlar gözükmüyor
User prompt
Kalça hep vücut altında sabit olsun.
User prompt
Kuklaya her tıkladığımda pozları sırayla göster. Sorunları test edeceğim
User prompt
Bu sıra jumda bozuluyor düzelt
User prompt
Üst bacakların kalçayla bağlantısı hiçbir pozda kopmasın. Aynı şekilde sol üst bacak-sol diz-sol alt bacak hiç kopmasın. sağ üst bacak -sag diz - sağ alt bacak hiç kopmasın.
User prompt
Ayakta pozunda sol diz ile sol alt bacak sağ diz ile sağ alt bacak bağlansın ik
User prompt
Üst bacak ve alt bacak bağlantısında ik kısıtlarını ekle
User prompt
Oturma pozunu bağdaş kurma pozuns çevir.
User prompt
Tüm vücut parçaları ve pozların ik kinematik fizik hareketlerini ve işlevlerini tekrar güncelle, iyileştir.
User prompt
soldaki ve sağdaki enstrümanları basınca oyun bitene kadar sürekli çal ta ki bir kez daha basincaya kadar.
User prompt
soldaki ve sağdaki enstrümanları basınca sürekli çal ta ki bir kez daha basincaya kadar.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Drum class var Drum = Container.expand(function () { var self = Container.call(this); self.drumType = 'none'; // 'large', 'left', 'right', 'sit', 'stand' self.action = null; // function to call on tap // Set up drum asset self.setDrum = function (type) { self.drumType = type; var assetId = type === 'large' ? 'drum_large' : 'drum_medium'; var drum = self.attachAsset(assetId, { anchorX: 0.5, anchorY: 0.5 }); // (Drum label removed) }; // Drum tap effect self.flash = function () { tween(self, { scaleX: 1.18, scaleY: 0.92 }, { duration: 80, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 120 }); } }); }; // Touch event self.down = function (x, y, obj) { self.flash(); // Play unique sound for each drum type if (self.drumType === 'large') { LK.getSound('drum_tap_center').play(); } else if (self.drumType === 'left') { // Play with very long reverb effect if (typeof reverb !== "undefined" && reverb.add) { var leftSound = LK.getSound('drum_tap_left'); reverb.add(leftSound, { reverbTime: 3.5 }); // simulate very long reverb (if plugin supports param) leftSound.play(); } else { LK.getSound('drum_tap_left').play(); } } else if (self.drumType === 'right') { // Play with very long reverb effect if (typeof reverb !== "undefined" && reverb.add) { var rightSound = LK.getSound('drum_tap_right'); reverb.add(rightSound, { reverbTime: 3.5 }); // simulate very long reverb (if plugin supports param) rightSound.play(); } else { LK.getSound('drum_tap_right').play(); } } else if (self.drumType === 'sit') { var sitSound = LK.getSound('drum_tap_sit'); sitSound.play(); LK.setTimeout(function () { sitSound.play(); }, 120); } else if (self.drumType === 'stand') { // Play the sound with 3 fast delay effects (echoes) var base = LK.getSound('drum_tap_stand'); base.play(); LK.setTimeout(function () { base.play(); }, 45); LK.setTimeout(function () { base.play(); }, 90); } else { // No fallback sound } if (self.action) self.action(); }; return self; }); // Puppet class: articulated body with simple kinematics var Puppet = Container.expand(function () { var self = Container.call(this); // --- Body part sizes (for positioning) --- var headH = 120 * 1.5, headW = 120 * 1.5; var bodyH = 200 * 1.5, bodyW = 80 * 1.5; var upperArmH = 100 * 1.5, upperArmW = 40 * 1.5; var lowerArmH = 90 * 1.5, lowerArmW = 32 * 1.5; var upperLegH = 120 * 1.5, upperLegW = 48 * 1.5; var lowerLegH = 110 * 1.5, lowerLegW = 40 * 1.5; // --- Create body parts --- // Head var head = self.attachAsset('puppet_head', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Neck (between head and body, sized to match hip) var neck = self.attachAsset('puppet_neck', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, // match hip scale scaleY: 1.5 }); // Shoulders (left and right) var lShoulder = self.attachAsset('puppet_shoulder', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); var rShoulder = self.attachAsset('puppet_shoulder', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Body var body = self.attachAsset('puppet_body', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Single hip (center) var hip = self.attachAsset('puppet_hip', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Right upper arm (was left) var lUpperArm = self.attachAsset('puppet_upperarm', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Right elbow (was left) var lElbow = self.attachAsset('puppet_elbow', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Right lower arm (was left) var lLowerArm = self.attachAsset('puppet_lowerarm', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Left upper arm (was right) var rUpperArm = self.attachAsset('puppet_upperarm', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Left elbow (was right) var rElbow = self.attachAsset('puppet_elbow', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Left lower arm (was right) var rLowerArm = self.attachAsset('puppet_lowerarm', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Left upper leg var lUpperLeg = self.attachAsset('puppet_upperleg', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Left knee var lKnee = self.attachAsset('puppet_knee', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Left lower leg var lLowerLeg = self.attachAsset('puppet_lowerleg', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Right upper leg var rUpperLeg = self.attachAsset('puppet_upperleg', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // Right knee var rKnee = self.attachAsset('puppet_knee', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); // Right lower leg var rLowerLeg = self.attachAsset('puppet_lowerleg', { anchorX: 0.5, anchorY: 0, scaleX: 1.5, scaleY: 1.5 }); // --- Initial pose state --- self.state = { vx: 0, // horizontal velocity vy: 0, // vertical velocity grounded: false, pose: 'stand', // 'stand', 'sit', 'jump' headAngle: 0, // radians, for "pull head" actions x: 0, // world position y: 0 }; // --- Positioning offsets (relative to puppet center) --- function updateBodyParts() { // Head head.x = 0; // Move head higher above the neck for a more natural look (was +10, now -30 for more separation) head.y = -bodyH / 2 - headH / 2 - 30; head.rotation = self.state.headAngle; // Neck: place between head and body, sized to match hip // Use hip asset size for neck size/placement var hipH = 44 * 1.5; // puppet_hip height * scale var neckH = hipH; neck.x = 0; neck.y = -bodyH / 2 - neckH / 2 + 38; // 38 is a small offset to visually connect neck, adjust as needed neck.rotation = 0; // Body body.x = 0; body.y = -bodyH / 2; // Arms var armY = -bodyH / 2 + 30; var armX = bodyW / 2 + upperArmW / 2 - 10; // Shoulder positions var lShoulderX = -armX; var lShoulderY = armY; var rShoulderX = armX; var rShoulderY = armY; // Place shoulder assets at shoulder positions lShoulder.x = lShoulderX; lShoulder.y = lShoulderY; rShoulder.x = rShoulderX; rShoulder.y = rShoulderY; // --- Improved arm kinematics --- // Default arm pose angles (opened wider) var lUpperArmAngle = 0.45; var rUpperArmAngle = -0.45; var lLowerArmAngle = -0.25; var rLowerArmAngle = 0.25; // Pose-based arm animation if (self.state.pose === 'sit') { lUpperArmAngle = 1.45; rUpperArmAngle = -1.45; lLowerArmAngle = -1.5; rLowerArmAngle = 1.5; // Anchor upper arms to shoulder bottom in sit pose lUpperArm.x = lShoulder.x; lUpperArm.y = lShoulder.y + 38 * 1.5 / 2; lUpperArm.rotation = lUpperArmAngle; // Connect upper arm's bottom center to elbow's top center var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH; var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH; lElbow.x = lUpperArmBottomX; lElbow.y = lUpperArmBottomY; // Connect lower arm's top center to be horizontally aligned with upper arm (sit pose) var lElbowBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); var lElbowBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); lLowerArm.x = lElbowBottomX; lLowerArm.y = lElbowBottomY; lLowerArm.rotation = lLowerArmAngle; var rElbowBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); var rElbowBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); rLowerArm.x = rElbowBottomX; rLowerArm.y = rElbowBottomY; rUpperArm.x = rShoulder.x; rUpperArm.y = rShoulder.y + 38 * 1.5 / 2; rUpperArm.rotation = rUpperArmAngle; // Connect upper arm's bottom center to elbow's top center var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * upperArmH; var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * upperArmH; rElbow.x = rUpperArmBottomX; rElbow.y = rUpperArmBottomY; rLowerArm.rotation = rLowerArmAngle; } else if (self.state.pose === 'jump') { lUpperArmAngle = 1.35; rUpperArmAngle = -1.35; lLowerArmAngle = -2.0; rLowerArmAngle = 2.0; } else if (self.state.pose === 'stand') { // Gentle swing based on horizontal velocity for more life lUpperArmAngle -= self.state.vx * 0.01; rUpperArmAngle += self.state.vx * 0.01; lLowerArmAngle -= Math.sin(Date.now() * 0.003) * 0.08; rLowerArmAngle += Math.sin(Date.now() * 0.003) * 0.08; } // Right upper arm: connect its top center to the bottom center of the left shoulder var lShoulderBottomY = lShoulder.y + 38 * 1.5 / 2; // shoulder asset height * scale / 2 lUpperArm.x = lShoulder.x; lUpperArm.y = lShoulderBottomY; lUpperArm.rotation = lUpperArmAngle; // Right elbow position: connect upper arm's bottom center to elbow's top center var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArmAngle) * upperArmH; var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArmAngle) * upperArmH; lElbow.x = lUpperArmBottomX; lElbow.y = lUpperArmBottomY; // Right lower arm: align horizontally with upper arm var lLowerArmAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); var lLowerArmAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); lLowerArm.x = lLowerArmAlignX; lLowerArm.y = lLowerArmAlignY; lLowerArm.rotation = lLowerArmAngle; // Left upper arm: connect its top center to the bottom center of the right shoulder var rShoulderBottomY = rShoulder.y + 38 * 1.5 / 2; rUpperArm.x = rShoulder.x; rUpperArm.y = rShoulderBottomY; rUpperArm.rotation = rUpperArmAngle; // Left elbow position: connect upper arm's bottom center to elbow's top center var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArmAngle) * upperArmH; var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArmAngle) * upperArmH; rElbow.x = rUpperArmBottomX; rElbow.y = rUpperArmBottomY; // Left lower arm: align horizontally with upper arm var rLowerArmAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); var rLowerArmAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); rLowerArm.x = rLowerArmAlignX; rLowerArm.y = rLowerArmAlignY; rLowerArm.rotation = rLowerArmAngle; // --- Improved leg kinematics --- var legY = bodyH / 2 - 10; var legX = bodyW / 2 - 18; // Hip position (center) var hipX = 0; var hipY = legY; hip.x = hipX; hip.y = hipY; // Both legs originate from the single hip var lHipX = hipX - legX; var lHipY = hipY; var rHipX = hipX + legX; var rHipY = hipY; // Default leg pose var lUpperLegAngle = 0.18; var rUpperLegAngle = -0.18; var lLowerLegAngle = 0.25; var rLowerLegAngle = -0.25; // Pose-based leg animation if (self.state.pose === 'sit') { lUpperLegAngle = 1.35; rUpperLegAngle = 1.35; lLowerLegAngle = lUpperLegAngle - Math.PI / 2 + 0.15; rLowerLegAngle = rUpperLegAngle - Math.PI / 2 - 0.15; } else if (self.state.pose === 'jump') { lUpperLegAngle = -1.2; rUpperLegAngle = -1.2; lLowerLegAngle = lUpperLegAngle + 2.1; rLowerLegAngle = rUpperLegAngle + 2.1; } else if (self.state.pose === 'stand') { // Gentle walk cycle if moving var walk = Math.abs(self.state.vx) > 0.5 ? Math.sin(Date.now() * 0.008) * 0.25 : 0; lUpperLegAngle += walk; rUpperLegAngle -= walk; lLowerLegAngle += walk * 0.5; rLowerLegAngle -= walk * 0.5; } // Left upper leg lUpperLeg.x = hip.x - legX; lUpperLeg.y = hip.y; lUpperLeg.rotation = lUpperLegAngle; // Calculate left knee position var lKneeX = lUpperLeg.x + Math.sin(lUpperLegAngle) * upperLegH; var lKneeY = lUpperLeg.y + Math.cos(lUpperLegAngle) * upperLegH; lKnee.x = lKneeX; lKnee.y = lKneeY; // Attach lower leg at knee, rotate for more natural foot placement lLowerLeg.x = lKneeX; lLowerLeg.y = lKneeY; lLowerLeg.rotation = lLowerLegAngle; // Right upper leg rUpperLeg.x = hip.x + legX; rUpperLeg.y = hip.y; rUpperLeg.rotation = rUpperLegAngle; // Calculate right knee position var rKneeX = rUpperLeg.x + Math.sin(rUpperLegAngle) * upperLegH; var rKneeY = rUpperLeg.y + Math.cos(rUpperLegAngle) * upperLegH; rKnee.x = rKneeX; rKnee.y = rKneeY; // Attach lower leg at knee, rotate for more natural foot placement rLowerLeg.x = rKneeX; rLowerLeg.y = rKneeY; rLowerLeg.rotation = rLowerLegAngle; // Pose adjustments if (self.state.pose === 'sit') { // Sitting: thighs forward, knees bent, shins down lUpperLeg.x = hip.x - legX; lUpperLeg.y = hip.y; lUpperLeg.rotation = 1.35; var lKneeX = lUpperLeg.x + Math.sin(lUpperLeg.rotation) * upperLegH; var lKneeY = lUpperLeg.y + Math.cos(lUpperLeg.rotation) * upperLegH; lKnee.x = lKneeX; lKnee.y = lKneeY; lLowerLeg.x = lKneeX; lLowerLeg.y = lKneeY; lLowerLeg.rotation = lUpperLeg.rotation - Math.PI / 2 + 0.15; rUpperLeg.x = hip.x + legX; rUpperLeg.y = hip.y; rUpperLeg.rotation = 1.35; var rKneeX = rUpperLeg.x + Math.sin(rUpperLeg.rotation) * upperLegH; var rKneeY = rUpperLeg.y + Math.cos(rUpperLeg.rotation) * upperLegH; rKnee.x = rKneeX; rKnee.y = rKneeY; rLowerLeg.x = rKneeX; rLowerLeg.y = rKneeY; rLowerLeg.rotation = rUpperLeg.rotation - Math.PI / 2 - 0.15; // Swap arms for sit pose lUpperArm.x = lShoulder.x; lUpperArm.y = lShoulder.y + 38 * 1.5 / 2; lUpperArm.rotation = 1.1; var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH; var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH; lElbow.x = lUpperArmBottomX; lElbow.y = lUpperArmBottomY; // Connect lower arm's top center to be horizontally aligned with upper arm (sit pose, swap arms) var lLowerArmSitAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); var lLowerArmSitAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); lLowerArm.x = lLowerArmSitAlignX; lLowerArm.y = lLowerArmSitAlignY; lLowerArm.rotation = -2.0; var rLowerArmSitAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); var rLowerArmSitAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); rLowerArm.x = rLowerArmSitAlignX; rLowerArm.y = rLowerArmSitAlignY; rUpperArm.x = rShoulder.x; rUpperArm.y = rShoulder.y + 38 * 1.5 / 2; rUpperArm.rotation = -1.1; var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * upperArmH; var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * upperArmH; rElbow.x = rUpperArmBottomX; rElbow.y = rUpperArmBottomY; rLowerArm.rotation = 2.0; body.rotation = -0.18; } else if (self.state.pose === 'jump') { // Jump: legs up, knees bent, elbows and knees more pronounced lUpperLeg.x = hip.x - legX; lUpperLeg.y = hip.y; lUpperLeg.rotation = -1.2; var lKneeX = lUpperLeg.x + Math.sin(lUpperLeg.rotation) * upperLegH; var lKneeY = lUpperLeg.y + Math.cos(lUpperLeg.rotation) * upperLegH; lKnee.x = lKneeX; lKnee.y = lKneeY; lLowerLeg.x = lKneeX; lLowerLeg.y = lKneeY; lLowerLeg.rotation = lUpperLeg.rotation + 2.1; rUpperLeg.x = hip.x + legX; rUpperLeg.y = hip.y; rUpperLeg.rotation = -1.2; var rKneeX = rUpperLeg.x + Math.sin(rUpperLeg.rotation) * upperLegH; var rKneeY = rUpperLeg.y + Math.cos(rUpperLeg.rotation) * upperLegH; rKnee.x = rKneeX; rKnee.y = rKneeY; rLowerLeg.x = rKneeX; rLowerLeg.y = rKneeY; rLowerLeg.rotation = rUpperLeg.rotation + 2.1; // Elbows more bent in jump // Anchor upper arms to shoulder bottom lUpperArm.x = lShoulder.x; lUpperArm.y = lShoulder.y + 38 * 1.5 / 2; lUpperArm.rotation = 1.1; var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH; var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH; lElbow.x = lUpperArmBottomX; lElbow.y = lUpperArmBottomY; // Connect lower arm's top center to be horizontally aligned with upper arm (jump pose) var lLowerArmJumpAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); var lLowerArmJumpAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2); lLowerArm.x = lLowerArmJumpAlignX; lLowerArm.y = lLowerArmJumpAlignY; lLowerArm.rotation = -2.0; var rLowerArmJumpAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); var rLowerArmJumpAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2); rLowerArm.x = rLowerArmJumpAlignX; rLowerArm.y = rLowerArmJumpAlignY; rUpperArm.x = rShoulder.x; rUpperArm.y = rShoulder.y + 38 * 1.5 / 2; rUpperArm.rotation = -1.1; var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * upperArmH; var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * upperArmH; rElbow.x = rUpperArmBottomX; rElbow.y = rUpperArmBottomY; rLowerArm.rotation = 2.0; body.rotation = 0.12; } else { body.rotation = 0; } } // --- Public puppet actions --- self.pullHeadLeft = function () { // Pull head left, add leftward velocity if (self.state.grounded) { self.state.vx -= 12; self.state.headAngle = -0.5; tween(self.state, { headAngle: 0 }, { duration: 400, easing: tween.easeOut }); } }; self.pullHeadRight = function () { if (self.state.grounded) { self.state.vx += 12; self.state.headAngle = 0.5; tween(self.state, { headAngle: 0 }, { duration: 400, easing: tween.easeOut }); } }; self.jump = function () { if (self.state.grounded) { self.state.vy = -48; // Increased jump velocity for higher jump self.state.grounded = false; self.state.pose = 'jump'; tween(self.state, {}, { duration: 0, onFinish: function onFinish() { // After 400ms, return to stand pose LK.setTimeout(function () { self.state.pose = 'stand'; }, 400); } }); } }; self.sit = function () { if (self.state.grounded && self.state.pose !== 'sit') { self.state.pose = 'sit'; // After 600ms, stand up automatically LK.setTimeout(function () { self.stand(); }, 600); } }; self.stand = function () { if (self.state.grounded && self.state.pose !== 'stand') { self.state.pose = 'stand'; } }; // --- Physics update --- self.update = function () { // Gravity if (!self.state.grounded) { self.state.vy += 2.2; // gravity if (self.state.vy > 40) self.state.vy = 40; } // Friction if (self.state.grounded) { self.state.vx *= 0.82; if (Math.abs(self.state.vx) < 0.5) self.state.vx = 0; } else { self.state.vx *= 0.98; } // Move self.state.x += self.state.vx; self.state.y += self.state.vy; // Clamp to world bounds if (self.state.x < 80) self.state.x = 80; if (self.state.x > 2048 - 80) self.state.x = 2048 - 80; // --- Ava: Adjust puppet Y so feet are above ground visually --- // The puppet's feet are at y + (bodyH/2) + upperLegH + lowerLegH - 10 - 10 // ground.y = 2732 - 80, ground height = 80 // So, puppet.y + (bodyH/2) + upperLegH + lowerLegH - 20 = 2732 - 80 // puppet.y = 2732 - 80 - (bodyH/2) - upperLegH - lowerLegH + 20 var puppetFeetOffset = bodyH / 2 + upperLegH + lowerLegH - 20; var puppetGroundY = 2732 - 80 - puppetFeetOffset; if (self.state.y > puppetGroundY) self.state.y = puppetGroundY; // above ground // Ground collision if (self.state.y >= puppetGroundY) { self.state.y = puppetGroundY; self.state.vy = 0; self.state.grounded = true; if (self.state.pose === 'jump') self.state.pose = 'stand'; } else { self.state.grounded = false; } // Apply to container self.x = self.state.x; self.y = self.state.y; updateBodyParts(); }; // --- Start position --- self.state.x = 600; // Moved puppet further right (was 180) // --- Ava: Set initial Y so feet are above ground visually --- var puppetFeetOffset = bodyH / 2 + upperLegH + lowerLegH - 20; self.state.y = 2732 - 80 - puppetFeetOffset; updateBodyParts(); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Ava: background asset // Apply reverb to all drum and win/lose sounds // --- World setup --- // Puppet body parts (shapes) // Drums // Ground // Finish sign // Drum tap sound // Win/lose sound // Define and initialize the reverb object before using it var reverb = { add: function add(sound) { // Dummy implementation: does nothing, but prevents errors // In a real environment, this would apply a reverb effect to the sound } }; reverb.add(LK.getSound('drum_tap_center')); reverb.add(LK.getSound('drum_tap_left')); reverb.add(LK.getSound('drum_tap_right')); reverb.add(LK.getSound('drum_tap_sit')); reverb.add(LK.getSound('drum_tap_stand')); reverb.add(LK.getSound('lose')); reverb.add(LK.getSound('win')); // --- Background music playlist (4 tracks, play in random order) --- var musicTracks = [{ id: 'musicId', volume: 0.1, start: 0, end: 1 }, { id: 'musicId2', volume: 0.1, start: 0, end: 1 }, { id: 'musicId3', volume: 0.1, start: 0, end: 1 }, { id: 'musicId4', volume: 0.1, start: 0, end: 1 }]; // Shuffle helper (Fisher-Yates) function shuffleArray(arr) { for (var i = arr.length - 1; i > 0; i--) { var j = Math.floor(Math.random() * (i + 1)); var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } // Start with a shuffled playlist var shuffledMusicOrder = []; function reshuffleMusicOrder() { shuffledMusicOrder = []; for (var i = 0; i < musicTracks.length; ++i) shuffledMusicOrder.push(i); shuffleArray(shuffledMusicOrder); } reshuffleMusicOrder(); var currentMusicOrderIndex = 0; function playNextMusic() { // If we've played all, reshuffle for a new random order if (currentMusicOrderIndex >= shuffledMusicOrder.length) { reshuffleMusicOrder(); currentMusicOrderIndex = 0; } var trackIndex = shuffledMusicOrder[currentMusicOrderIndex]; var track = musicTracks[trackIndex]; LK.playMusic(track.id, { loop: false, volume: track.volume, start: track.start, end: track.end, onFinish: function onFinish() { currentMusicOrderIndex++; playNextMusic(); } }); } playNextMusic(); game.setBackgroundColor(0x000000); // --- Background --- // Ava: Add background image behind all elements var background = LK.getAsset('background', { anchorX: 0, anchorY: 0, x: 0, y: 0, scaleX: 1, scaleY: 1 }); game.addChild(background); // Ground var ground = LK.getAsset('ground', { anchorX: 0, anchorY: 0 }); ground.x = 0; ground.y = 2732 - 80; game.addChild(ground); // Finish sign var finishSign = LK.getAsset('finish_sign', { anchorX: 0.5, anchorY: 1, scaleX: 3, scaleY: 6 // 2x as tall as before }); finishSign.x = 2048 - 120; finishSign.y = 2732 - 80; game.addChild(finishSign); // Finish text removed // --- Puppet --- var puppet = new Puppet(); game.addChild(puppet); // --- Drums --- var drums = []; // Drum positions (relative to center) // Move drums higher: set drumCenterY above puppet's head var drumCenterX = 2048 / 2, drumCenterY = 900; // was 2732 / 2 + 220, now much higher (puppet head is around y=~1200) var drumRadius = 220 * 3; var angleList = [{ type: 'left', angle: -Math.PI / 2 - 0.7 }, { type: 'right', angle: -Math.PI / 2 + 0.7 }, { type: 'sit', angle: Math.PI / 2 + 0.7 }, { type: 'stand', angle: Math.PI / 2 - 0.7 }]; // --- Drum action pool --- // Each drum will have all actions, only their order will be shuffled // Ava: Increase the number of right movement actions (pullHeadRight) in the action pool var puppetActions = [function () { puppet.pullHeadLeft(); }, function () { puppet.pullHeadRight(); }, function () { puppet.pullHeadRight(); }, function () { puppet.jump(); }, function () { puppet.sit(); }, function () { puppet.stand(); }]; // Large center drum (fixed action sequence) var drumJump = new Drum(); drumJump.setDrum('large'); drumJump.x = drumCenterX; drumJump.y = drumCenterY; // Assign a fixed sequence of all 5 actions, and cycle through them drumJump._actionSequence = puppetActions.slice(); drumJump._actionIndex = 0; drumJump.action = function () { drumJump._actionSequence[drumJump._actionIndex](); drumJump._actionIndex = (drumJump._actionIndex + 1) % drumJump._actionSequence.length; }; game.addChild(drumJump); drums.push(drumJump); // Four medium drums for (var i = 0; i < angleList.length; ++i) { var d = new Drum(); d.setDrum(angleList[i].type); d.x = drumCenterX + Math.cos(angleList[i].angle) * drumRadius; d.y = drumCenterY + Math.sin(angleList[i].angle) * drumRadius; // Each drum gets a fixed sequence of all 5 actions, and cycles through them d._actionSequence = puppetActions.slice(); d._actionIndex = 0; d.action = function (drum) { return function () { drum._actionSequence[drum._actionIndex](); drum._actionIndex = (drum._actionIndex + 1) % drum._actionSequence.length; }; }(d); game.addChild(d); drums.push(d); } // --- Timer --- var timeLeft = 60; function formatTimeDigital(secs) { var m = Math.floor(secs / 60); var s = secs % 60; var mm = m < 10 ? "0" + m : "" + m; var ss = s < 10 ? "0" + s : "" + s; return mm + ":" + ss; } var timerText = new Text2(formatTimeDigital(60), { size: 120, fill: '#ffffff' }); timerText.anchor.set(0.5, 0); LK.gui.top.addChild(timerText); // --- Score/Win state --- var gameEnded = false; // --- Timer logic --- var timerInterval = LK.setInterval(function () { if (gameEnded) return; timeLeft -= 1; if (timeLeft < 0) timeLeft = 0; timerText.setText(formatTimeDigital(timeLeft)); if (timeLeft === 0 && !gameEnded) { gameEnded = true; LK.getSound('lose').play(); LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); } }, 1000); // --- Game update --- game.update = function () { if (gameEnded) return; puppet.update(); // Win condition: puppet body collides with finish sign using intersects if (!gameEnded && puppet.intersects(finishSign)) { gameEnded = true; LK.setScore(timeLeft); // Set score to remaining seconds LK.getSound('win').play(); LK.effects.flashScreen(0x44c767, 800); LK.showYouWin(); } }; // --- Clean up on game over --- game.onDestroy = function () { LK.clearInterval(timerInterval); }; // --- Prevent accidental tap on top left (menu) --- /* No elements are placed at (0,0)-(100,100) */ // --- UX: drums are always on top --- for (var i = 0; i < drums.length; ++i) { game.addChild(drums[i]); }
===================================================================
--- original.js
+++ change.js
@@ -292,21 +292,21 @@
// Anchor upper arms to shoulder bottom in sit pose
lUpperArm.x = lShoulder.x;
lUpperArm.y = lShoulder.y + 38 * 1.5 / 2;
lUpperArm.rotation = lUpperArmAngle;
- // Connect right upper arm's bottom center to right elbow's top center (sit pose)
+ // Connect upper arm's bottom center to elbow's top center
var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH;
var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH;
lElbow.x = lUpperArmBottomX;
lElbow.y = lUpperArmBottomY;
- // Connect lower arm's top center to elbow's bottom center (sit pose)
- var lElbowBottomX = lElbow.x + Math.sin(lLowerArmAngle) * (28 * 1.5 / 2);
- var lElbowBottomY = lElbow.y + Math.cos(lLowerArmAngle) * (28 * 1.5 / 2);
+ // Connect lower arm's top center to be horizontally aligned with upper arm (sit pose)
+ var lElbowBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var lElbowBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
lLowerArm.x = lElbowBottomX;
lLowerArm.y = lElbowBottomY;
lLowerArm.rotation = lLowerArmAngle;
- var rElbowBottomX = rElbow.x + Math.sin(rLowerArmAngle) * (28 * 1.5 / 2);
- var rElbowBottomY = rElbow.y + Math.cos(rLowerArmAngle) * (28 * 1.5 / 2);
+ var rElbowBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var rElbowBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
rLowerArm.x = rElbowBottomX;
rLowerArm.y = rElbowBottomY;
rUpperArm.x = rShoulder.x;
rUpperArm.y = rShoulder.y + 38 * 1.5 / 2;
@@ -333,36 +333,34 @@
var lShoulderBottomY = lShoulder.y + 38 * 1.5 / 2; // shoulder asset height * scale / 2
lUpperArm.x = lShoulder.x;
lUpperArm.y = lShoulderBottomY;
lUpperArm.rotation = lUpperArmAngle;
- // Right elbow position: connect right upper arm's bottom center to right elbow's top center
+ // Right elbow position: connect upper arm's bottom center to elbow's top center
var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArmAngle) * upperArmH;
var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArmAngle) * upperArmH;
lElbow.x = lUpperArmBottomX;
lElbow.y = lUpperArmBottomY;
- // Right lower arm: connect its top center to the bottom center of upper arm (elbow)
- // Now: connect lower arm's top center to the bottom center of the elbow
- var lElbowBottomX = lElbow.x + Math.sin(lLowerArmAngle) * (28 * 1.5 / 2); // elbow asset height * scale / 2
- var lElbowBottomY = lElbow.y + Math.cos(lLowerArmAngle) * (28 * 1.5 / 2);
- lLowerArm.x = lElbowBottomX;
- lLowerArm.y = lElbowBottomY;
+ // Right lower arm: align horizontally with upper arm
+ var lLowerArmAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var lLowerArmAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ lLowerArm.x = lLowerArmAlignX;
+ lLowerArm.y = lLowerArmAlignY;
lLowerArm.rotation = lLowerArmAngle;
// Left upper arm: connect its top center to the bottom center of the right shoulder
var rShoulderBottomY = rShoulder.y + 38 * 1.5 / 2;
rUpperArm.x = rShoulder.x;
rUpperArm.y = rShoulderBottomY;
rUpperArm.rotation = rUpperArmAngle;
- // Left elbow position: connect left upper arm's bottom center to right elbow's top center
- var lUpperArmBottomX_forRightElbow = lUpperArm.x + Math.sin(lUpperArmAngle) * upperArmH;
- var lUpperArmBottomY_forRightElbow = lUpperArm.y + Math.cos(lUpperArmAngle) * upperArmH;
- rElbow.x = lUpperArmBottomX_forRightElbow;
- rElbow.y = lUpperArmBottomY_forRightElbow;
- // Left lower arm: connect its top center to the bottom center of upper arm (elbow)
- // Now: connect lower arm's top center to the bottom center of the elbow
- var rElbowBottomX = rElbow.x + Math.sin(rLowerArmAngle) * (28 * 1.5 / 2); // elbow asset height * scale / 2
- var rElbowBottomY = rElbow.y + Math.cos(rLowerArmAngle) * (28 * 1.5 / 2);
- rLowerArm.x = rElbowBottomX;
- rLowerArm.y = rElbowBottomY;
+ // Left elbow position: connect upper arm's bottom center to elbow's top center
+ var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArmAngle) * upperArmH;
+ var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArmAngle) * upperArmH;
+ rElbow.x = rUpperArmBottomX;
+ rElbow.y = rUpperArmBottomY;
+ // Left lower arm: align horizontally with upper arm
+ var rLowerArmAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var rLowerArmAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ rLowerArm.x = rLowerArmAlignX;
+ rLowerArm.y = rLowerArmAlignY;
rLowerArm.rotation = rLowerArmAngle;
// --- Improved leg kinematics ---
var legY = bodyH / 2 - 10;
var legX = bodyW / 2 - 18;
@@ -452,31 +450,29 @@
// Swap arms for sit pose
lUpperArm.x = lShoulder.x;
lUpperArm.y = lShoulder.y + 38 * 1.5 / 2;
lUpperArm.rotation = 1.1;
- // Connect right upper arm's bottom center to right elbow's top center (sit pose, swap arms)
var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH;
var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH;
lElbow.x = lUpperArmBottomX;
lElbow.y = lUpperArmBottomY;
- // Connect lower arm's top center to elbow's bottom center (sit pose, swap arms)
- var lElbowBottomX = lElbow.x + Math.sin(-2.0) * (28 * 1.5 / 2);
- var lElbowBottomY = lElbow.y + Math.cos(-2.0) * (28 * 1.5 / 2);
- lLowerArm.x = lElbowBottomX;
- lLowerArm.y = lElbowBottomY;
+ // Connect lower arm's top center to be horizontally aligned with upper arm (sit pose, swap arms)
+ var lLowerArmSitAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var lLowerArmSitAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ lLowerArm.x = lLowerArmSitAlignX;
+ lLowerArm.y = lLowerArmSitAlignY;
lLowerArm.rotation = -2.0;
- var rElbowBottomX = rElbow.x + Math.sin(2.0) * (28 * 1.5 / 2);
- var rElbowBottomY = rElbow.y + Math.cos(2.0) * (28 * 1.5 / 2);
- rLowerArm.x = rElbowBottomX;
- rLowerArm.y = rElbowBottomY;
+ var rLowerArmSitAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var rLowerArmSitAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ rLowerArm.x = rLowerArmSitAlignX;
+ rLowerArm.y = rLowerArmSitAlignY;
rUpperArm.x = rShoulder.x;
rUpperArm.y = rShoulder.y + 38 * 1.5 / 2;
rUpperArm.rotation = -1.1;
- // Connect left upper arm's bottom center to right elbow's top center (sit pose, swap arms)
- var lUpperArmBottomX_forRightElbow = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH;
- var lUpperArmBottomY_forRightElbow = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH;
- rElbow.x = lUpperArmBottomX_forRightElbow;
- rElbow.y = lUpperArmBottomY_forRightElbow;
+ var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * upperArmH;
+ var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * upperArmH;
+ rElbow.x = rUpperArmBottomX;
+ rElbow.y = rUpperArmBottomY;
rLowerArm.rotation = 2.0;
body.rotation = -0.18;
} else if (self.state.pose === 'jump') {
// Jump: legs up, knees bent, elbows and knees more pronounced
@@ -504,31 +500,29 @@
// Anchor upper arms to shoulder bottom
lUpperArm.x = lShoulder.x;
lUpperArm.y = lShoulder.y + 38 * 1.5 / 2;
lUpperArm.rotation = 1.1;
- // Connect right upper arm's bottom center to right elbow's top center (jump pose)
var lUpperArmBottomX = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH;
var lUpperArmBottomY = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH;
lElbow.x = lUpperArmBottomX;
lElbow.y = lUpperArmBottomY;
- // Connect lower arm's top center to elbow's bottom center (jump pose)
- var lElbowBottomX = lElbow.x + Math.sin(-2.0) * (28 * 1.5 / 2);
- var lElbowBottomY = lElbow.y + Math.cos(-2.0) * (28 * 1.5 / 2);
- lLowerArm.x = lElbowBottomX;
- lLowerArm.y = lElbowBottomY;
+ // Connect lower arm's top center to be horizontally aligned with upper arm (jump pose)
+ var lLowerArmJumpAlignX = lUpperArm.x + Math.sin(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var lLowerArmJumpAlignY = lUpperArm.y + Math.cos(lUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ lLowerArm.x = lLowerArmJumpAlignX;
+ lLowerArm.y = lLowerArmJumpAlignY;
lLowerArm.rotation = -2.0;
- var rElbowBottomX = rElbow.x + Math.sin(2.0) * (28 * 1.5 / 2);
- var rElbowBottomY = rElbow.y + Math.cos(2.0) * (28 * 1.5 / 2);
- rLowerArm.x = rElbowBottomX;
- rLowerArm.y = rElbowBottomY;
+ var rLowerArmJumpAlignX = rUpperArm.x + Math.sin(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ var rLowerArmJumpAlignY = rUpperArm.y + Math.cos(rUpperArm.rotation) * (upperArmH + lowerArmH / 2);
+ rLowerArm.x = rLowerArmJumpAlignX;
+ rLowerArm.y = rLowerArmJumpAlignY;
rUpperArm.x = rShoulder.x;
rUpperArm.y = rShoulder.y + 38 * 1.5 / 2;
rUpperArm.rotation = -1.1;
- // Connect left upper arm's bottom center to right elbow's top center (jump pose)
- var lUpperArmBottomX_forRightElbow = lUpperArm.x + Math.sin(lUpperArm.rotation) * upperArmH;
- var lUpperArmBottomY_forRightElbow = lUpperArm.y + Math.cos(lUpperArm.rotation) * upperArmH;
- rElbow.x = lUpperArmBottomX_forRightElbow;
- rElbow.y = lUpperArmBottomY_forRightElbow;
+ var rUpperArmBottomX = rUpperArm.x + Math.sin(rUpperArm.rotation) * upperArmH;
+ var rUpperArmBottomY = rUpperArm.y + Math.cos(rUpperArm.rotation) * upperArmH;
+ rElbow.x = rUpperArmBottomX;
+ rElbow.y = rUpperArmBottomY;
rLowerArm.rotation = 2.0;
body.rotation = 0.12;
} else {
body.rotation = 0;
@@ -650,18 +644,18 @@
/****
* Game Code
****/
-// Define and initialize the reverb object before using it
-// Win/lose sound
-// Drum tap sound
-// Finish sign
-// Ground
-// Drums
-// Puppet body parts (shapes)
-// --- World setup ---
-// Apply reverb to all drum and win/lose sounds
// Ava: background asset
+// Apply reverb to all drum and win/lose sounds
+// --- World setup ---
+// Puppet body parts (shapes)
+// Drums
+// Ground
+// Finish sign
+// Drum tap sound
+// Win/lose sound
+// Define and initialize the reverb object before using it
var reverb = {
add: function add(sound) {
// Dummy implementation: does nothing, but prevents errors
// In a real environment, this would apply a reverb effect to the sound