User prompt
Remove all duplicate code
User prompt
Remove all duplicate code
User prompt
Prevent chicken being stuck on ropes
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'scaleY' in undefined' in or related to this line: 'tween(self, {' Line Number: 1078 βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading '__colorFlash_current_tick')' in or related to this line: 'LK.effects.flashObject(self, flashIntensity, 200);' Line Number: 1108
User prompt
Please fix the bug: 'ReferenceError: speed is not defined' in or related to this line: 'var flashIntensity = Math.min(0xFFFFFF, 0xFFFFFF * (speed / 30));' Line Number: 1106
User prompt
Please fix the bug: 'ReferenceError: speed is not defined' in or related to this line: 'var flashIntensity = Math.min(0xFFFFFF, 0xFFFFFF * (speed / 30));' Line Number: 1104
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'x')' in or related to this line: 'var originalX = self.x;' Line Number: 1060
User prompt
Please fix the bug: 'ReferenceError: originalX is not defined' in or related to this line: 'tween(self, {' Line Number: 1060
User prompt
Ensure the bottom rope maintains its position
User prompt
Move bottom rope up 100
User prompt
Make bottom rope animation work like the other ropes
User prompt
Reset high score βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Change launch method to slingshot βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Remove all bounce dynamics change launch techniques to slingshot
User prompt
Redo bounce physics.. remove all bounce elements
User prompt
Add gravity
User prompt
I just want standard simple bounce of rope logic
User prompt
Stop bonus text animation βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Stop somersaults animation βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Slow chicken speed down
User prompt
Fix all the problems and make the game work good
User prompt
Hitting corner makes chicken stop
User prompt
Activate no gravity
User prompt
Add enhanced emergency escape mechanism to detect and free chicken from rope intersections
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var ChickenJockey = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach chicken asset
	var chickenGraphics = self.attachAsset('chicken', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Physics properties
	self.vx = 0;
	self.vy = 0;
	self.gravity = 0.5;
	self.bounceDecay = 0.7; // Reduced bounce decay for more sustained bounces
	self.friction = 0.998; // Increased horizontal friction for less horizontal drift
	self.launched = false;
	self.bounceCount = 0;
	self.maxBounces = 5; // Allow 5 bounces per swipe
	self.lastBouncePosition = {
		x: 0,
		y: 0
	}; // Track last bounce position to prevent getting stuck
	// Score multiplier based on somersaults
	self.scoreMultiplier = 1;
	self.scoreMultiplierText = null;
	// Rotation properties
	self.rotationSpeed = 0;
	self.somersaulting = false;
	self.somersaultRotation = 0;
	self.somersaultDirection = 1; // 1 for clockwise, -1 for counter-clockwise
	self.launch = function (startX, startY, endX, endY) {
		// Calculate direction vector
		var dx = startX - endX;
		var dy = startY - endY;
		// Calculate distance for power
		var distance = Math.sqrt(dx * dx + dy * dy);
		// Scale power based on distance (capped for balance)
		var power = Math.min(distance, 300) * 0.15;
		// Calculate angle in radians
		var angle = Math.atan2(dy, dx);
		// Set initial velocity based on power and angle
		self.vx = Math.cos(angle) * power;
		self.vy = Math.sin(angle) * power;
		// Set rotation speed based on velocity
		self.rotationSpeed = power / 50;
		self.launched = true;
		self.bounceCount = 0;
		// Play launch sound
		LK.getSound('launch').play();
	};
	self.reset = function () {
		self.vx = 0;
		self.vy = 0;
		self.rotation = 0;
		self.rotationSpeed = 0;
		self.launched = false;
		self.bounceCount = 0;
		self.maxBounces = 300; // Set the max bounces here too
		self.somersaulting = false;
		self.somersaultRotation = 0;
		self.rewardedFreeLaunch = false; // Track if we've already given free launch reward
		self.scoreMultiplier = 1; // Reset score multiplier
		// Remove multiplier text if it exists
		if (self.scoreMultiplierText && self.scoreMultiplierText.parent) {
			self.scoreMultiplierText.parent.removeChild(self.scoreMultiplierText);
			self.scoreMultiplierText = null;
		}
		// Reset the chicken graphic rotation
		var chickenGraphics = self.getChildAt(0);
		if (chickenGraphics) {
			chickenGraphics.rotation = 0;
		}
	};
	self.update = function () {
		if (!self.launched) {
			return;
		}
		// Apply physics with speed limiting
		self.vy += self.gravity;
		// Cap maximum velocity to prevent freezing
		var maxSpeed = 30;
		self.vx = Math.max(-maxSpeed, Math.min(maxSpeed, self.vx));
		self.vy = Math.max(-maxSpeed, Math.min(maxSpeed, self.vy));
		self.x += self.vx;
		self.y += self.vy;
		self.vx *= self.friction;
		// Apply rotation with speed limiting
		self.rotationSpeed = Math.max(-0.2, Math.min(0.2, self.rotationSpeed));
		self.rotation += self.rotationSpeed;
		// Update score multiplier based on somersaults (1x for 0 somersaults, +0.5x per somersault)
		var newMultiplier = 1 + Math.min(10, self.bounceCount) * 0.5;
		if (newMultiplier !== self.scoreMultiplier) {
			self.scoreMultiplier = newMultiplier;
			// Create or update multiplier text
			if (!self.scoreMultiplierText) {
				self.scoreMultiplierText = new Text2("x" + self.scoreMultiplier.toFixed(1), {
					size: 60,
					fill: 0xFFFF00
				});
				self.scoreMultiplierText.anchor.set(0.5, 1);
				self.addChild(self.scoreMultiplierText);
			} else {
				self.scoreMultiplierText.setText("x" + self.scoreMultiplier.toFixed(1));
			}
			// Animate multiplier change
			if (self.bounceCount > 0) {
				self.scoreMultiplierText.alpha = 1;
				tween.stop(self.scoreMultiplierText);
				self.scoreMultiplierText.scaleX = 1.5;
				self.scoreMultiplierText.scaleY = 1.5;
				tween(self.scoreMultiplierText, {
					scaleX: 1,
					scaleY: 1
				}, {
					duration: 300,
					easing: tween.elasticOut
				});
			}
		}
		// Position the multiplier text above the chicken
		if (self.scoreMultiplierText) {
			self.scoreMultiplierText.y = -60;
		}
		// Keep chicken within arena boundaries
		if (self.x < bounds.left) {
			self.x = bounds.left;
			self.vx = -self.vx * self.bounceDecay;
			// Flip chicken when hitting arena boundary
			var chickenGraphics = self.getChildAt(0);
			if (chickenGraphics.scaleX !== 1) {
				// Start somersault animation
				self.somersaulting = true;
				self.somersaultDirection = -1;
				tween.stop(chickenGraphics); // Stop any existing rotation animations
				tween(chickenGraphics, {
					rotation: -Math.PI * 2
				}, {
					duration: 600,
					easing: tween.easeOut,
					onFinish: function onFinish() {
						chickenGraphics.rotation = 0;
						chickenGraphics.scaleX = 1; // Facing left
						self.somersaulting = false;
					}
				});
			}
		} else if (self.x > bounds.right) {
			self.x = bounds.right;
			self.vx = -self.vx * self.bounceDecay;
			// Flip chicken when hitting arena boundary
			var chickenGraphics = self.getChildAt(0);
			if (chickenGraphics.scaleX !== -1) {
				// Start somersault animation
				self.somersaulting = true;
				self.somersaultDirection = 1;
				tween.stop(chickenGraphics); // Stop any existing rotation animations
				tween(chickenGraphics, {
					rotation: Math.PI * 2
				}, {
					duration: 600,
					easing: tween.easeOut,
					onFinish: function onFinish() {
						chickenGraphics.rotation = 0;
						chickenGraphics.scaleX = -1; // Facing right
						self.somersaulting = false;
					}
				});
			}
		}
		if (self.y < bounds.top) {
			self.y = bounds.top;
			self.vy = -self.vy * self.bounceDecay;
		} else if (self.y > bounds.bottom) {
			self.y = bounds.bottom;
			self.vy = -self.vy * self.bounceDecay;
		}
		// Check if stopped
		if (Math.abs(self.vx) < 0.5 && Math.abs(self.vy) < 0.5 && self.bounceCount > 0) {
			self.launched = false;
			// Notify game that chicken jockey has stopped
			if (typeof game.onChickenJockeyStop === 'function') {
				game.onChickenJockeyStop();
			}
		}
		// Bounce from side to side
		if (self.x <= bounds.left || self.x >= bounds.right) {
			self.vx = -self.vx * self.bounceDecay;
			self.bounceCount++;
			LK.getSound('bounce').play();
			game.addScore(2000);
		}
		// Check if reached 10 somersaults and reward the player
		if (self.bounceCount >= 10 && !self.rewardedFreeLaunch) {
			self.rewardedFreeLaunch = true;
			// Award free launch
			if (typeof game.onFreeLaunchEarned === 'function') {
				game.onFreeLaunchEarned();
			}
		}
		// Check if max bounces reached
		if (self.bounceCount >= self.maxBounces) {
			self.launched = false;
			// Notify game that max bounces reached
			if (typeof game.onMaxBouncesReached === 'function') {
				game.onMaxBouncesReached();
			}
		}
	};
	return self;
});
var HighScoreTally = Container.expand(function () {
	var self = Container.call(this);
	// Background container
	var background = self.attachAsset('Hiscorebackdrop', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	background.width = 1400;
	background.height = 1200;
	background.alpha = 0.8;
	// Title text
	var titleText = new Text2("HIGH SCORES", {
		size: 100,
		fill: 0xFFD700
	});
	titleText.anchor.set(0.5, 0);
	titleText.y = -background.height / 2 + 100;
	self.addChild(titleText);
	// Score entries container
	var scoreEntries = [];
	self.updateScores = function (highScores) {
		// Clear existing entries
		for (var i = 0; i < scoreEntries.length; i++) {
			if (scoreEntries[i].parent) {
				scoreEntries[i].parent.removeChild(scoreEntries[i]);
			}
		}
		scoreEntries = [];
		// Create new entries
		var startY = -background.height / 2 + 250;
		var padding = 80;
		for (var i = 0; i < highScores.length && i < 5; i++) {
			var entry = new Container();
			// Rank
			var rankText = new Text2(i + 1 + ".", {
				size: 70,
				fill: 0xFFFFFF
			});
			rankText.anchor.set(0, 0.5);
			rankText.x = -background.width / 2 + 200;
			entry.addChild(rankText);
			// Score
			var scoreText = new Text2(highScores[i] ? highScores[i].toLocaleString() : "0", {
				size: 70,
				fill: 0xFFD700
			});
			scoreText.anchor.set(1, 0.5);
			scoreText.x = background.width / 2 - 200;
			entry.addChild(scoreText);
			// Position entry
			entry.y = startY + i * padding;
			self.addChild(entry);
			scoreEntries.push(entry);
		}
		// If no scores available
		if (highScores.length === 0) {
			var noScoreText = new Text2("No scores yet!", {
				size: 70,
				fill: 0xFFFFFF
			});
			noScoreText.anchor.set(0.5, 0.5);
			noScoreText.y = 0;
			self.addChild(noScoreText);
			scoreEntries.push(noScoreText);
		}
	};
	// Play Game button
	var startButton = new Container();
	var buttonBg = startButton.attachAsset('rope', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	buttonBg.width = 600;
	buttonBg.height = 150;
	buttonBg.tint = 0x00AA00;
	var buttonText = new Text2("PLAY GAME", {
		size: 70,
		fill: 0xFFFFFF
	});
	buttonText.anchor.set(0.5, 0.5);
	startButton.addChild(buttonText);
	startButton.y = background.height / 2 - 200;
	self.addChild(startButton);
	startButton.interactive = true;
	startButton.down = function () {
		buttonBg.tint = 0x007700;
	};
	startButton.up = function () {
		buttonBg.tint = 0x00AA00;
		if (typeof self.onStart === 'function') {
			self.onStart();
		}
	};
	// Reset button removed
	// Make container position in center of screen
	self.x = 2048 / 2;
	self.y = 2732 / 2;
	return self;
});
var InstructionsScreen = Container.expand(function () {
	var self = Container.call(this);
	// Background container
	var background = self.attachAsset('Hiscorebackdrop', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	background.width = 1400;
	background.height = 1600;
	background.alpha = 0.8;
	// Title text
	var titleText = new Text2("HOW TO PLAY", {
		size: 100,
		fill: 0xFFD700
	});
	titleText.anchor.set(0.5, 0);
	titleText.y = -background.height / 2 + 100;
	self.addChild(titleText);
	// Instructions text
	var instructions = ["1. Pull back to slingshot the chicken", "2. Bounce off ropes for points", "3. Collect popcorn for bonus points", "4. Each somersault increases your score multiplier", "5. Perform 10+ somersaults to earn a free launch", "6. Collect power-ups for special abilities", "7. Tap while chicken is flying to extend somersaults"];
	var startY = -background.height / 2 + 250;
	var padding = 80;
	for (var i = 0; i < instructions.length; i++) {
		var instructionText = new Text2(instructions[i], {
			size: 60,
			fill: 0xFFFFFF
		});
		instructionText.anchor.set(0, 0.5);
		instructionText.x = -background.width / 2 + 100;
		instructionText.y = startY + i * padding;
		self.addChild(instructionText);
	}
	// Continue button
	var continueButton = new Container();
	var buttonBg = continueButton.attachAsset('rope', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	buttonBg.width = 600;
	buttonBg.height = 150;
	buttonBg.tint = 0x00AA00;
	var buttonText = new Text2("CONTINUE", {
		size: 70,
		fill: 0xFFFFFF
	});
	buttonText.anchor.set(0.5, 0.5);
	continueButton.addChild(buttonText);
	continueButton.y = background.height / 2 - 200;
	self.addChild(continueButton);
	continueButton.interactive = true;
	continueButton.down = function () {
		buttonBg.tint = 0x007700;
	};
	continueButton.up = function () {
		buttonBg.tint = 0x00AA00;
		// Animate out
		tween(self, {
			alpha: 0
		}, {
			duration: 500,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// Remove from parent
				if (self.parent) {
					self.parent.removeChild(self);
				}
				// Start the game
				if (typeof self.onContinue === 'function') {
					self.onContinue();
				}
			}
		});
	};
	// Position in center of screen
	self.x = 2048 / 2;
	self.y = 2732 / 2;
	return self;
});
var PathTracer = Container.expand(function () {
	var self = Container.call(this);
	self.points = [];
	self.maxPoints = 50;
	self.lineWidth = 5;
	self.lineColor = 0xFFFFFF;
	self.active = false;
	// Create visual representation of the path
	var pathGraphics = self.attachAsset('rope', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Initialize path graphics
	pathGraphics.alpha = 0.5;
	pathGraphics.width = 0;
	pathGraphics.height = 0;
	self.startTracing = function (x, y) {
		self.points = [{
			x: x,
			y: y
		}];
		self.active = true;
	};
	self.addPoint = function (x, y) {
		if (!self.active) {
			return;
		}
		// Only add point if it's significantly different from last point
		var lastPoint = self.points[self.points.length - 1];
		var dx = x - lastPoint.x;
		var dy = y - lastPoint.y;
		var distance = Math.sqrt(dx * dx + dy * dy);
		if (distance > 20) {
			self.points.push({
				x: x,
				y: y
			});
			// Limit number of points
			if (self.points.length > self.maxPoints) {
				self.points.shift();
			}
		}
	};
	self.stopTracing = function () {
		self.active = false;
		return self.points.length >= 2 ? self.points : null;
	};
	self.clear = function () {
		self.points = [];
		self.active = false;
	};
	self.update = function () {
		// Update path visualization based on current points
		if (self.points.length < 2) {
			pathGraphics.alpha = 0;
			return;
		}
		pathGraphics.alpha = 0.8;
		// Calculate path visual representation
		var firstPoint = self.points[0];
		var lastPoint = self.points[self.points.length - 1];
		// Position at midpoint of path
		self.x = (firstPoint.x + lastPoint.x) / 2;
		self.y = (firstPoint.y + lastPoint.y) / 2;
		// Calculate path length and angle
		var dx = lastPoint.x - firstPoint.x;
		var dy = lastPoint.y - firstPoint.y;
		var length = Math.sqrt(dx * dx + dy * dy);
		var angle = Math.atan2(dy, dx);
		// Update path graphics for slingshot visual - thicker line
		pathGraphics.width = length;
		pathGraphics.height = 10; // Make line thicker for slingshot
		pathGraphics.rotation = angle;
		// Make path color change based on pull length (strength indicator)
		var strengthRatio = Math.min(length, 300) / 300; // Normalize to 0-1
		// Color transitions from green (weak) to yellow to red (strong)
		var r = strengthRatio > 0.5 ? 255 : Math.floor(255 * (strengthRatio * 2));
		var g = strengthRatio < 0.5 ? 255 : Math.floor(255 * (2 - strengthRatio * 2));
		var color = (r << 16) + (g << 8);
		pathGraphics.tint = color;
	};
	return self;
});
var Popcorn = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach popcorn asset
	var popcornGraphics = self.attachAsset('popcorn', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Add slight animation
	self.animationOffset = Math.random() * Math.PI * 2;
	self.animationSpeed = 0.03 + Math.random() * 0.02;
	self.baseY = 0;
	self.collect = function () {
		// Play collect sound
		LK.getSound('collect').play();
		// Flash effect
		LK.effects.flashObject(self, 0xFFFFFF, 200);
		// Animate collection (flying up)
		tween(self, {
			y: self.y - 100,
			alpha: 0
		}, {
			duration: 500,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// Remove from parent
				if (self.parent) {
					self.parent.removeChild(self);
				}
			}
		});
	};
	self.update = function () {
		// Hover animation
		if (self.baseY === 0) {
			self.baseY = self.y;
		}
		self.y = self.baseY + Math.sin(LK.ticks * self.animationSpeed + self.animationOffset) * 5;
	};
	return self;
});
var PowerUp = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach power-up asset (using popcorn as base)
	var powerUpGraphics = self.attachAsset('popcorn', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Make it visually distinct
	powerUpGraphics.tint = 0x00FFFF;
	// PowerUp properties
	self.type = "multiplier"; // Default type
	self.value = 2; // Default multiplier value
	self.duration = 10000; // 10 seconds
	self.active = false;
	// Animation properties
	self.animationOffset = Math.random() * Math.PI * 2;
	self.animationSpeed = 0.05 + Math.random() * 0.03;
	self.baseY = 0;
	self.scale = 1.5; // Make power-ups slightly larger
	// Pulse animation
	self.pulseDirection = 1;
	self.pulseSpeed = 0.02;
	self.minScale = 1.3;
	self.maxScale = 1.7;
	self.collect = function () {
		// Play Bogerk sound for power-up collection
		LK.getSound('Bogerk').play();
		// Flash effect
		LK.effects.flashObject(self, 0xFFFFFF, 300);
		// Animate collection (flying up)
		tween(self, {
			y: self.y - 150,
			alpha: 0,
			scaleX: 2,
			scaleY: 2
		}, {
			duration: 600,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// Remove from parent
				if (self.parent) {
					self.parent.removeChild(self);
				}
			}
		});
		// Activate the powerup effect
		if (typeof game.activatePowerUp === 'function') {
			game.activatePowerUp(self.type, self.value, self.duration);
		}
	};
	self.update = function () {
		// Hover animation
		if (self.baseY === 0) {
			self.baseY = self.y;
		}
		// Vertical hover
		self.y = self.baseY + Math.sin(LK.ticks * self.animationSpeed + self.animationOffset) * 8;
		// Pulsing animation
		var currentScale = self.scale;
		currentScale += self.pulseDirection * self.pulseSpeed;
		if (currentScale > self.maxScale) {
			currentScale = self.maxScale;
			self.pulseDirection = -1;
		} else if (currentScale < self.minScale) {
			currentScale = self.minScale;
			self.pulseDirection = 1;
		}
		self.scale = currentScale;
		self.scaleX = self.scale;
		self.scaleY = self.scale;
	};
	return self;
});
var Rope = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach rope asset
	var ropeGraphics = self.attachAsset('rope', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Rope properties
	self.tension = 0.8; // Increased tension for more springy, elastic bounces
	self.bounce = function (chickenJockey) {
		// Check if we've already bounced in the same place to prevent getting stuck
		var distFromLastBounce = Math.sqrt(Math.pow(chickenJockey.x - chickenJockey.lastBouncePosition.x, 2) + Math.pow(chickenJockey.y - chickenJockey.lastBouncePosition.y, 2));
		// If too close to last bounce position, give an extra boost to escape
		if (distFromLastBounce < 50) {
			// Extra velocity away from the rope
			var awayX = chickenJockey.x - self.x;
			var awayY = chickenJockey.y - self.y;
			var awayDist = Math.sqrt(awayX * awayX + awayY * awayY);
			if (awayDist > 0) {
				chickenJockey.vx += awayX / awayDist * 10;
				chickenJockey.vy += awayY / awayDist * 10;
			}
		}
		// Store current position as last bounce position
		chickenJockey.lastBouncePosition.x = chickenJockey.x;
		chickenJockey.lastBouncePosition.y = chickenJockey.y;
		// Store original position for rope displacement effect
		var originalX = self.x;
		var originalY = self.y;
		// Calculate normal angle (perpendicular to rope)
		var normalAngle = Math.atan2(chickenJockey.y - self.y, chickenJockey.x - self.x);
		// Account for rope rotation when calculating normal
		normalAngle += self.rotation + Math.PI / 2;
		// Calculate velocity components
		var speed = Math.sqrt(chickenJockey.vx * chickenJockey.vx + chickenJockey.vy * chickenJockey.vy);
		var incomingAngle = Math.atan2(chickenJockey.vy, chickenJockey.vx);
		// Flip the chicken based on horizontal velocity after bounce
		var chickenGraphics = chickenJockey.getChildAt(0);
		if (chickenJockey.vx > 0) {
			if (chickenGraphics.scaleX !== -1) {
				// Starting a flip from left to right
				chickenJockey.somersaulting = true;
				chickenJockey.somersaultDirection = 1;
				chickenJockey.somersaultRotation = 0;
				// Start somersault animation with tween
				tween.stop(chickenGraphics); // Stop any existing rotation animations
				tween(chickenGraphics, {
					rotation: Math.PI * 2
				}, {
					duration: 600,
					easing: tween.easeOut,
					onFinish: function onFinish() {
						chickenGraphics.rotation = 0;
						chickenGraphics.scaleX = -1; // Facing right
						chickenJockey.somersaulting = false;
					}
				});
			}
		} else {
			if (chickenGraphics.scaleX !== 1) {
				// Starting a flip from right to left
				chickenJockey.somersaulting = true;
				chickenJockey.somersaultDirection = -1;
				chickenJockey.somersaultRotation = 0;
				// Start somersault animation with tween
				tween.stop(chickenGraphics); // Stop any existing rotation animations
				tween(chickenGraphics, {
					rotation: -Math.PI * 2
				}, {
					duration: 600,
					easing: tween.easeOut,
					onFinish: function onFinish() {
						chickenGraphics.rotation = 0;
						chickenGraphics.scaleX = 1; // Facing left
						chickenJockey.somersaulting = false;
					}
				});
			}
		}
		// Calculate angle of reflection
		var bounceAngle = 2 * normalAngle - incomingAngle;
		// Calculate new velocity with enhanced force based on incoming speed
		// Higher incoming speed = stronger bounce back effect
		var bounceForce = speed * self.tension * (1 + Math.min(1.0, speed / 20)); // Further adjusted to depend more on incoming velocity
		// Ensure minimum bounce force to prevent getting stuck
		bounceForce = Math.max(bounceForce, 5);
		// Add screen shake effect on powerful impacts
		if (speed > 20) {
			// Custom screen shake effect using tween
			var originalPosition = {
				x: game.x,
				y: game.y
			};
			tween(game, {
				x: originalPosition.x + (Math.random() - 0.5) * 20,
				y: originalPosition.y + (Math.random() - 0.5) * 20
			}, {
				duration: 100,
				easing: tween.easeInOut,
				onFinish: function onFinish() {
					tween(game, {
						x: originalPosition.x,
						y: originalPosition.y
					}, {
						duration: 100,
						easing: tween.easeInOut
					});
				}
			});
		}
		// Reduce random angle variation for more predictable wrestling-style bounces
		var angleVariation = (Math.random() - 0.5) * 0.05; // Further reduced random angle adjustment for predictability
		bounceAngle += angleVariation;
		// Apply immediate minimum velocity to prevent sticking
		var minVelocity = 3.0;
		chickenJockey.vx = Math.cos(bounceAngle) * Math.max(bounceForce * 0.3, minVelocity) * chickenJockey.bounceDecay;
		chickenJockey.vy = Math.sin(bounceAngle) * Math.max(bounceForce * 0.3, minVelocity) * chickenJockey.bounceDecay;
		// Brief pause to simulate rope stretching and chicken "sticking" to rope momentarily
		// Store original velocities but don't slow down as much to prevent sticking
		var originalVX = chickenJockey.vx;
		var originalVY = chickenJockey.vy;
		// Momentarily slow down the chicken but not enough to get stuck
		chickenJockey.vx *= 0.3;
		chickenJockey.vy *= 0.3;
		// Add a slight delay before applying the bounce-back force
		LK.setTimeout(function () {
			// Now apply the full bounce force with enhanced velocity
			chickenJockey.vx = Math.cos(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
			chickenJockey.vy = Math.sin(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
			// Add a burst of rotation to simulate impact force
			chickenJockey.rotationSpeed = (Math.random() - 0.5) * 0.2; // Increased rotation burst for more dramatic impact
		}, 30);
		// Create enhanced bounce visual effect with more dramatic rope "give"
		tween(self, {
			scaleY: 1.8,
			// More dramatic stretch
			alpha: 0.7,
			// Add slight displacement in direction of impact
			x: originalX + Math.cos(incomingAngle) * 10,
			y: originalY + Math.sin(incomingAngle) * 10
		}, {
			duration: 200,
			// Extended stretch duration
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// After brief delay, apply the full bounce force
				// We're not setting additional velocity here to prevent doubling the effect
				LK.setTimeout(function () {
					// Ensure the chicken is still moving away from the rope
					if (Math.abs(chickenJockey.vx) < minVelocity && Math.abs(chickenJockey.vy) < minVelocity) {
						chickenJockey.vx = Math.cos(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
						chickenJockey.vy = Math.sin(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
					}
					// Add a burst of rotation to simulate impact force
					chickenJockey.rotationSpeed = (Math.random() - 0.5) * 0.15;
				}, 30);
				// Snap the rope back with more dramatic effect
				tween(self, {
					scaleY: 1.0,
					alpha: 1.0,
					x: originalX,
					y: originalY
				}, {
					duration: 500,
					// Longer snap-back for more visual impact
					easing: tween.elasticOut,
					onFinish: function onFinish() {
						// Add rope vibration effect after snap-back
						tween(self, {
							x: originalX + Math.sin(LK.ticks * 0.1) * 5,
							y: originalY + Math.cos(LK.ticks * 0.1) * 5
						}, {
							duration: 300,
							easing: tween.easeInOut,
							onFinish: function onFinish() {
								// Reset position after vibration
								self.x = originalX;
								self.y = originalY;
							}
						});
					}
				});
			}
		});
		// Increment bounce count
		chickenJockey.bounceCount++;
		// Play bounce sound with increased volume for high-speed bounces
		var bounceSound = LK.getSound('bounce');
		bounceSound.volume = Math.min(1, speed / 30); // Increase volume based on speed
		bounceSound.play();
		// Play chicken cluck sound when chicken bounces off ropes
		LK.getSound('Chickencluck').play();
		// Flash rope to indicate bounce with more intensity for high-speed bounces
		var flashIntensity = Math.min(0xFFFFFF, 0xFFFFFF * (speed / 30));
		LK.effects.flashObject(self, flashIntensity, 200);
		// Add points for bouncing - more points for higher somersault count
		var somersaultBonus = Math.min(10, chickenJockey.bounceCount) * 500; // Bonus increases with somersault count
		if (typeof game.addScore === 'function') {
			game.addScore(5000 + somersaultBonus);
		}
		// Spawn more popcorn on rope bounce (increased chance and count)
		if (Math.random() < 0.7 && typeof game.createPopcornAt === 'function') {
			game.createPopcornAt(chickenJockey.x, chickenJockey.y, 5);
		}
	};
	self.intersectsWithPoint = function (x, y) {
		var halfWidth = ropeGraphics.width / 2;
		var halfHeight = ropeGraphics.height / 2;
		// Check if point is within the rope's bounding box
		return x >= self.x - halfWidth && x <= self.x + halfWidth && y >= self.y - halfHeight && y <= self.y + halfHeight;
	};
	return self;
});
var TitleScreen = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach title screen asset
	var titleGraphics = self.attachAsset('Titlescreen', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Position in center of screen
	self.x = 2048 / 2;
	self.y = 2732 / 2;
	// Make interactive to handle clicks
	self.interactive = true;
	// Handle click/tap to start game
	self.down = function () {
		// Visual feedback
		titleGraphics.alpha = 0.8;
	};
	self.up = function () {
		// Animate out
		tween(self, {
			alpha: 0
		}, {
			duration: 500,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// Remove from parent
				if (self.parent) {
					self.parent.removeChild(self);
				}
				// Start the game
				if (typeof self.onStart === 'function') {
					self.onStart();
				}
			}
		});
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x000000 // Black background
});
/**** 
* Game Code
****/ 
// Game state
var gameState = "ready"; // ready, aiming, launched, gameOver
var score = 0;
var launches = 0;
var maxLaunches = 5;
var maxLaunchesFromBonuses = 0; // Track how many launches came from bonuses
var popcorns = [];
var ropes = [];
var powerUps = [];
var scoreMultiplier = 1;
var multiplierEndTime = 0;
var highScoresKey = 'chickenJockeyHighScores';
var pathTracer = game.addChild(new PathTracer());
// Add backdrop first
var backdrop = game.addChild(LK.getAsset('Backdrop', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2,
	y: 2732 / 2
}));
// Create wrestling arena
var arena = game.addChild(LK.getAsset('arena', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2 + 20,
	y: 2732 / 2
}));
// Create chicken jockey
var chickenJockey = game.addChild(new ChickenJockey());
// Game boundaries
var bounds = {
	left: arena.x - arena.width / 2,
	right: arena.x + arena.width / 2,
	top: arena.y - arena.height / 2,
	bottom: arena.y + arena.height / 2
};
// Create GUI elements
var scoreText = new Text2("Score: 0", {
	size: 70,
	fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var launchesText = new Text2("Launches: 0/" + maxLaunches, {
	size: 50,
	fill: 0xFFFFFF
});
launchesText.anchor.set(0, 0);
launchesText.x = 120; // Avoid top-left corner
launchesText.y = 140;
LK.gui.topLeft.addChild(launchesText);
// Add somersault counter display
var somersaultText = new Text2("Somersaults: 0", {
	size: 50,
	fill: 0xFFFFFF
});
somersaultText.anchor.set(1, 0);
somersaultText.x = -120; // Position on right side
somersaultText.y = 140;
LK.gui.topRight.addChild(somersaultText);
var instructionText = new Text2("Drag to aim and launch the chicken!", {
	size: 40,
	fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
instructionText.y = 100;
LK.gui.top.addChild(instructionText);
// Initialize game
function initGame() {
	// Reset variables
	score = 0;
	launches = 0;
	maxLaunches = 5; // Starting launches, can go up to 20 max
	maxLaunchesFromBonuses = 0; // Reset bonus launches counter
	scoreMultiplier = 1;
	multiplierEndTime = 0;
	gameState = "ready";
	// Update UI
	scoreText.setText("Score: " + score);
	launchesText.setText("Launches: " + launches + "/" + maxLaunches);
	instructionText.setText("Pull back to slingshot! Somersaults = SCORE MULTIPLIER + FREE LAUNCH!");
	somersaultText.setText("Somersaults: 0");
	// Reset chicken jockey
	resetChickenJockey();
	// Clear existing popcorn and ropes
	clearPopcornsAndRopes();
	// Create ropes around the arena
	createRopes();
	// Create more popcorn scattered around the arena
	createPopcorn(60);
	// Create a few power-ups
	for (var i = 0; i < 3; i++) {
		createPowerUp();
	}
	// Play game start sound
	LK.getSound('Gamestart').play();
	// Play background music after a short delay to ensure it starts after the game start sound
	LK.setTimeout(function () {
		LK.playMusic('gameMusic', {
			loop: true
		});
	}, 1000); // Delay of 1000ms (1 second)
}
function resetChickenJockey() {
	chickenJockey.reset();
	// Position chicken in the center of the arena
	chickenJockey.x = arena.x;
	chickenJockey.y = arena.y;
}
function clearPopcornsAndRopes() {
	// Remove all popcorn
	for (var i = 0; i < popcorns.length; i++) {
		if (popcorns[i].parent) {
			popcorns[i].parent.removeChild(popcorns[i]);
		}
	}
	popcorns = [];
	// Remove all ropes
	for (var i = 0; i < ropes.length; i++) {
		if (ropes[i].parent) {
			ropes[i].parent.removeChild(ropes[i]);
		}
	}
	ropes = [];
	// Remove all power-ups
	for (var i = 0; i < powerUps.length; i++) {
		if (powerUps[i].parent) {
			powerUps[i].parent.removeChild(powerUps[i]);
		}
	}
	powerUps = [];
}
function createRopes() {
	// Create top rope
	var topRope = new Rope();
	topRope.x = arena.x;
	topRope.y = bounds.top + 100;
	game.addChild(topRope);
	ropes.push(topRope);
	// Create right rope
	var rightRope = new Rope();
	rightRope.x = bounds.right - 100;
	rightRope.y = arena.y;
	rightRope.rotation = Math.PI / 2; // Rotate 90 degrees
	game.addChild(rightRope);
	ropes.push(rightRope);
	// Create bottom rope
	var bottomRope = new Rope();
	bottomRope.x = arena.x;
	bottomRope.y = bounds.bottom - 100;
	bottomRope.bounce = function (chickenJockey) {
		// Prevent the bottom rope from moving down with stronger upward bounce
		var speed = Math.sqrt(chickenJockey.vx * chickenJockey.vx + chickenJockey.vy * chickenJockey.vy);
		var upwardForce = Math.max(10, speed * 0.8);
		// Apply minimum upward velocity to prevent sticking
		chickenJockey.vy = -upwardForce * chickenJockey.bounceDecay;
		// Move chicken slightly up to avoid rope overlap
		chickenJockey.y -= 20;
		chickenJockey.bounceCount++;
		LK.getSound('bounce').play();
		game.addScore(2000);
	};
	game.addChild(bottomRope);
	ropes.push(bottomRope);
	// Create left rope
	var leftRope = new Rope();
	leftRope.x = bounds.left + 100;
	leftRope.y = arena.y;
	leftRope.rotation = Math.PI / 2; // Rotate 90 degrees
	game.addChild(leftRope);
	ropes.push(leftRope);
	// Center horizontal rope removed
}
function createPopcorn(count) {
	for (var i = 0; i < count; i++) {
		var popcorn = new Popcorn();
		// Random position within arena bounds
		popcorn.x = bounds.left + 100 + Math.random() * (arena.width - 200);
		popcorn.y = bounds.top + 100 + Math.random() * (arena.height - 200);
		game.addChild(popcorn);
		popcorns.push(popcorn);
	}
}
function createPowerUp() {
	var powerUp = new PowerUp();
	// Random position within arena bounds
	powerUp.x = bounds.left + 150 + Math.random() * (arena.width - 300);
	powerUp.y = bounds.top + 150 + Math.random() * (arena.height - 300);
	// Random power-up type
	var types = ["multiplier", "extraLaunch", "superBounce"];
	var randomType = types[Math.floor(Math.random() * types.length)];
	powerUp.type = randomType;
	// Configure based on type
	if (randomType === "multiplier") {
		powerUp.tint = 0x00FFFF; // Cyan
		powerUp.value = 2 + Math.floor(Math.random() * 3); // 2x to 4x multiplier
	} else if (randomType === "extraLaunch") {
		powerUp.tint = 0xFF00FF; // Purple
		powerUp.value = 1; // Extra launch
	} else if (randomType === "superBounce") {
		powerUp.tint = 0xFFFF00; // Yellow
		powerUp.value = 2; // Double bounce points
	}
	game.addChild(powerUp);
	powerUps.push(powerUp);
}
// Game events
game.onChickenJockeyStop = function () {
	gameState = "ready";
	// Add more popcorn when chicken jockey stops
	if (popcorns.length < 40) {
		createPopcorn(25);
	}
	// Occasionally add a power-up when chicken stops
	if (Math.random() < 0.3 && powerUps.length < 5) {
		createPowerUp();
	}
	// Check if out of launches
	if (launches >= maxLaunches) {
		// Game over
		instructionText.setText("Game Over! Final Score: " + score);
		gameState = "gameOver";
		// Show game over after a short delay
		LK.setTimeout(function () {
			LK.showGameOver();
		}, 2000);
	} else {
		// Reset for next launch
		resetChickenJockey();
		instructionText.setText("Drag to aim and launch the chicken!");
	}
};
game.onMaxBouncesReached = function () {
	// Same as onChickenJockeyStop for now
	game.onChickenJockeyStop();
};
// Input handling
var dragStartX = 0;
var dragStartY = 0;
var dragEndX = 0;
var dragEndY = 0;
game.down = function (x, y, obj) {
	if (gameState === "ready") {
		gameState = "aiming";
		dragStartX = x;
		dragStartY = y;
		pathTracer.startTracing(x, y);
		instructionText.setText("Pull back to launch chicken!");
	}
	// Add quick tap detection for increasing somersaults when chicken is launched
	else if (gameState === "launched" && chickenJockey.launched) {
		// Increase max bounces to allow more somersaults
		chickenJockey.maxBounces += 3;
		// Show feedback
		showMessage("+" + 3 + " somersaults!", 0x00FF00);
		// Add some visual feedback
		LK.effects.flashObject(chickenJockey, 0x00FF00, 200);
		// Play sound
		LK.getSound('bounce').play();
	}
};
game.move = function (x, y, obj) {
	if (gameState === "aiming") {
		pathTracer.addPoint(x, y);
	}
};
game.up = function (x, y, obj) {
	if (gameState === "aiming") {
		// Get the path from the path tracer
		var path = pathTracer.stopTracing();
		// Only launch if we have a valid path
		if (path && path.length >= 2) {
			// Record drag end position
			dragEndX = x;
			dragEndY = y;
			// Get start and end points for slingshot mechanics
			var startPoint = path[0];
			var endPoint = path[path.length - 1];
			// Launch the chicken using slingshot mechanics
			chickenJockey.launch(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
			// Update game state
			gameState = "launched";
			launches++;
			launchesText.setText("Launches: " + launches + "/" + maxLaunches);
			instructionText.setText("Watch the chicken bounce!");
		} else {
			// Cancel the launch if the path was too short
			gameState = "ready";
		}
		// Clear the path tracer regardless
		pathTracer.clear();
	}
};
// Add helper to update score
game.addScore = function (points) {
	// Apply multiplier if active (powerup multiplier)
	var finalPoints = points;
	if (Date.now() < multiplierEndTime) {
		finalPoints = Math.floor(points * scoreMultiplier);
	}
	// Apply somersault multiplier if chicken is launched
	if (chickenJockey.launched && chickenJockey.scoreMultiplier > 1) {
		finalPoints = Math.floor(finalPoints * chickenJockey.scoreMultiplier);
		// Show somersault multiplier notification for big scores
		if (points >= 2000) {
			var multiplierText = new Text2("SOMERSAULT BONUS x" + chickenJockey.scoreMultiplier.toFixed(1), {
				size: 70,
				fill: 0x00FFAA
			});
			multiplierText.anchor.set(0.5, 0.5);
			multiplierText.x = chickenJockey.x;
			multiplierText.y = chickenJockey.y - 180;
			game.addChild(multiplierText);
			// Animate multiplier text
			tween(multiplierText, {
				y: multiplierText.y - 100,
				alpha: 0
			}, {
				duration: 800,
				easing: tween.easeOut,
				onFinish: function onFinish() {
					if (multiplierText.parent) {
						multiplierText.parent.removeChild(multiplierText);
					}
				}
			});
		}
	}
	score += finalPoints;
	scoreText.setText("Score: " + score);
	LK.setScore(score);
	// Visual feedback for big point gains
	if (finalPoints >= 5000) {
		// Add fireworks effect - LK.effects.fireworks is not a function
		// LK.effects.fireworks();
		var pointText = new Text2("+" + finalPoints, {
			size: 80,
			fill: 0xFFFF00,
			font: "'Arial',Impact,'Helvetica'" // Start with standard font
		});
		pointText.anchor.set(0.5, 0.5);
		pointText.x = chickenJockey.x;
		pointText.y = chickenJockey.y - 120;
		game.addChild(pointText);
		// Animate font change and movement
		tween(pointText, {
			y: pointText.y - 70,
			scaleX: 2.0,
			scaleY: 2.0
		}, {
			duration: 300,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				// Change font to more dramatic one mid-animation
				pointText.font = "'Impact','Arial Black'";
				pointText.fill = 0xFF4500; // Change color to orange-red
				// Finish animation with new font
				tween(pointText, {
					y: pointText.y - 100,
					alpha: 0,
					scaleX: 1.0,
					scaleY: 1.0
				}, {
					duration: 600,
					easing: tween.easeOut,
					onFinish: function onFinish() {
						if (pointText.parent) {
							pointText.parent.removeChild(pointText);
						}
					}
				});
			}
		});
	}
};
// Helper method to create popcorn at specific location
game.createPopcornAt = function (x, y, count) {
	count = count || 1;
	for (var i = 0; i < count; i++) {
		var popcorn = new Popcorn();
		// Position near the specified location with some random offset
		var offsetX = (Math.random() - 0.5) * 200;
		var offsetY = (Math.random() - 0.5) * 200;
		popcorn.x = Math.max(bounds.left + 50, Math.min(bounds.right - 50, x + offsetX));
		popcorn.y = Math.max(bounds.top + 50, Math.min(bounds.bottom - 50, y + offsetY));
		// Add to game
		game.addChild(popcorn);
		popcorns.push(popcorn);
	}
};
// Power-up activation function
game.activatePowerUp = function (type, value, duration) {
	// Visual feedback for power-up activation
	LK.effects.flashScreen(0x00FFFF, 500);
	if (type === "multiplier") {
		// Set score multiplier
		scoreMultiplier = value;
		// Display message
		showMessage("Score x" + value + " for " + duration / 1000 + "s!", 0x00FFFF);
		// Set timer to end effect
		multiplierEndTime = Date.now() + duration;
	} else if (type === "extraLaunch") {
		// Check if adding value would exceed the maximum of 20 launches or max bonus launches
		if (maxLaunches < 20 && maxLaunchesFromBonuses < 15) {
			// Calculate how many launches to add without exceeding the cap
			var maxBonusRemaining = 15 - maxLaunchesFromBonuses;
			var maxTotalRemaining = 20 - maxLaunches;
			var launchesToAdd = Math.min(value, Math.min(maxBonusRemaining, maxTotalRemaining));
			maxLaunches += launchesToAdd;
			maxLaunchesFromBonuses += launchesToAdd;
			launches = Math.max(0, launches - launchesToAdd); // Refund launches
			launchesText.setText("Launches: " + launches + "/" + maxLaunches);
			// Display message
			showMessage("+" + launchesToAdd + " Extra Launch!", 0xFF00FF);
			// Show warning if we had to cap the bonus
			if (launchesToAdd < value) {
				LK.setTimeout(function () {
					showMessage("MAX LAUNCHES REACHED (20)!", 0xFF0000);
				}, 1000);
			}
		} else {
			// Already at max launches
			showMessage("MAX LAUNCHES REACHED (20)!", 0xFF0000);
		}
	} else if (type === "superBounce") {
		// Temporarily increase bounce values
		var oldBounceDecay = chickenJockey.bounceDecay;
		chickenJockey.bounceDecay = Math.min(1.0, chickenJockey.bounceDecay * 1.3);
		// Display message
		showMessage("Super Bounce for " + duration / 1000 + "s!", 0xFFFF00);
		// Set timer to end effect
		LK.setTimeout(function () {
			chickenJockey.bounceDecay = oldBounceDecay;
		}, duration);
	}
};
// Helper function to show temporary messages
function showMessage(text, color) {
	var message = new Text2(text, {
		size: 60,
		fill: color || 0xFFFFFF
	});
	message.anchor.set(0.5, 0.5);
	message.x = 2048 / 2;
	message.y = 400;
	LK.gui.center.addChild(message);
	// Animate in
	message.alpha = 0;
	message.scaleX = 0.5;
	message.scaleY = 0.5;
	tween(message, {
		alpha: 1,
		scaleX: 1,
		scaleY: 1
	}, {
		duration: 300,
		easing: tween.easeOut
	});
	// Animate out after delay
	LK.setTimeout(function () {
		tween(message, {
			alpha: 0,
			y: message.y - 100
		}, {
			duration: 500,
			easing: tween.easeIn,
			onFinish: function onFinish() {
				if (message.parent) {
					message.parent.removeChild(message);
				}
			}
		});
	}, 2000);
}
// Main game loop
game.update = function () {
	// Update all game objects
	if (gameState === "launched") {
		chickenJockey.update();
		if (chickenJockey.lastRopeCollision === undefined) {
			chickenJockey.lastRopeCollision = null;
		}
		// Check for collisions with ropes
		for (var i = 0; i < ropes.length; i++) {
			// Only bounce if we weren't already intersecting this rope
			if (chickenJockey.intersects(ropes[i]) && chickenJockey.lastRopeCollision !== ropes[i]) {
				// Calculate direction vectors for bounce
				var dx = chickenJockey.x - ropes[i].x;
				var dy = chickenJockey.y - ropes[i].y;
				var dist = Math.sqrt(dx * dx + dy * dy);
				// Push chicken away from rope slightly to prevent sticking
				if (dist > 0) {
					chickenJockey.x += dx / dist * 10;
					chickenJockey.y += dy / dist * 10;
				}
				ropes[i].bounce(chickenJockey);
				chickenJockey.lastRopeCollision = ropes[i];
				// Clear last rope collision after a shorter delay to allow for new collisions
				LK.setTimeout(function () {
					chickenJockey.lastRopeCollision = null;
				}, 150);
				// Only bounce on one rope per frame to prevent chaotic behavior
				break;
			}
		}
		// Check for collisions with popcorn
		for (var i = popcorns.length - 1; i >= 0; i--) {
			if (chickenJockey.intersects(popcorns[i])) {
				// Collect popcorn
				popcorns[i].collect();
				popcorns.splice(i, 1);
				// Increase score - reduced from 10000 to 2000
				game.addScore(2000);
				scoreText.setText("Score: " + score);
				// Save score to LK
				LK.setScore(score);
				// No longer reset launches when score reaches 1000
			}
		}
		// Check for collisions with power-ups
		for (var i = powerUps.length - 1; i >= 0; i--) {
			if (chickenJockey.intersects(powerUps[i])) {
				// Collect power-up
				powerUps[i].collect();
				powerUps.splice(i, 1);
			}
		}
	}
	// Update popcorn animations
	for (var i = 0; i < popcorns.length; i++) {
		popcorns[i].update();
	}
	// Update power-up animations
	for (var i = 0; i < powerUps.length; i++) {
		powerUps[i].update();
	}
	// Randomly spawn new power-ups (rare)
	if (gameState === "launched" && Math.random() < 0.001 && powerUps.length < 5) {
		createPowerUp();
	}
	// Randomly create popcorn explosions during gameplay
	if (gameState === "launched" && Math.random() < 0.01) {
		// Create random popcorn explosion in the arena
		var explosionX = bounds.left + 150 + Math.random() * (arena.width - 300);
		var explosionY = bounds.top + 150 + Math.random() * (arena.height - 300);
		game.createPopcornAt(explosionX, explosionY, 8);
		// Visual feedback
		var popText = new Text2("POP!", {
			size: 60,
			fill: 0xFFD700
		});
		popText.anchor.set(0.5, 0.5);
		popText.x = explosionX;
		popText.y = explosionY;
		game.addChild(popText);
		// Animate out
		tween(popText, {
			alpha: 0,
			y: popText.y - 100,
			scaleX: 2,
			scaleY: 2
		}, {
			duration: 600,
			easing: tween.easeOut,
			onFinish: function onFinish() {
				if (popText.parent) {
					popText.parent.removeChild(popText);
				}
			}
		});
	}
	// Update path tracer
	pathTracer.update();
	// Update score multiplier UI if active
	if (Date.now() < multiplierEndTime && scoreMultiplier > 1) {
		// Update multiplier display in score text
		var remainingSecs = Math.ceil((multiplierEndTime - Date.now()) / 1000);
		scoreText.setText("Score: " + score + " (x" + scoreMultiplier + " for " + remainingSecs + "s)");
	}
	// Update somersault counter if chicken is launched
	if (gameState === "launched" && chickenJockey.launched) {
		somersaultText.setText("Somersaults: " + chickenJockey.bounceCount);
	}
	// Award extra launch for every million points
	if (score >= 1000000) {
		// Calculate current million mark
		var currentMillionMark = Math.floor(score / 1000000);
		// Check if we crossed a new million point threshold
		if (!game.lastMillionMark || currentMillionMark > game.lastMillionMark) {
			// Award free launch if not at max cap and not exceeding max bonus launches
			if (maxLaunches < 20 && maxLaunchesFromBonuses < 15) {
				maxLaunches++;
				maxLaunchesFromBonuses++;
				// Optionally refund a launch for immediate use
				launches = Math.max(0, launches - 1);
				// Play Bogerk sound for million point bonus
				LK.getSound('Bogerk').play();
				showMessage("FREE LAUNCH FOR " + currentMillionMark + " MILLION POINTS!", 0xFFFF00);
			} else {
				showMessage("MAX LAUNCHES REACHED (20)!", 0xFF0000);
			}
			launchesText.setText("Launches: " + launches + "/" + maxLaunches);
			game.lastMillionMark = currentMillionMark;
			// Add popcorn explosion for million point milestone
			game.createPopcornAt(chickenJockey.x, chickenJockey.y, 20);
			// Create animated free launch text
			var freeText = new Text2("FREE LAUNCH!", {
				size: 100,
				fill: 0xFFFF00
			});
			freeText.anchor.set(0.5, 0.5);
			freeText.x = 2048 / 2;
			freeText.y = 2732 / 2;
			freeText.alpha = 0;
			freeText.scaleX = 0.5;
			freeText.scaleY = 0.5;
			LK.gui.center.addChild(freeText);
			// Flash the screen for dramatic effect
			LK.effects.flashScreen(0xFFFF00, 300);
			// Animate in with bounce effect
			tween(freeText, {
				alpha: 1,
				scaleX: 1.2,
				scaleY: 1.2
			}, {
				duration: 500,
				easing: tween.elasticOut,
				onFinish: function onFinish() {
					// Pulse animation
					tween(freeText, {
						scaleX: 1,
						scaleY: 1
					}, {
						duration: 500,
						easing: tween.easeInOut,
						onFinish: function onFinish() {
							// Animate out with upward movement
							tween(freeText, {
								alpha: 0,
								y: freeText.y - 200
							}, {
								duration: 800,
								easing: tween.easeIn,
								onFinish: function onFinish() {
									if (freeText.parent) {
										freeText.parent.removeChild(freeText);
									}
								}
							});
						}
					});
				}
			});
		}
	}
};
// Handle free launch earned by player getting 10+ somersaults
game.onFreeLaunchEarned = function () {
	// Award free launch if we haven't reached the cap and not exceeding max bonus launches
	if (maxLaunches < 20 && maxLaunchesFromBonuses < 15) {
		maxLaunches++;
		maxLaunchesFromBonuses++;
		// Play Bogerk sound for free launch bonus
		LK.getSound('Bogerk').play();
		// Show message
		showMessage("FREE LAUNCH! 10+ SOMERSAULTS!", 0x00FF00);
		launchesText.setText("Launches: " + launches + "/" + maxLaunches);
	} else {
		// Show message about reaching the max launches cap
		showMessage("MAX LAUNCHES REACHED (20)!", 0xFF0000);
	}
	// Create animated free launch text
	var freeText = new Text2("FREE LAUNCH!", {
		size: 100,
		fill: 0x00FF00
	});
	freeText.anchor.set(0.5, 0.5);
	freeText.x = 2048 / 2;
	freeText.y = 2732 / 2;
	freeText.alpha = 0;
	freeText.scaleX = 0.5;
	freeText.scaleY = 0.5;
	LK.gui.center.addChild(freeText);
	// Flash screen
	LK.effects.flashScreen(0x00FF00, 300);
	// Animate the text
	tween(freeText, {
		alpha: 1,
		scaleX: 1.2,
		scaleY: 1.2
	}, {
		duration: 500,
		easing: tween.elasticOut,
		onFinish: function onFinish() {
			tween(freeText, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 500,
				easing: tween.easeInOut,
				onFinish: function onFinish() {
					tween(freeText, {
						alpha: 0,
						y: freeText.y - 200
					}, {
						duration: 800,
						easing: tween.easeIn,
						onFinish: function onFinish() {
							if (freeText.parent) {
								freeText.parent.removeChild(freeText);
							}
						}
					});
				}
			});
		}
	});
};
// High score management functions
function getHighScores() {
	return storage[highScoresKey] || [];
}
function saveHighScore(score) {
	var highScores = getHighScores();
	highScores.push(score);
	// Sort in descending order
	highScores.sort(function (a, b) {
		return b - a;
	});
	// Keep only top 10 scores
	if (highScores.length > 10) {
		highScores = highScores.slice(0, 10);
	}
	// Save to storage
	storage[highScoresKey] = highScores;
}
// Create high score tally
var highScoreTally = new HighScoreTally();
highScoreTally.visible = true;
highScoreTally.onStart = function () {
	game.removeChild(highScoreTally);
	initGame();
};
// Create title screen
var titleScreen = new TitleScreen();
game.addChild(titleScreen);
// Set up title screen callback
titleScreen.onStart = function () {
	// Show instructions screen instead of high scores
	var instructionsScreen = new InstructionsScreen();
	game.addChild(instructionsScreen);
	// Set up callback for when instructions screen is closed
	instructionsScreen.onContinue = function () {
		// Show high scores after instructions
		game.addChild(highScoreTally);
		highScoreTally.updateScores(getHighScores());
		// Position chicken in the center of the screen when high score tally is shown
		chickenJockey.x = arena.x;
		chickenJockey.y = arena.y;
	};
};
// Modified game over handling
var originalOnChickenJockeyStop = game.onChickenJockeyStop;
game.onChickenJockeyStop = function () {
	// Call original function first
	originalOnChickenJockeyStop();
	// If game over, save score
	if (gameState === "gameOver") {
		saveHighScore(score);
		// We'll show high scores after game over in LK.showGameOver callback
	}
};
// Handle game start
LK.onGameOver = function () {
	// Show high score tally after game over
	game.addChild(highScoreTally);
	highScoreTally.updateScores(getHighScores());
}; ===================================================================
--- original.js
+++ change.js
@@ -35,19 +35,21 @@
 	self.somersaulting = false;
 	self.somersaultRotation = 0;
 	self.somersaultDirection = 1; // 1 for clockwise, -1 for counter-clockwise
 	self.launch = function (startX, startY, endX, endY) {
-		// Calculate direction vector from end point to start point
+		// Calculate direction vector
 		var dx = startX - endX;
 		var dy = startY - endY;
 		// Calculate distance for power
 		var distance = Math.sqrt(dx * dx + dy * dy);
-		// Normalize the vector and scale by distance for power (with a cap)
-		var power = Math.min(distance * 0.15, 30);
-		// Set velocity based on normalized direction and power
-		self.vx = dx / distance * power;
-		self.vy = dy / distance * power;
-		// Set rotation speed based on velocity magnitude
+		// Scale power based on distance (capped for balance)
+		var power = Math.min(distance, 300) * 0.15;
+		// Calculate angle in radians
+		var angle = Math.atan2(dy, dx);
+		// Set initial velocity based on power and angle
+		self.vx = Math.cos(angle) * power;
+		self.vy = Math.sin(angle) * power;
+		// Set rotation speed based on velocity
 		self.rotationSpeed = power / 50;
 		self.launched = true;
 		self.bounceCount = 0;
 		// Play launch sound
@@ -80,11 +82,11 @@
 		if (!self.launched) {
 			return;
 		}
 		// Apply physics with speed limiting
-		self.vy += self.gravity; // Re-added gravity
+		self.vy += self.gravity;
 		// Cap maximum velocity to prevent freezing
-		var maxSpeed = 15; // Reduced maximum speed
+		var maxSpeed = 30;
 		self.vx = Math.max(-maxSpeed, Math.min(maxSpeed, self.vx));
 		self.vy = Math.max(-maxSpeed, Math.min(maxSpeed, self.vy));
 		self.x += self.vx;
 		self.y += self.vy;
@@ -106,14 +108,21 @@
 				self.addChild(self.scoreMultiplierText);
 			} else {
 				self.scoreMultiplierText.setText("x" + self.scoreMultiplier.toFixed(1));
 			}
-			// Set multiplier text without animation
+			// Animate multiplier change
 			if (self.bounceCount > 0) {
 				self.scoreMultiplierText.alpha = 1;
 				tween.stop(self.scoreMultiplierText);
-				self.scoreMultiplierText.scaleX = 1;
-				self.scoreMultiplierText.scaleY = 1;
+				self.scoreMultiplierText.scaleX = 1.5;
+				self.scoreMultiplierText.scaleY = 1.5;
+				tween(self.scoreMultiplierText, {
+					scaleX: 1,
+					scaleY: 1
+				}, {
+					duration: 300,
+					easing: tween.elasticOut
+				});
 			}
 		}
 		// Position the multiplier text above the chicken
 		if (self.scoreMultiplierText) {
@@ -122,55 +131,59 @@
 		// Keep chicken within arena boundaries
 		if (self.x < bounds.left) {
 			self.x = bounds.left;
 			self.vx = -self.vx * self.bounceDecay;
-			// Flip chicken when hitting arena boundary without animation
+			// Flip chicken when hitting arena boundary
 			var chickenGraphics = self.getChildAt(0);
 			if (chickenGraphics.scaleX !== 1) {
-				chickenGraphics.rotation = 0;
-				chickenGraphics.scaleX = 1; // Facing left
+				// Start somersault animation
+				self.somersaulting = true;
+				self.somersaultDirection = -1;
+				tween.stop(chickenGraphics); // Stop any existing rotation animations
+				tween(chickenGraphics, {
+					rotation: -Math.PI * 2
+				}, {
+					duration: 600,
+					easing: tween.easeOut,
+					onFinish: function onFinish() {
+						chickenGraphics.rotation = 0;
+						chickenGraphics.scaleX = 1; // Facing left
+						self.somersaulting = false;
+					}
+				});
 			}
 		} else if (self.x > bounds.right) {
 			self.x = bounds.right;
 			self.vx = -self.vx * self.bounceDecay;
-			// Flip chicken when hitting arena boundary without animation
+			// Flip chicken when hitting arena boundary
 			var chickenGraphics = self.getChildAt(0);
 			if (chickenGraphics.scaleX !== -1) {
-				chickenGraphics.rotation = 0;
-				chickenGraphics.scaleX = -1; // Facing right
+				// Start somersault animation
+				self.somersaulting = true;
+				self.somersaultDirection = 1;
+				tween.stop(chickenGraphics); // Stop any existing rotation animations
+				tween(chickenGraphics, {
+					rotation: Math.PI * 2
+				}, {
+					duration: 600,
+					easing: tween.easeOut,
+					onFinish: function onFinish() {
+						chickenGraphics.rotation = 0;
+						chickenGraphics.scaleX = -1; // Facing right
+						self.somersaulting = false;
+					}
+				});
 			}
 		}
 		if (self.y < bounds.top) {
 			self.y = bounds.top;
 			self.vy = -self.vy * self.bounceDecay;
 		} else if (self.y > bounds.bottom) {
 			self.y = bounds.bottom;
-			// Normal vertical bounce if not in a corner
 			self.vy = -self.vy * self.bounceDecay;
 		}
-		// Check if stuck in ropes (very low velocity but still touching a rope)
-		var touchingRope = false;
-		if (ropes && ropes.length > 0) {
-			for (var i = 0; i < ropes.length; i++) {
-				if (self.intersects(ropes[i])) {
-					touchingRope = true;
-					break;
-				}
-			}
-		}
-		if (touchingRope && Math.abs(self.vx) < 1 && Math.abs(self.vy) < 1) {
-			// Apply escape velocity in a random direction to break free with greater force
-			var escapeAngle = Math.random() * Math.PI * 2;
-			self.vx = Math.cos(escapeAngle) * 8; // Reduced escape velocity
-			self.vy = Math.sin(escapeAngle) * 8; // Reduced escape velocity
-			// Reset last bounce position to allow for new bounce
-			self.lastBouncePosition.x = -9999;
-			self.lastBouncePosition.y = -9999;
-			// Clear last rope collision to allow immediate rebounce
-			self.lastRopeCollision = null;
-		}
 		// Check if stopped
-		else if (Math.abs(self.vx) < 0.5 && Math.abs(self.vy) < 0.5 && self.bounceCount > 0) {
+		if (Math.abs(self.vx) < 0.5 && Math.abs(self.vy) < 0.5 && self.bounceCount > 0) {
 			self.launched = false;
 			// Notify game that chicken jockey has stopped
 			if (typeof game.onChickenJockeyStop === 'function') {
 				game.onChickenJockeyStop();
@@ -178,13 +191,8 @@
 		}
 		// Bounce from side to side
 		if (self.x <= bounds.left || self.x >= bounds.right) {
 			self.vx = -self.vx * self.bounceDecay;
-			// Add a minimum velocity to prevent getting stuck
-			if (Math.abs(self.vx) < 3) {
-				// Reduced minimum velocity
-				self.vx = self.vx > 0 ? 3 : -3;
-			}
 			self.bounceCount++;
 			LK.getSound('bounce').play();
 			game.addScore(2000);
 		}
@@ -440,10 +448,10 @@
 		if (self.points.length < 2) {
 			pathGraphics.alpha = 0;
 			return;
 		}
-		pathGraphics.alpha = 0.7;
-		// Calculate path visual representation for slingshot
+		pathGraphics.alpha = 0.8;
+		// Calculate path visual representation
 		var firstPoint = self.points[0];
 		var lastPoint = self.points[self.points.length - 1];
 		// Position at midpoint of path
 		self.x = (firstPoint.x + lastPoint.x) / 2;
@@ -452,15 +460,19 @@
 		var dx = lastPoint.x - firstPoint.x;
 		var dy = lastPoint.y - firstPoint.y;
 		var length = Math.sqrt(dx * dx + dy * dy);
 		var angle = Math.atan2(dy, dx);
-		// Update path graphics with thicker line for slingshot
+		// Update path graphics for slingshot visual - thicker line
 		pathGraphics.width = length;
-		pathGraphics.height = Math.max(10, 30 * (length / 300)); // Variable thickness based on pull distance
+		pathGraphics.height = 10; // Make line thicker for slingshot
 		pathGraphics.rotation = angle;
-		// Change color based on pull strength (from green to red)
-		var pullStrength = Math.min(1, length / 400);
-		pathGraphics.tint = 0x00FF00 + Math.floor(pullStrength * 255) * 0x010000 - Math.floor(pullStrength * 255) * 0x000100;
+		// Make path color change based on pull length (strength indicator)
+		var strengthRatio = Math.min(length, 300) / 300; // Normalize to 0-1
+		// Color transitions from green (weak) to yellow to red (strong)
+		var r = strengthRatio > 0.5 ? 255 : Math.floor(255 * (strengthRatio * 2));
+		var g = strengthRatio < 0.5 ? 255 : Math.floor(255 * (2 - strengthRatio * 2));
+		var color = (r << 16) + (g << 8);
+		pathGraphics.tint = color;
 	};
 	return self;
 });
 var Popcorn = Container.expand(function () {
@@ -585,55 +597,202 @@
 	});
 	// Rope properties
 	self.tension = 0.8; // Increased tension for more springy, elastic bounces
 	self.bounce = function (chickenJockey) {
+		// Check if we've already bounced in the same place to prevent getting stuck
+		var distFromLastBounce = Math.sqrt(Math.pow(chickenJockey.x - chickenJockey.lastBouncePosition.x, 2) + Math.pow(chickenJockey.y - chickenJockey.lastBouncePosition.y, 2));
+		// If too close to last bounce position, give an extra boost to escape
+		if (distFromLastBounce < 50) {
+			// Extra velocity away from the rope
+			var awayX = chickenJockey.x - self.x;
+			var awayY = chickenJockey.y - self.y;
+			var awayDist = Math.sqrt(awayX * awayX + awayY * awayY);
+			if (awayDist > 0) {
+				chickenJockey.vx += awayX / awayDist * 10;
+				chickenJockey.vy += awayY / awayDist * 10;
+			}
+		}
 		// Store current position as last bounce position
 		chickenJockey.lastBouncePosition.x = chickenJockey.x;
 		chickenJockey.lastBouncePosition.y = chickenJockey.y;
+		// Store original position for rope displacement effect
+		var originalX = self.x;
+		var originalY = self.y;
 		// Calculate normal angle (perpendicular to rope)
 		var normalAngle = Math.atan2(chickenJockey.y - self.y, chickenJockey.x - self.x);
 		// Account for rope rotation when calculating normal
 		normalAngle += self.rotation + Math.PI / 2;
 		// Calculate velocity components
 		var speed = Math.sqrt(chickenJockey.vx * chickenJockey.vx + chickenJockey.vy * chickenJockey.vy);
 		var incomingAngle = Math.atan2(chickenJockey.vy, chickenJockey.vx);
-		// Calculate angle of reflection (standard reflection physics)
-		var bounceAngle = 2 * normalAngle - incomingAngle;
-		// Apply standard bounce physics
-		chickenJockey.vx = Math.cos(bounceAngle) * speed * chickenJockey.bounceDecay;
-		chickenJockey.vy = Math.sin(bounceAngle) * speed * chickenJockey.bounceDecay;
 		// Flip the chicken based on horizontal velocity after bounce
 		var chickenGraphics = chickenJockey.getChildAt(0);
 		if (chickenJockey.vx > 0) {
 			if (chickenGraphics.scaleX !== -1) {
-				chickenGraphics.scaleX = -1; // Facing right
+				// Starting a flip from left to right
+				chickenJockey.somersaulting = true;
+				chickenJockey.somersaultDirection = 1;
+				chickenJockey.somersaultRotation = 0;
+				// Start somersault animation with tween
+				tween.stop(chickenGraphics); // Stop any existing rotation animations
+				tween(chickenGraphics, {
+					rotation: Math.PI * 2
+				}, {
+					duration: 600,
+					easing: tween.easeOut,
+					onFinish: function onFinish() {
+						chickenGraphics.rotation = 0;
+						chickenGraphics.scaleX = -1; // Facing right
+						chickenJockey.somersaulting = false;
+					}
+				});
 			}
 		} else {
 			if (chickenGraphics.scaleX !== 1) {
-				chickenGraphics.scaleX = 1; // Facing left
+				// Starting a flip from right to left
+				chickenJockey.somersaulting = true;
+				chickenJockey.somersaultDirection = -1;
+				chickenJockey.somersaultRotation = 0;
+				// Start somersault animation with tween
+				tween.stop(chickenGraphics); // Stop any existing rotation animations
+				tween(chickenGraphics, {
+					rotation: -Math.PI * 2
+				}, {
+					duration: 600,
+					easing: tween.easeOut,
+					onFinish: function onFinish() {
+						chickenGraphics.rotation = 0;
+						chickenGraphics.scaleX = 1; // Facing left
+						chickenJockey.somersaulting = false;
+					}
+				});
 			}
 		}
+		// Calculate angle of reflection
+		var bounceAngle = 2 * normalAngle - incomingAngle;
+		// Calculate new velocity with enhanced force based on incoming speed
+		// Higher incoming speed = stronger bounce back effect
+		var bounceForce = speed * self.tension * (1 + Math.min(1.0, speed / 20)); // Further adjusted to depend more on incoming velocity
+		// Ensure minimum bounce force to prevent getting stuck
+		bounceForce = Math.max(bounceForce, 5);
+		// Add screen shake effect on powerful impacts
+		if (speed > 20) {
+			// Custom screen shake effect using tween
+			var originalPosition = {
+				x: game.x,
+				y: game.y
+			};
+			tween(game, {
+				x: originalPosition.x + (Math.random() - 0.5) * 20,
+				y: originalPosition.y + (Math.random() - 0.5) * 20
+			}, {
+				duration: 100,
+				easing: tween.easeInOut,
+				onFinish: function onFinish() {
+					tween(game, {
+						x: originalPosition.x,
+						y: originalPosition.y
+					}, {
+						duration: 100,
+						easing: tween.easeInOut
+					});
+				}
+			});
+		}
+		// Reduce random angle variation for more predictable wrestling-style bounces
+		var angleVariation = (Math.random() - 0.5) * 0.05; // Further reduced random angle adjustment for predictability
+		bounceAngle += angleVariation;
+		// Apply immediate minimum velocity to prevent sticking
+		var minVelocity = 3.0;
+		chickenJockey.vx = Math.cos(bounceAngle) * Math.max(bounceForce * 0.3, minVelocity) * chickenJockey.bounceDecay;
+		chickenJockey.vy = Math.sin(bounceAngle) * Math.max(bounceForce * 0.3, minVelocity) * chickenJockey.bounceDecay;
+		// Brief pause to simulate rope stretching and chicken "sticking" to rope momentarily
+		// Store original velocities but don't slow down as much to prevent sticking
+		var originalVX = chickenJockey.vx;
+		var originalVY = chickenJockey.vy;
+		// Momentarily slow down the chicken but not enough to get stuck
+		chickenJockey.vx *= 0.3;
+		chickenJockey.vy *= 0.3;
+		// Add a slight delay before applying the bounce-back force
+		LK.setTimeout(function () {
+			// Now apply the full bounce force with enhanced velocity
+			chickenJockey.vx = Math.cos(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
+			chickenJockey.vy = Math.sin(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
+			// Add a burst of rotation to simulate impact force
+			chickenJockey.rotationSpeed = (Math.random() - 0.5) * 0.2; // Increased rotation burst for more dramatic impact
+		}, 30);
+		// Create enhanced bounce visual effect with more dramatic rope "give"
+		tween(self, {
+			scaleY: 1.8,
+			// More dramatic stretch
+			alpha: 0.7,
+			// Add slight displacement in direction of impact
+			x: originalX + Math.cos(incomingAngle) * 10,
+			y: originalY + Math.sin(incomingAngle) * 10
+		}, {
+			duration: 200,
+			// Extended stretch duration
+			easing: tween.easeOut,
+			onFinish: function onFinish() {
+				// After brief delay, apply the full bounce force
+				// We're not setting additional velocity here to prevent doubling the effect
+				LK.setTimeout(function () {
+					// Ensure the chicken is still moving away from the rope
+					if (Math.abs(chickenJockey.vx) < minVelocity && Math.abs(chickenJockey.vy) < minVelocity) {
+						chickenJockey.vx = Math.cos(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
+						chickenJockey.vy = Math.sin(bounceAngle) * bounceForce * chickenJockey.bounceDecay;
+					}
+					// Add a burst of rotation to simulate impact force
+					chickenJockey.rotationSpeed = (Math.random() - 0.5) * 0.15;
+				}, 30);
+				// Snap the rope back with more dramatic effect
+				tween(self, {
+					scaleY: 1.0,
+					alpha: 1.0,
+					x: originalX,
+					y: originalY
+				}, {
+					duration: 500,
+					// Longer snap-back for more visual impact
+					easing: tween.elasticOut,
+					onFinish: function onFinish() {
+						// Add rope vibration effect after snap-back
+						tween(self, {
+							x: originalX + Math.sin(LK.ticks * 0.1) * 5,
+							y: originalY + Math.cos(LK.ticks * 0.1) * 5
+						}, {
+							duration: 300,
+							easing: tween.easeInOut,
+							onFinish: function onFinish() {
+								// Reset position after vibration
+								self.x = originalX;
+								self.y = originalY;
+							}
+						});
+					}
+				});
+			}
+		});
 		// Increment bounce count
 		chickenJockey.bounceCount++;
-		// Play bounce sound
-		LK.getSound('bounce').play();
-		// Play chicken cluck sound
+		// Play bounce sound with increased volume for high-speed bounces
+		var bounceSound = LK.getSound('bounce');
+		bounceSound.volume = Math.min(1, speed / 30); // Increase volume based on speed
+		bounceSound.play();
+		// Play chicken cluck sound when chicken bounces off ropes
 		LK.getSound('Chickencluck').play();
-		// Simple visual feedback
-		LK.effects.flashObject(self, 0xFFFFFF, 200);
-		// Add points for bouncing
-		var somersaultBonus = Math.min(10, chickenJockey.bounceCount) * 500;
+		// Flash rope to indicate bounce with more intensity for high-speed bounces
+		var flashIntensity = Math.min(0xFFFFFF, 0xFFFFFF * (speed / 30));
+		LK.effects.flashObject(self, flashIntensity, 200);
+		// Add points for bouncing - more points for higher somersault count
+		var somersaultBonus = Math.min(10, chickenJockey.bounceCount) * 500; // Bonus increases with somersault count
 		if (typeof game.addScore === 'function') {
 			game.addScore(5000 + somersaultBonus);
 		}
-		// Spawn popcorn
-		if (Math.random() < 0.5 && typeof game.createPopcornAt === 'function') {
-			game.createPopcornAt(chickenJockey.x, chickenJockey.y, 3);
+		// Spawn more popcorn on rope bounce (increased chance and count)
+		if (Math.random() < 0.7 && typeof game.createPopcornAt === 'function') {
+			game.createPopcornAt(chickenJockey.x, chickenJockey.y, 5);
 		}
-		// Clear last rope collision after a short delay
-		LK.setTimeout(function () {
-			chickenJockey.lastRopeCollision = null;
-		}, 50);
 	};
 	self.intersectsWithPoint = function (x, y) {
 		var halfWidth = ropeGraphics.width / 2;
 		var halfHeight = ropeGraphics.height / 2;
@@ -840,8 +999,20 @@
 	// Create bottom rope
 	var bottomRope = new Rope();
 	bottomRope.x = arena.x;
 	bottomRope.y = bounds.bottom - 100;
+	bottomRope.bounce = function (chickenJockey) {
+		// Prevent the bottom rope from moving down with stronger upward bounce
+		var speed = Math.sqrt(chickenJockey.vx * chickenJockey.vx + chickenJockey.vy * chickenJockey.vy);
+		var upwardForce = Math.max(10, speed * 0.8);
+		// Apply minimum upward velocity to prevent sticking
+		chickenJockey.vy = -upwardForce * chickenJockey.bounceDecay;
+		// Move chicken slightly up to avoid rope overlap
+		chickenJockey.y -= 20;
+		chickenJockey.bounceCount++;
+		LK.getSound('bounce').play();
+		game.addScore(2000);
+	};
 	game.addChild(bottomRope);
 	ropes.push(bottomRope);
 	// Create left rope
 	var leftRope = new Rope();
@@ -901,9 +1072,11 @@
 		// Game over
 		instructionText.setText("Game Over! Final Score: " + score);
 		gameState = "gameOver";
 		// Show game over after a short delay
-		// Removed call to LK.showGameOver to prevent freezing and default win screen
+		LK.setTimeout(function () {
+			LK.showGameOver();
+		}, 2000);
 	} else {
 		// Reset for next launch
 		resetChickenJockey();
 		instructionText.setText("Drag to aim and launch the chicken!");
@@ -923,9 +1096,9 @@
 		gameState = "aiming";
 		dragStartX = x;
 		dragStartY = y;
 		pathTracer.startTracing(x, y);
-		instructionText.setText("Pull back to launch the chicken!");
+		instructionText.setText("Pull back to launch chicken!");
 	}
 	// Add quick tap detection for increasing somersaults when chicken is launched
 	else if (gameState === "launched" && chickenJockey.launched) {
 		// Increase max bounces to allow more somersaults
@@ -951,18 +1124,18 @@
 		if (path && path.length >= 2) {
 			// Record drag end position
 			dragEndX = x;
 			dragEndY = y;
-			// Get start and end points for slingshot launch
+			// Get start and end points for slingshot mechanics
 			var startPoint = path[0];
 			var endPoint = path[path.length - 1];
-			// Launch the chicken with slingshot mechanics (from start to end)
+			// Launch the chicken using slingshot mechanics
 			chickenJockey.launch(startPoint.x, startPoint.y, endPoint.x, endPoint.y);
 			// Update game state
 			gameState = "launched";
 			launches++;
 			launchesText.setText("Launches: " + launches + "/" + maxLaunches);
-			instructionText.setText("Watch the chicken fly!");
+			instructionText.setText("Watch the chicken bounce!");
 		} else {
 			// Cancel the launch if the path was too short
 			gameState = "ready";
 		}
@@ -990,9 +1163,8 @@
 			multiplierText.x = chickenJockey.x;
 			multiplierText.y = chickenJockey.y - 180;
 			game.addChild(multiplierText);
 			// Animate multiplier text
-			tween.stop(multiplierText);
 			tween(multiplierText, {
 				y: multiplierText.y - 100,
 				alpha: 0
 			}, {
@@ -1070,9 +1242,9 @@
 };
 // Power-up activation function
 game.activatePowerUp = function (type, value, duration) {
 	// Visual feedback for power-up activation
-	// Removed LK.effects.flashScreen to prevent green and yellow screen flashes
+	LK.effects.flashScreen(0x00FFFF, 500);
 	if (type === "multiplier") {
 		// Set score multiplier
 		scoreMultiplier = value;
 		// Display message
@@ -1159,44 +1331,29 @@
 		chickenJockey.update();
 		if (chickenJockey.lastRopeCollision === undefined) {
 			chickenJockey.lastRopeCollision = null;
 		}
-		// Count how many ropes the chicken is intersecting
-		var intersectingRopes = 0;
+		// Check for collisions with ropes
 		for (var i = 0; i < ropes.length; i++) {
-			if (chickenJockey.intersects(ropes[i])) {
-				intersectingRopes++;
-			}
-		}
-		// If intersecting multiple ropes (stuck in corner/intersection), just set lastRopeCollision to null
-		if (intersectingRopes > 1) {
-			// Just clear the last rope collision to allow for a new rope bounce
-			chickenJockey.lastRopeCollision = null;
-		}
-		// Normal single rope collision handling
-		else {
-			// Check for collisions with ropes
-			for (var i = 0; i < ropes.length; i++) {
-				// Only bounce if we weren't already intersecting this rope
-				if (chickenJockey.intersects(ropes[i]) && chickenJockey.lastRopeCollision !== ropes[i]) {
-					// Calculate direction vectors for bounce
-					var dx = chickenJockey.x - ropes[i].x;
-					var dy = chickenJockey.y - ropes[i].y;
-					var dist = Math.sqrt(dx * dx + dy * dy);
-					// Push chicken away from rope slightly to prevent sticking
-					if (dist > 0) {
-						chickenJockey.x += dx / dist * 10;
-						chickenJockey.y += dy / dist * 10;
-					}
-					ropes[i].bounce(chickenJockey);
-					chickenJockey.lastRopeCollision = ropes[i];
-					// Clear last rope collision after a shorter delay to allow for new collisions
-					LK.setTimeout(function () {
-						chickenJockey.lastRopeCollision = null;
-					}, 100); // Reduced from 150 to 100ms
-					// Only bounce on one rope per frame to prevent chaotic behavior
-					break;
+			// Only bounce if we weren't already intersecting this rope
+			if (chickenJockey.intersects(ropes[i]) && chickenJockey.lastRopeCollision !== ropes[i]) {
+				// Calculate direction vectors for bounce
+				var dx = chickenJockey.x - ropes[i].x;
+				var dy = chickenJockey.y - ropes[i].y;
+				var dist = Math.sqrt(dx * dx + dy * dy);
+				// Push chicken away from rope slightly to prevent sticking
+				if (dist > 0) {
+					chickenJockey.x += dx / dist * 10;
+					chickenJockey.y += dy / dist * 10;
 				}
+				ropes[i].bounce(chickenJockey);
+				chickenJockey.lastRopeCollision = ropes[i];
+				// Clear last rope collision after a shorter delay to allow for new collisions
+				LK.setTimeout(function () {
+					chickenJockey.lastRopeCollision = null;
+				}, 150);
+				// Only bounce on one rope per frame to prevent chaotic behavior
+				break;
 			}
 		}
 		// Check for collisions with popcorn
 		for (var i = popcorns.length - 1; i >= 0; i--) {
@@ -1310,9 +1467,9 @@
 			freeText.scaleX = 0.5;
 			freeText.scaleY = 0.5;
 			LK.gui.center.addChild(freeText);
 			// Flash the screen for dramatic effect
-			// Removed LK.effects.flashScreen to prevent green and yellow screen flashes
+			LK.effects.flashScreen(0xFFFF00, 300);
 			// Animate in with bounce effect
 			tween(freeText, {
 				alpha: 1,
 				scaleX: 1.2,
@@ -1376,9 +1533,9 @@
 	freeText.scaleX = 0.5;
 	freeText.scaleY = 0.5;
 	LK.gui.center.addChild(freeText);
 	// Flash screen
-	// Removed LK.effects.flashScreen to prevent green and yellow screen flashes
+	LK.effects.flashScreen(0x00FF00, 300);
 	// Animate the text
 	tween(freeText, {
 		alpha: 1,
 		scaleX: 1.2,
:quality(85)/https://cdn.frvr.ai/680e2cb731e90df6e3a79663.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/680f25b74b91ed99c0c93065.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68107d72af890f4678fa3c0c.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6811f7e547f9689b747b894b.png%3F3) 
 X5 symbol. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6811f84547f9689b747b8951.png%3F3) 
 X2 symbol. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6812d11c31e90df6e3a797a7.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6812d23e21b2d4faceef26d6.png%3F3) 
 Super popcorn yellow. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814a4059dcd06d468edb7f4.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814a730211045a0f483816f.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814a81e211045a0f4838182.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814a94a211045a0f483818b.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814aa19211045a0f4838190.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814aae1211045a0f4838194.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814dcf6bef1291d4e518ee7.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6814e89f0e23fbc7292fa249.png%3F3) 
 Start button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814e9750e23fbc7292fa26a.png%3F3) 
 High score button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814ea630e23fbc7292fa285.png%3F3) 
 Back button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814eb8e0e23fbc7292fa299.png%3F3) 
 SELECT YOUR CHARACTER button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814ed0e0e23fbc7292fa2b0.png%3F3) 
 Launches button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814f180fb90c04ce18c733a.png%3F3) 
 How to play button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814f1d4fb90c04ce18c733e.png%3F3) 
 Score button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814fcd30e23fbc7292fa369.png%3F3) 
 High Scores button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814fe1d0e23fbc7292fa377.png%3F3) 
 Transparent padlock. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6814ff160e23fbc7292fa382.png%3F3) 
 Chicken jockey character. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6815cc2e1a2f31aebc36772c.png%3F3) 
 Reset scores button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6815e8706137896f737201af.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6816d35ae16864a155151a6f.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6816db39d574efc6b10a8c23.png%3F3) 
 Spider jockey unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6816dba1d574efc6b10a8c2b.png%3F3) 
 Minecraft Steve unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6816dc6cd574efc6b10a8c3b.png%3F3) 
 Piglin unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6816dcafd574efc6b10a8c41.png%3F3) 
 Minecraft skeleton unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6816dd05d574efc6b10a8c49.png%3F3) 
 Minecraft villager unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6817072827945e34d88365bf.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6817077827945e34d88365c7.png%3F3) 
 Star. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681707d227945e34d88365cd.png%3F3) 
 White star. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681709c927945e34d88365da.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68170ba127945e34d88365fe.png%3F3) 
 Red heart. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68170bea27945e34d8836604.png%3F3) 
 Purple heart. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68170c3730f9a3ca3143c36b.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68170df027945e34d8836617.png%3F3) 
 A peanut. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68170e3627945e34d883661c.png%3F3) 
 Cashew nut. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6817137327945e34d883666e.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681717d45557ee2046ecc2f7.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68171a3c27945e34d883669c.png%3F3) 
 Grimace shake. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68171a8627945e34d88366a8.png%3F3) 
 MacDonald's fries. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68172b1b527b05c35818e92d.png%3F3) 
 Grimace unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68176ba74a0979b918f7a043.png%3F3) 
 Michael Jackson unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68176bfb4a0979b918f7a047.png%3F3) 
 John Cena unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681848065557ee2046ecc355.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681852a92383a43353c7548b.png%3F3) 
 Deez nuts unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681852f02383a43353c75498.png%3F3) 
 Shooting stars unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68185b748a0e5c4bce224097.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681875d52be3391f326409d8.png%3F3) 
 Rick roll unlocked button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681952795557ee2046ecc397.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6819530ee4bfd0bbff165058.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681c8c14c433709b9f3496bb.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681c9e526135700112f879bd.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681d93b51b9e5a67ebab2a52.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681d95da1b9e5a67ebab2a5f.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681e1884c7ebd23c4bdd5928.png%3F3) 
 Popcorn chicken. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681e18f9c7ebd23c4bdd5939.png%3F3) 
 Fried chicken drumstick. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681eb5fbce5c2130acf291bd.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681eb6868578d3fadb9cac49.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681eb95249de8df9599c5b97.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681ebb3049de8df9599c5ba9.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681ee624b1146135aaefe63c.png%3F3) 
 Amazing digital circus button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681ef7e841b5fb6826081a28.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681ef98cce5c2130acf291c1.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681ef9efce5c2130acf291c3.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/681f82fa4de4664a77b8eb6f.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6826b332054039919f0a089c.png%3F3) 
 Select game mode button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6826bbff97a2158c01b6e945.png%3F3) 
 Diamond shaped colourful classic mode button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6826c2d197a2158c01b6e963.png%3F3) 
 Diamond shaped colourful mini games button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6827168900c54e0648f3278d.png%3F3) 
 Same picture in high definition
:quality(85)/https://cdn.frvr.ai/6827414625df75ae7a4de4a6.png%3F3) 
 Diamond shaped colourful button that says sling shot mode. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/682548fd80be55c1986a9d45.png%3F3) 
 Make picture transparent
:quality(85)/https://cdn.frvr.ai/6827dcc4f0da5bc629928468.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6827fd58f0da5bc629928492.png%3F3) 
 Bullet. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6827fdd2f0da5bc6299284a3.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6828170b80d2c88911cb1d24.png%3F3) 
 Start game button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/682b446c031377340829c968.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/682b45b0031377340829ca5d.png%3F3) 
 Shooting gallery button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/682ec3c623c50e12668ce9bd.png%3F3) 
 Chain reaction button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/682ecaa723c50e12668cea01.png%3F3) 
 Realistic space backdrop. In-Game asset. 2d. High contrast. No shadows
launch
Sound effect
Gamestart
Sound effect
collect
Sound effect
gameMusic
Music
Gamemusic
Sound effect
Bogerk
Sound effect
pop
Sound effect
Pignoise
Sound effect
Steve
Sound effect
Villager
Sound effect
Spider
Sound effect
Skeleton
Sound effect
Shootingstars
Music
Maccas
Sound effect
Grimace
Sound effect
Thriller
Music
MJ
Sound effect
Cenaentrance
Music
Johncena
Sound effect
Chickencluck
Sound effect
Deeznuts
Sound effect
Deeznutstrap
Music
Rickroll
Sound effect
Nevergonna
Music
Starz
Sound effect
Grimaceshake
Music
Joenugget
Sound effect
gegagedi
Music
Shrek
Sound effect
Raveswamp
Music
Pomni
Sound effect
Digcircus
Music
Runandgo
Music
Gunshot
Sound effect
Reelbadman
Sound effect
Tinggoes
Music