User prompt
her strike yapıldığında ortadaki engel biraz daha uzasın ve penguenin hızını biraz daha düşür, penguenin ateşe çarpıp yandığı yere başka bir ses eklemek istiyorum
User prompt
penguen yanarken başka bir resim olsun
User prompt
penguen ortada çıkan engele değdiğinde yansın
User prompt
penguen çok hızlı fırlıyor biraz yavaşlatalım
User prompt
eğer ortadaki engele 3 kere çarparsa penguen yanarak ölsün ve yandığı zamanki resmini değiştirebileyim
User prompt
ortada çıkan engel çizgisinin resmini değiştiremiyorum
User prompt
ortadaki çizginin arkasına ışınlanıyor , o şekilde olmasını istemiyorum çizginin bir duvar gibi olduğunu düşün aynı çerçevede olduğu gibi görev görsün ona vurursa penguen geriye seksin ve pengueni biraz yavaşlat çok hızlı gidiyor
User prompt
strike yaptıktan sonra çıkan engel hala geçirgen , o çizgi geçirgen olmasın aynı duvar gibi ona vurulduğunda geri sekilsin
User prompt
ekranın ortasında çıkan engel geçilmez olsun yani duvar gibi ona dokununca penguen seksin
User prompt
penguen mouse ile itme hızımıza göre hızını alsın her seferinde aynı hızda gitmesin örneğin yavaş fırlatırsak yavaş hızlı fırlatırsak hızlı gitsin
User prompt
penguenin hızı biraz yavaşlasın ve engel yatay olarak karşımıza çıksın
User prompt
labutlara sadece önden vurunca yıkılması ister arkadan ister sağdan ister soldan nereden vurursan vur gerçek fizik kurallarına uygun olarak yıkılsınlar , her levelde labutların arasının açılması mekaniğini iptal et yen bir mekanik ekliyoruz her strike yapışta ekranın ortasında ya sağdan ya da soldan bir engel çıksın ve bu engelin olmadığı boş alandan pengueni atıp labutları yıkabilelim ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
eğer penguen duvardan sekerek labutlara gelirse de labutları yıkabilsin
User prompt
eğer strike yapamazsa labutlar sıfırdan dizilmesin kaldığı yerden devam etsin
User prompt
penguenin hızını biraz arttır bu sefer hiç gitmiyor
User prompt
penguenin sürtünme hızı daha biraz daha yavaşlasın gerçek bir buzun üzerinde kayıyomuş hissiyatı versin, oyuncu her strike yaptığında labutlar etrafa daha fazla açılsın ve vurması zorlaşsın 2 kere strike yapamazsa game over olsun ve oyun tekrar başlasın
User prompt
labutların arasını biraz daha aç ve penguen çarpar çarpmaz hepsi yıkılmasın gerçek fizik kurallarına uygun yıkılsınlar , duvardan çarptırarak atarsan daha fazla puan versin
User prompt
When the penguin hits the wall, calculate the reflection vector based on a 90-degree bounce logic and apply reduced velocity. The penguin should continue moving in that new direction.
User prompt
The light blue area should also act like a wall, and when the penguin hits it, it should bounce off.
User prompt
Make the entire frame of the game act like a wall, so that when the penguin hits it, it bounces off.
User prompt
The edges should be walls, but when the penguin hits them, its speed should decrease, and it should continue moving at a perfect 90-degree angle.
User prompt
Only the front pins should fall over, and there should be a mechanic where the pins disappear by colliding with each other. If the penguin goes straight, it should knock all the pins over.
User prompt
When the penguin is released, at the maximum speed, it should definitely reach the pins. However, if it is thrown more slowly, it shouldn't reach the pins.
User prompt
The penguin should move a bit faster, and the arrow should be removed. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
The arrow should start from where the penguin is being held, and the farther I pull the penguin, the farther it should be launched.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0 }); /**** * Classes ****/ var AimArrow = Container.expand(function () { var self = Container.call(this); // Create arrow components var arrowLine = self.attachAsset('aimLine', { anchorX: 0.5, anchorY: 1.0, width: 10, height: 150 }); // Set initial visibility self.visible = false; // Update arrow position and rotation based on angle self.updateArrow = function (startX, startY, angle) { self.x = startX; self.y = startY; self.rotation = angle; self.visible = true; }; self.hide = function () { self.visible = false; }; return self; }); var BowlingPin = Container.expand(function () { var self = Container.call(this); var pinGraphics = self.attachAsset('bowlingPin', { anchorX: 0.5, anchorY: 0.5 }); self.isKnockedDown = false; self.velocityX = 0; self.velocityY = 0; self.friction = 0.95; self.lastX = 0; self.lastY = 0; self.row = 0; // Store which row this pin belongs to self.knockDown = function () { if (!self.isKnockedDown) { self.isKnockedDown = true; // More realistic physical response based on pin position and row // Front pins fall backward, back pins fall forward var directionModifier = self.row < 3 ? 1 : -1; // Add horizontal randomness self.velocityX = (Math.random() - 0.5) * 8; // Add vertical velocity based on row position self.velocityY = directionModifier * (Math.random() * 3 + 2); LK.getSound('pinHit').play(); return true; } return false; }; self.update = function () { // Store last position for collision detection self.lastX = self.x; self.lastY = self.y; if (self.isKnockedDown) { // Apply velocity self.x += self.velocityX; self.y += self.velocityY; // Apply friction self.velocityX *= self.friction; self.velocityY *= self.friction; // More realistic falling behavior - pins rotate more when moving faster var rotationSpeed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.03; pinGraphics.rotation += Math.min(rotationSpeed, 0.15); // Slower fade out for more realistic pin falling pinGraphics.alpha *= 0.985; // Remove from game when almost invisible if (pinGraphics.alpha < 0.1) { self.visible = false; } } }; self.reset = function () { self.isKnockedDown = false; self.velocityX = 0; self.velocityY = 0; pinGraphics.rotation = 0; pinGraphics.alpha = 1; self.visible = true; }; return self; }); var Penguin = Container.expand(function () { var self = Container.call(this); var penguinGraphics = self.attachAsset('penguin', { anchorX: 0.5, anchorY: 0.5 }); // Physics properties self.velocityX = 0; self.velocityY = 0; self.friction = 0.95; // Reduced ice friction for more realistic sliding self.active = false; self.hasCollided = false; self.pullDistance = 0; // Store the pull distance for power calculation self.launch = function (angle, power) { // Scale speed so that only at max power (MAX_POWER) will it reach the pins // Lower power values will result in the penguin not reaching the pins var speedMultiplier = power / MAX_POWER; // Normalize based on max power var baseSpeed = 25; // Minimum speed needed to move var reachPinsSpeed = 40; // Speed needed to reach pins var maxSpeed = baseSpeed + (reachPinsSpeed - baseSpeed) * speedMultiplier; self.velocityX = Math.cos(angle) * maxSpeed; self.velocityY = Math.sin(angle) * maxSpeed; // Special case for throwing straight - make sure it reaches pins at max power if (Math.abs(Math.cos(angle)) < 0.2 && Math.sin(angle) < -0.8 && speedMultiplier > 0.9) { // Adjust vertical speed to ensure it reaches the pins self.velocityY = -reachPinsSpeed; } self.active = true; self.hasCollided = false; LK.getSound('slide').play(); }; self.update = function () { if (!self.active) return; // Apply velocity self.x += self.velocityX; self.y += self.velocityY; // Apply friction self.velocityX *= self.friction; self.velocityY *= self.friction; // Slight rotation effect for realism penguinGraphics.rotation += self.velocityX * 0.01; // Stop if velocity is very small if (Math.abs(self.velocityX) < 0.1 && Math.abs(self.velocityY) < 0.1) { self.active = false; self.velocityX = 0; self.velocityY = 0; } // Frame boundary checks with proper reflection vectors // Left boundary if (self.x < 0) { self.x = 0; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityX = -self.velocityX * 0.8; // Reverse X direction with reduced speed // If X velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityX) < 0.5) { self.velocityX = 0; // Perfect 90 degrees means no horizontal movement self.velocityY = self.velocityY > 0 ? speed : -speed; // Maintain vertical direction } // Award wall bounce bonus if active and hasn't collided yet if (self.active && !self.hasCollided) { self.wallBounceCount = self.wallBounceCount || 0; self.wallBounceCount++; } } // Right boundary else if (self.x > 2048) { self.x = 2048; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityX = -self.velocityX * 0.8; // Reverse X direction with reduced speed // If X velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityX) < 0.5) { self.velocityX = 0; // Perfect 90 degrees means no horizontal movement self.velocityY = self.velocityY > 0 ? speed : -speed; // Maintain vertical direction } } // Top boundary if (self.y < 0) { self.y = 0; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityY = -self.velocityY * 0.8; // Reverse Y direction with reduced speed // If Y velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityY) < 0.5) { self.velocityY = 0; // Perfect 90 degrees means no vertical movement self.velocityX = self.velocityX > 0 ? speed : -speed; // Maintain horizontal direction } } // Bottom boundary if (self.y > 2732) { self.y = 2732; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityY = -self.velocityY * 0.8; // Reverse Y direction with reduced speed // If Y velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityY) < 0.5) { self.velocityY = 0; // Perfect 90 degrees means no vertical movement self.velocityX = self.velocityX > 0 ? speed : -speed; // Maintain horizontal direction } } // Bowling lane boundary checks (light blue area) // Calculate bowling lane boundaries var laneLeftBoundary = bowlingLane.x - bowlingLane.width / 2; var laneRightBoundary = bowlingLane.x + bowlingLane.width / 2; var laneTopBoundary = bowlingLane.y; var laneBottomBoundary = bowlingLane.y + bowlingLane.height; // Check if penguin is outside the lane but not outside the game boundaries // Left lane boundary if (self.x < laneLeftBoundary && self.x > 0) { self.x = laneLeftBoundary; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityX = -self.velocityX * 0.8; // Reverse X direction with reduced speed // If X velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityX) < 0.5) { self.velocityX = 0; self.velocityY = self.velocityY > 0 ? speed : -speed; } } // Right lane boundary else if (self.x > laneRightBoundary && self.x < 2048) { self.x = laneRightBoundary; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityX = -self.velocityX * 0.8; // Reverse X direction with reduced speed // If X velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityX) < 0.5) { self.velocityX = 0; self.velocityY = self.velocityY > 0 ? speed : -speed; } } // Top lane boundary if (self.y < laneTopBoundary && self.y > 0) { self.y = laneTopBoundary; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityY = -self.velocityY * 0.8; // Reverse Y direction with reduced speed // If Y velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityY) < 0.5) { self.velocityY = 0; self.velocityX = self.velocityX > 0 ? speed : -speed; } } // Bottom lane boundary if (self.y > laneBottomBoundary && self.y < 2732) { self.y = laneBottomBoundary; // Calculate reflection vector for a 90-degree bounce with reduced speed var speed = Math.sqrt(self.velocityX * self.velocityX + self.velocityY * self.velocityY) * 0.8; self.velocityY = -self.velocityY * 0.8; // Reverse Y direction with reduced speed // If Y velocity is very small, set to zero for perfect 90-degree bounce if (Math.abs(self.velocityY) < 0.5) { self.velocityY = 0; self.velocityX = self.velocityX > 0 ? speed : -speed; } } }; self.reset = function () { self.x = launchArea.x; self.y = launchArea.y - 250; // Move penguin further up the lane self.velocityX = 0; self.velocityY = 0; self.active = false; self.hasCollided = false; self.pullDistance = 0; // Reset pull distance self.wallBounceCount = 0; // Reset wall bounce counter penguinGraphics.rotation = 0; }; return self; }); var PowerMeter = Container.expand(function () { var self = Container.call(this); var meterBG = self.attachAsset('powerMeterBG', { anchorX: 0.5, anchorY: 0.5 }); var meter = self.attachAsset('powerMeter', { anchorX: 0.5, anchorY: 1.0, height: 0 // Start with no power }); var maxPower = 300; self.power = 0; self.increasing = true; self.update = function () { if (self.visible) { if (self.increasing) { self.power += 5; if (self.power >= maxPower) { self.power = maxPower; self.increasing = false; } } else { self.power -= 5; if (self.power <= 0) { self.power = 0; self.increasing = true; } } // Update meter height based on power meter.height = self.power; meter.y = meterBG.y + meterBG.height / 2 - meter.height / 2; } }; self.getPowerRatio = function () { return self.power / maxPower; }; self.reset = function () { self.power = 0; self.increasing = true; meter.height = 0; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xC7E6F7 }); /**** * Game Code ****/ // Game constants var MAX_POWER = 20; var PIN_ROWS = 4; var FRAMES = 10; var PINS_PER_FRAME = 10; // Game state variables var currentFrame = 1; var pinsKnockedDown = 0; var totalScore = 0; var aiming = false; var powering = false; var gameState = "aiming"; // States: aiming, powering, sliding, scoring, gameover var aimAngle = -Math.PI / 2; // Start aiming straight up var consecutiveFailedStrikes = 0; // Track consecutive failures to get a strike var pinSpacingMultiplier = 1.0; // Controls pin spacing based on strikes // Create background var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); // Create bowling lane var bowlingLane = game.addChild(LK.getAsset('bowlingLane', { anchorX: 0.5, anchorY: 0, x: 2048 / 2, y: 100 })); // Create launch area var launchArea = game.addChild(LK.getAsset('launchArea', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2400 })); // Create the aiming line var aimLine = game.addChild(LK.getAsset('aimLine', { anchorX: 0.5, anchorY: 1.0, x: launchArea.x, y: launchArea.y, visible: false })); // Arrow removed as requested // Create the power meter var powerMeter = game.addChild(new PowerMeter()); powerMeter.x = 1900; powerMeter.y = 1400; powerMeter.visible = false; // Create the penguin var penguin = game.addChild(new Penguin()); penguin.x = launchArea.x; penguin.y = launchArea.y - 250; // Move penguin further up the lane // Create bowling pins var pins = []; setupPins(); // Create UI elements var frameText = new Text2('Frame: 1/10', { size: 70, fill: 0x000000 }); frameText.anchor.set(0.5, 0); // Position frame text under the penguin's position frameText.y = penguin.y + 150; LK.gui.center.addChild(frameText); var scoreText = new Text2('Score: 0', { size: 70, fill: 0x000000 }); scoreText.anchor.set(0.5, 0); scoreText.y = 80; LK.gui.top.addChild(scoreText); var instructionText = new Text2('Tap and drag to pull penguin back, release to launch', { size: 50, fill: 0x000000 }); instructionText.anchor.set(0.5, 0); instructionText.y = 180; LK.gui.top.addChild(instructionText); // Helper functions function setupPins() { // Clear any existing pins for (var i = 0; i < pins.length; i++) { pins[i].destroy(); } pins = []; // Create pin layout in traditional bowling triangle formation // Ensure pins are exactly centered on the lane var startX = 2048 / 2; // Center of screen var startY = 400; // Position from top var pinSpacingX = 120 * pinSpacingMultiplier; // Increased horizontal spacing based on multiplier var pinSpacingY = 120 * pinSpacingMultiplier; // Increased vertical spacing based on multiplier // Standard bowling pin layout (4-3-2-1 triangle) // First row (back) - 4 pins for (var i = 0; i < 4; i++) { var pin = new BowlingPin(); pin.x = startX + (i - 1.5) * pinSpacingX; // Perfectly centered pin.y = startY; pin.row = 1; // Back row pin.lastX = pin.x; pin.lastY = pin.y; pins.push(pin); game.addChild(pin); } // Second row - 3 pins for (var i = 0; i < 3; i++) { var pin = new BowlingPin(); pin.x = startX + (i - 1) * pinSpacingX; // Centered relative to first row pin.y = startY + pinSpacingY; pin.row = 2; // Second row pin.lastX = pin.x; pin.lastY = pin.y; pins.push(pin); game.addChild(pin); } // Third row - 2 pins for (var i = 0; i < 2; i++) { var pin = new BowlingPin(); pin.x = startX + (i - 0.5) * pinSpacingX; // Centered relative to second row pin.y = startY + 2 * pinSpacingY; pin.row = 3; // Third row pin.lastX = pin.x; pin.lastY = pin.y; pins.push(pin); game.addChild(pin); } // Fourth row (front) - 1 pin var pin = new BowlingPin(); pin.x = startX; // Center pin pin.y = startY + 3 * pinSpacingY; pin.row = 4; // Front row pin.lastX = pin.x; pin.lastY = pin.y; pins.push(pin); game.addChild(pin); pinsKnockedDown = 0; } function updateAimLine() { aimLine.rotation = aimAngle; // Ensure the aim line points from the penguin position aimLine.x = launchArea.x; aimLine.y = launchArea.y; } function launchPenguin() { // Calculate power based on the pull distance var powerRatio = Math.min(penguin.pullDistance / 300, 1); // Normalize based on max drag distance var power = powerRatio * MAX_POWER; // Launch penguin from current position toward the launch area var launchAngle = aimAngle + Math.PI; // Reverse the angle to launch toward the pins penguin.launch(launchAngle, power); gameState = "sliding"; powerMeter.visible = false; // Update instruction text based on power and difficulty var difficultyMsg = pinSpacingMultiplier > 1.0 ? " - Difficulty: " + Math.round((pinSpacingMultiplier - 1) * 100) + "%" : ""; if (powerRatio >= 0.9) { instructionText.setText("Full power! Watch the penguin slide!" + difficultyMsg); } else { instructionText.setText("Watch the penguin slide! (Power: " + Math.round(powerRatio * 100) + "%)" + difficultyMsg); } } function checkCollisions() { if (!penguin.active || penguin.hasCollided) return; var newKnockdowns = 0; // First, check penguin collision with front pins only for (var i = 0; i < pins.length; i++) { var pin = pins[i]; // Calculate penguin velocity magnitude for physics-based knockdown var penguinSpeed = Math.sqrt(penguin.velocityX * penguin.velocityX + penguin.velocityY * penguin.velocityY); var isPenguinGoingStraight = Math.abs(penguin.velocityX) < 3 && penguin.velocityY < 0; // Only front row pins are directly knocked down, unless the penguin is thrown straight // with sufficient force to reach back rows var isTargetablePin = pin.row === 4 || isPenguinGoingStraight && penguinSpeed > 25 && pin.row === 3 || isPenguinGoingStraight && penguinSpeed > 35; if (!pin.isKnockedDown && isTargetablePin && penguin.intersects(pin)) { if (pin.knockDown()) { newKnockdowns++; pinsKnockedDown++; // Update score totalScore += 1; updateScoreDisplay(); } } } // Now check for pin-to-pin collisions between ALL pins for (var i = 0; i < pins.length; i++) { var pin = pins[i]; if (pin.isKnockedDown && (Math.abs(pin.velocityX) > 0.5 || Math.abs(pin.velocityY) > 0.5)) { // This pin is moving and can cause collisions for (var j = 0; j < pins.length; j++) { if (i !== j && !pins[j].isKnockedDown && pin.intersects(pins[j])) { // This pin collided with another pin if (pins[j].knockDown()) { pinsKnockedDown++; totalScore += 1; updateScoreDisplay(); } } } } } if (newKnockdowns > 0) { penguin.hasCollided = true; // Play strike sound if all pins are knocked down if (pinsKnockedDown === PINS_PER_FRAME) { LK.getSound('strike').play(); LK.effects.flashScreen(0xFFFFFF, 500); instructionText.setText("STRIKE!"); } } } function updateScoreDisplay() { scoreText.setText("Score: " + totalScore); // Update high score if needed if (totalScore > storage.highScore) { storage.highScore = totalScore; } } function nextFrame() { // Check if player got a strike var isStrike = pinsKnockedDown === PINS_PER_FRAME; // Update consecutive fails counter and spacing multiplier if (isStrike) { consecutiveFailedStrikes = 0; // Increase pin spacing for added difficulty after a strike pinSpacingMultiplier += 0.15; // Cap the multiplier to prevent pins from going off-screen pinSpacingMultiplier = Math.min(pinSpacingMultiplier, 2.0); instructionText.setText("Pins are spreading out! Next throw will be more challenging!"); } else { consecutiveFailedStrikes++; // Check for game over condition (2 consecutive failed strikes) if (consecutiveFailedStrikes >= 2) { gameState = "gameover"; instructionText.setText("Game Over! 2 consecutive misses! Final Score: " + totalScore); // Show game over screen after a brief delay LK.setTimeout(function () { LK.showGameOver(); }, 2000); return; } } currentFrame++; if (currentFrame > FRAMES) { // Game over gameState = "gameover"; instructionText.setText("Game Over! Final Score: " + totalScore); // Show game over screen after a brief delay LK.setTimeout(function () { LK.showGameOver(); }, 2000); } else { // Setup for next frame frameText.setText("Frame: " + currentFrame + "/10"); setupPins(); penguin.reset(); gameState = "aiming"; instructionText.setText("Tap and drag backward to aim, release to launch"); } } function checkGameStateTransition() { if (gameState === "sliding") { // Check if penguin has stopped if (!penguin.active) { // Add wall bounce bonus if any if (penguin.wallBounceCount && penguin.wallBounceCount > 0) { var bounceBonus = penguin.wallBounceCount * 2; totalScore += bounceBonus; instructionText.setText("Nice trick shot! +" + bounceBonus + " bonus points!"); updateScoreDisplay(); } // Wait a bit for pins to settle and then move to next frame LK.setTimeout(function () { nextFrame(); }, 2000); gameState = "scoring"; } } } // Event handlers game.down = function (x, y, obj) { if (gameState === "aiming") { aiming = true; aimLine.visible = false; // Store original penguin position penguin.originalX = penguin.x; penguin.originalY = penguin.y; } }; game.move = function (x, y, obj) { if (aiming) { // Calculate aim angle from penguin to opposite of pull direction var dx = launchArea.x - x; var dy = launchArea.y - y; // Calculate the distance of the pull for power var distance = Math.sqrt(dx * dx + dy * dy); // Limit the maximum drag distance var maxDrag = 300; distance = Math.min(distance, maxDrag); // Calculate the angle aimAngle = Math.atan2(dy, dx); // Move the penguin to the drag position penguin.x = launchArea.x - Math.cos(aimAngle) * distance; penguin.y = launchArea.y - Math.sin(aimAngle) * distance; // Store the pull distance for calculating power later penguin.pullDistance = distance; } }; game.up = function (x, y, obj) { if (aiming) { aiming = false; // Only launch if penguin was actually pulled back if (penguin.pullDistance > 10) { // Launch immediately after release launchPenguin(); } else { // Reset penguin position if not pulled back enough penguin.x = penguin.originalX; penguin.y = penguin.originalY; } } }; // Game update loop game.update = function () { if (gameState === "sliding") { penguin.update(); // Update pin physics for (var i = 0; i < pins.length; i++) { pins[i].update(); } checkCollisions(); // Check for pin-to-pin collisions even after penguin has finished moving if (penguin.hasCollided) { for (var i = 0; i < pins.length; i++) { var pin1 = pins[i]; if (pin1.isKnockedDown && pin1.visible && (Math.abs(pin1.velocityX) > 0.5 || Math.abs(pin1.velocityY) > 0.5)) { for (var j = 0; j < pins.length; j++) { var pin2 = pins[j]; if (i !== j && !pin2.isKnockedDown && pin2.visible && pin1.intersects(pin2)) { if (pin2.knockDown()) { pinsKnockedDown++; totalScore++; updateScoreDisplay(); } } } } } } checkGameStateTransition(); } }; // Initialize variables and start the game consecutiveFailedStrikes = 0; pinSpacingMultiplier = 1.0; // Show initial instructions instructionText.setText("Tap and drag backward to aim, release to launch. 2 misses = Game Over!"); // Start background music LK.playMusic('gameMusic'); ;
===================================================================
--- original.js
+++ change.js
@@ -100,9 +100,9 @@
});
// Physics properties
self.velocityX = 0;
self.velocityY = 0;
- self.friction = 0.98; // Ice friction
+ self.friction = 0.95; // Reduced ice friction for more realistic sliding
self.active = false;
self.hasCollided = false;
self.pullDistance = 0; // Store the pull distance for power calculation
self.launch = function (angle, power) {
@@ -329,8 +329,10 @@
var aiming = false;
var powering = false;
var gameState = "aiming"; // States: aiming, powering, sliding, scoring, gameover
var aimAngle = -Math.PI / 2; // Start aiming straight up
+var consecutiveFailedStrikes = 0; // Track consecutive failures to get a strike
+var pinSpacingMultiplier = 1.0; // Controls pin spacing based on strikes
// Create background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0,
anchorY: 0
@@ -403,10 +405,10 @@
// Create pin layout in traditional bowling triangle formation
// Ensure pins are exactly centered on the lane
var startX = 2048 / 2; // Center of screen
var startY = 400; // Position from top
- var pinSpacingX = 120; // Increased horizontal spacing
- var pinSpacingY = 120; // Increased vertical spacing
+ var pinSpacingX = 120 * pinSpacingMultiplier; // Increased horizontal spacing based on multiplier
+ var pinSpacingY = 120 * pinSpacingMultiplier; // Increased vertical spacing based on multiplier
// Standard bowling pin layout (4-3-2-1 triangle)
// First row (back) - 4 pins
for (var i = 0; i < 4; i++) {
var pin = new BowlingPin();
@@ -465,13 +467,14 @@
var launchAngle = aimAngle + Math.PI; // Reverse the angle to launch toward the pins
penguin.launch(launchAngle, power);
gameState = "sliding";
powerMeter.visible = false;
- // Update instruction text based on power
+ // Update instruction text based on power and difficulty
+ var difficultyMsg = pinSpacingMultiplier > 1.0 ? " - Difficulty: " + Math.round((pinSpacingMultiplier - 1) * 100) + "%" : "";
if (powerRatio >= 0.9) {
- instructionText.setText("Full power! Watch the penguin slide!");
+ instructionText.setText("Full power! Watch the penguin slide!" + difficultyMsg);
} else {
- instructionText.setText("Watch the penguin slide! (Power: " + Math.round(powerRatio * 100) + "%)");
+ instructionText.setText("Watch the penguin slide! (Power: " + Math.round(powerRatio * 100) + "%)" + difficultyMsg);
}
}
function checkCollisions() {
if (!penguin.active || penguin.hasCollided) return;
@@ -529,8 +532,31 @@
storage.highScore = totalScore;
}
}
function nextFrame() {
+ // Check if player got a strike
+ var isStrike = pinsKnockedDown === PINS_PER_FRAME;
+ // Update consecutive fails counter and spacing multiplier
+ if (isStrike) {
+ consecutiveFailedStrikes = 0;
+ // Increase pin spacing for added difficulty after a strike
+ pinSpacingMultiplier += 0.15;
+ // Cap the multiplier to prevent pins from going off-screen
+ pinSpacingMultiplier = Math.min(pinSpacingMultiplier, 2.0);
+ instructionText.setText("Pins are spreading out! Next throw will be more challenging!");
+ } else {
+ consecutiveFailedStrikes++;
+ // Check for game over condition (2 consecutive failed strikes)
+ if (consecutiveFailedStrikes >= 2) {
+ gameState = "gameover";
+ instructionText.setText("Game Over! 2 consecutive misses! Final Score: " + totalScore);
+ // Show game over screen after a brief delay
+ LK.setTimeout(function () {
+ LK.showGameOver();
+ }, 2000);
+ return;
+ }
+ }
currentFrame++;
if (currentFrame > FRAMES) {
// Game over
gameState = "gameover";
@@ -639,6 +665,12 @@
}
checkGameStateTransition();
}
};
+// Initialize variables and start the game
+consecutiveFailedStrikes = 0;
+pinSpacingMultiplier = 1.0;
+// Show initial instructions
+instructionText.setText("Tap and drag backward to aim, release to launch. 2 misses = Game Over!");
// Start background music
-LK.playMusic('gameMusic');
\ No newline at end of file
+LK.playMusic('gameMusic');
+;
\ No newline at end of file
A cartoon-style penguin lying flat on its belly, facing forward with its body stretched out. In-Game asset. 2d. High contrast. No shadows
Bowling pin. In-Game asset. 2d. High contrast. No shadows
iglo. In-Game asset. 2d. High contrast. No shadows
Icy surface. In-Game asset. 2d. High contrast. No shadows
Snow gently falling from the sky in a peaceful winter scene. The snowflakes are soft and light, creating a calm atmosphere. The snow is falling in large, delicate flakes, covering the icy surface and creating a serene, magical ambiance.". In-Game asset. 2d. High contrast. No shadows
horizontal fire. In-Game asset. 2d. High contrast. No shadows
pişmiş tavuk. In-Game asset. 2d. High contrast. No shadows