User prompt
Update with: var DragonHead = Container.expand(function () { var self = Container.call(this); var head = self.attachAsset('dragonHead', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var leftEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -30 }); var rightEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: 50, y: -30 }); // Position smoothing variables self.targetX = 2048 / 2; self.targetY = 2732 * 0.2; self.smoothingFactor = 0.15; // Simplified rotation variables self.currentRotation = 0; self.targetRotation = 0; self.rotationSmoothing = 0.1; self.update = function () { // Position tracking if (facekit.noseTip) { self.targetX = facekit.noseTip.x; self.targetY = facekit.noseTip.y; } // Apply position smoothing self.x += (self.targetX - self.x) * self.smoothingFactor; self.y += (self.targetY - self.y) * self.smoothingFactor; // Fixed rotation calculation with reversed direction if (facekit.leftEye && facekit.rightEye) { // Calculate angle between eyes var dx = facekit.rightEye.x - facekit.leftEye.x; var dy = facekit.rightEye.y - facekit.leftEye.y; // Get the raw angle in radians and negate it to reverse the direction var rawAngle = -Math.atan2(dy, dx); // Limit the rotation to prevent extreme angles (Β±0.3 radians β Β±17 degrees) self.targetRotation = Math.max(-0.3, Math.min(0.3, rawAngle)); // Apply rotation smoothing self.rotation += (self.targetRotation - self.rotation) * self.rotationSmoothing; } }; return self; }); βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Update with: var DragonHead = Container.expand(function () { var self = Container.call(this); var head = self.attachAsset('dragonHead', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var leftEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -30 }); var rightEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: 50, y: -30 }); // Position smoothing variables self.targetX = 2048 / 2; self.targetY = 2732 * 0.2; self.smoothingFactor = 0.15; // Simplified rotation variables self.currentRotation = 0; self.targetRotation = 0; self.rotationSmoothing = 0.1; self.update = function () { // Position tracking if (facekit.noseTip) { self.targetX = facekit.noseTip.x; self.targetY = facekit.noseTip.y; } // Apply position smoothing self.x += (self.targetX - self.x) * self.smoothingFactor; self.y += (self.targetY - self.y) * self.smoothingFactor; // Simplified rotation calculation directly from eye positions if (facekit.leftEye && facekit.rightEye) { // Calculate angle between eyes (simpler approach) var dx = facekit.rightEye.x - facekit.leftEye.x; var dy = facekit.rightEye.y - facekit.leftEye.y; // Get the raw angle in radians var rawAngle = Math.atan2(dy, dx); // Limit the rotation to prevent extreme angles (Β±0.3 radians β Β±17 degrees) self.targetRotation = Math.max(-0.3, Math.min(0.3, rawAngle)); // Apply rotation smoothing self.rotation += (self.targetRotation - self.rotation) * self.rotationSmoothing; // Debug output - uncomment if you have console logging // console.log("Eyes dx/dy:", dx, dy, "Target rotation:", self.targetRotation, "Current rotation:", self.rotation); } }; return self; }); βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Update with: var DragonHead = Container.expand(function () { var self = Container.call(this); var head = self.attachAsset('dragonHead', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var leftEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -30 }); var rightEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: 50, y: -30 }); // Position smoothing variables self.targetX = 2048 / 2; self.targetY = 2732 * 0.2; self.smoothingFactor = 0.15; // Rotation/tilt variables using the provided code approach self.targetTilt = 0; self.tiltSmoothingFactor = 0.11; self.tiltScaleFactor = 0.09; // Calculate face tilt based on eye and mouth positions self.calculateFaceTilt = function() { if (facekit.leftEye && facekit.rightEye && facekit.mouthCenter) { // Calculate midpoint between eyes var eyeMidX = (facekit.leftEye.x + facekit.rightEye.x) / 2; var eyeMidY = (facekit.leftEye.y + facekit.rightEye.y) / 2; // Calculate angle between eye midpoint and mouth, negated to fix direction var dx = facekit.mouthCenter.x - eyeMidX; var dy = facekit.mouthCenter.y - eyeMidY; var angle = -(Math.atan2(dx, dy) * (180 / Math.PI)); // Reduced max angle to Β±15 degrees and lowered multiplier return Math.max(-15, Math.min(15, angle * 0.15)); } return 0; // Default to straight when face points aren't available }; self.update = function () { // Track the nose position instead of mouth if (facekit.noseTip) { // Set target positions based on nose tip self.targetX = facekit.noseTip.x; self.targetY = facekit.noseTip.y; } // Apply smoothing to position self.x += (self.targetX - self.x) * self.smoothingFactor; self.y += (self.targetY - self.y) * self.smoothingFactor; // Apply face tilt calculation for rotation if (facekit.leftEye && facekit.rightEye) { self.targetTilt = self.calculateFaceTilt() * self.tiltScaleFactor; // Reduce max rotation to Β±15 degrees self.targetTilt = Math.max(-15, Math.min(15, self.targetTilt)); // Convert degrees to radians for rotation var targetTiltRadians = self.targetTilt * (Math.PI / 180); self.rotation += (targetTiltRadians - self.rotation) * self.tiltSmoothingFactor; } }; return self; }); βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Update with: var DragonHead = Container.expand(function () { var self = Container.call(this); var head = self.attachAsset('dragonHead', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var leftEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -30 }); var rightEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: 50, y: -30 }); // Position smoothing variables self.targetX = 2048 / 2; // Default center position self.targetY = 2732 * 0.2; self.smoothingFactor = 0.15; // Previous positions for stable rotation calculation self.prevX = self.targetX; self.prevY = self.targetY; // Rotation variables self.targetRotation = 0; self.rotationSmoothingFactor = 0.08; self.maxRotation = Math.PI / 8; // Limit rotation to avoid flipping self.update = function () { // Track the nose position if (facekit.noseTip) { // Store previous position before updating self.prevX = self.x; self.prevY = self.y; // Set target positions based on nose tip self.targetX = facekit.noseTip.x; self.targetY = facekit.noseTip.y; // Limit the rotation calculation to small head movements // Only calculate rotation if we've moved enough to avoid jitter var dx = self.targetX - self.prevX; var dy = self.targetY - self.prevY; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 3) { // Minimum threshold for rotation calculation // Calculate rotation based on movement direction var angle = Math.atan2(dy, dx); // Limit rotation to prevent upside-down dragon var limitedAngle = Math.max(-self.maxRotation, Math.min(self.maxRotation, angle)); self.targetRotation = limitedAngle; } } // Apply smoothing to position self.x += (self.targetX - self.x) * self.smoothingFactor; self.y += (self.targetY - self.y) * self.smoothingFactor; // Apply smoothing to rotation with limits var rotationDiff = self.targetRotation - self.rotation; // Normalize the rotation difference while (rotationDiff > Math.PI) rotationDiff -= Math.PI * 2; while (rotationDiff < -Math.PI) rotationDiff += Math.PI * 2; // Apply smoothed rotation with limiting self.rotation += rotationDiff * self.rotationSmoothingFactor; }; return self; }); βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Update with: var DragonHead = Container.expand(function () { var self = Container.call(this); var head = self.attachAsset('dragonHead', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); var leftEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: -50, y: -30 }); var rightEye = self.attachAsset('dragonEyes', { anchorX: 0.5, anchorY: 0.5, x: 50, y: -30 }); // Position smoothing variables self.targetX = 0; self.targetY = 0; self.smoothingFactor = 0.15; // Adjust for more/less smoothing // Rotation smoothing variables self.targetRotation = 0; self.rotationSmoothingFactor = 0.1; // Adjust for more/less smoothing self.update = function () { // Track the nose position instead of mouth if (facekit.noseTip) { // Set target positions based on nose tip self.targetX = facekit.noseTip.x; self.targetY = facekit.noseTip.y; // Calculate rotation if we have both eyes if (facekit.leftEye && facekit.rightEye) { var dx = facekit.rightEye.x - facekit.leftEye.x; var dy = facekit.rightEye.y - facekit.leftEye.y; self.targetRotation = Math.atan2(dy, dx); } } // Apply smoothing to position self.x += (self.targetX - self.x) * self.smoothingFactor; self.y += (self.targetY - self.y) * self.smoothingFactor; // Apply smoothing to rotation self.rotation += (self.targetRotation - self.rotation) * self.rotationSmoothingFactor; }; return self; }); βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Change the direction of the fireballs, they need to be going down.
Code edit (1 edits merged)
Please save this source code
User prompt
Dragon's Breath
Initial prompt
Hi Ava, we are going to make a FaceKit game that allows players to play as a dragon who opens their mouth to blow fire to defeat enemies that are attacking them. The game will feature a mask of a dragon over the players face, with a body and wings layers behind the face to be animated separately, but they will be pinned to the mask to give the illusion of the full body of a dragon. The dragon will be facing down on the screen and the enemies will have the perspective of running up and into the screen while the dragon blows fire down and out towards the bottom of the screen. When hit with the dragon fire, the enemies will have different animations, like being turned to ash or being sent flying. The game is over when the dragon loses all its life. Score is recorded and high scores are saved.
/**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 });
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
A clear blue sky background with no clouds.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a small bush. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a wooden arrow with red feathers and a metal arrow head. Completely vertical orientation. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A small vertical flame. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a black scorch mark on the ground left by a meteor impact. cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A bright spark. Cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a red heart. cartoon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
An SVG of the word **BOSS** in sharp red font.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
An SVG of the word βStartβ written in fire. Cartoon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows