/**** * Plugins ****/ var facekit = LK.import("@upit/facekit.v1"); /**** * Classes ****/ //<Write imports for supported plugins here> // Chicken class to represent the player character var Chicken = Container.expand(function () { var self = Container.call(this); var chickenGraphics = self.attachAsset('chicken', { anchorX: 0.5, anchorY: 1 }); // Add a collision element inside the chicken var collisionElement = self.attachAsset('collisionElement', { anchorX: 0.5, anchorY: 0.5, width: chickenGraphics.width * 0.4, height: chickenGraphics.height * 0.2 }); collisionElement.alpha = 1; collisionElement.y = -30; chickenGraphics.y = 50; self.speed = 5; self.jumpHeight = 400; self.isJumping = false; self.jumpVelocity = 0; self.update = function () { self.y += self.jumpVelocity; self.jumpVelocity += 0.5; // Gravity effect if (self.jumpVelocity > 30) { self.jumpVelocity = 30; } var targetPlatform = undefined; var isOnPlatform = platforms.some(function (platform) { if (collisionElement.intersects(platform)) { if (self.y - platform.y < 100) { targetPlatform = platform; return true; } ; } }); if (isOnPlatform && self.jumpVelocity > 0) { // Ground level self.y = targetPlatform.y + 70; self.isJumping = false; self.jumpVelocity = 0; // Reset jump velocity when hitting the ground } self.x = 2048 / 2; // Center the chicken horizontally }; self.jump = function (volume) { var isOnPlatform = platforms.some(function (platform) { if (collisionElement.intersects(platform)) { return self.y - platform.y < 100; } }); if (!self.isJumping && isOnPlatform) { self.isJumping = true; chicken.jumpVelocity = -30 * volume; // Set jump velocity based on volume self.update(); } }; }); // Platform class to represent moving platforms var Platform = Container.expand(function () { var self = Container.call(this); self.moveSpeed = -5; // Base move speed self.moveMultiplier = 1; // Default move multiplier var groundGraphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0 }); self.width = groundGraphics.width; self.update = function () { if (chicken.isJumping) { self.moveMultiplier = 2; } else if (facekit.volume > 0.3) { self.moveMultiplier = facekit.volume * 3; } else { self.moveMultiplier = 0; } self.x += self.moveSpeed * self.moveMultiplier; // If the platform moves off screen to the left, reposition it to the right /*if (self.x < -self.width) { // Reposition the platform to the right with a random gap self.x += self.width + 2048 + Math.random() * 1000; }*/ }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize platforms function addPlatformAt(x, y) { var platform = new Platform(); platform.x = x; //i * 1900 + i * Math.random() * 1000; // Space platforms with gaps platform.y = y; //2200; // Ground level platforms.push(platform); game.addChild(platform); return platform; } var platforms = []; addPlatformAt(1000, 2200); addPlatformAt(3000, 2200); addPlatformAt(5000, 1800); addPlatformAt(7000, 2200); var lastPlatform = addPlatformAt(9000, 1500); var trophy = lastPlatform.attachAsset('trophy', { anchorX: 0.5, anchorY: 0.5, x: lastPlatform.width / 2, y: -100 }); // Initialize chicken //<Write imports for supported plugins here> var volumeText = new Text2('Volume: 0', { size: 100, fill: 0xFFFFFF }); volumeText.anchor.set(0.5, 0); LK.gui.top.addChild(volumeText); var chicken = game.addChild(new Chicken()); Platform.prototype.chicken = chicken; // Make chicken accessible in Platform class chicken.x = 2048 / 2; // Center the chicken horizontally chicken.y = 2200; // Start the chicken at the ground level // Function to handle microphone input function handleMicrophoneInput(volume) { // console.log(volume, volume > 0.9 && !chicken.isJumpin); if (volume > 0.80 && !chicken.isJumping) { chicken.jump(volume); } } // Update game logic game.update = function () { chicken.update(); platforms.forEach(function (platform) { platform.update(); }); // Remove excess platforms if more than 3 exist /*while (platforms.length > 3) { var excessPlatform = platforms.shift(); excessPlatform.destroy(); }*/ handleMicrophoneInput(facekit.volume); // Use facekit to get the volume volumeText.setText('Volume: ' + facekit.volume.toFixed(2)); // Check if the chicken has fallen off the screen if (chicken.y > 3000) { // End the game if the chicken has fallen off the screen LK.showGameOver(); } // Check if the chicken touches the trophy if (chicken.intersects(trophy)) { // End the game with a win if the chicken touches the trophy LK.showYouWin(); } };
===================================================================
--- original.js
+++ change.js
@@ -20,10 +20,11 @@
anchorY: 0.5,
width: chickenGraphics.width * 0.4,
height: chickenGraphics.height * 0.2
});
- collisionElement.alpha = 0;
+ collisionElement.alpha = 1;
collisionElement.y = -30;
+ chickenGraphics.y = 50;
self.speed = 5;
self.jumpHeight = 400;
self.isJumping = false;
self.jumpVelocity = 0;
Golden chicken trophy. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Row of Spikes. Computer Game Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A simple wide hand-drawn symmetrical ribbon banners. The banner text reads “Small bawk to move” in playful, cartoonish black lettering. The ribbon is warm beige parchment. Each side ends with simple curved, scroll-like ribbon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A simple wide hand-drawn symmetrical ribbon banners. The banner text reads “Big BAWK to Jump!” in playful, cartoonish black lettering. The ribbon is warm beige parchment. Each side ends with simple curved, scroll-like ribbon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon-style rectangular speech bubble with a sharp, dynamic outline. Inside the bubble, create the text ‘BAWK’ in bold, vibrant orange-to-yellow gradient lettering, with a thick black jagged shadow for contrast. The text should have a dynamic comic-style font and appear slightly 3D. The bubble should have a sharp tail pointing downward, consistent with comic-style speech bubbles. The intent is that we are shouting "BAWK".. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Simple cartoon whisper speech bubble with text "bawk" lowercase lettering. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows