User prompt
Add more popcorn to numbers
User prompt
Make number pattern twice it's size by adding more popcorn
User prompt
Add collect sounds when popcorn is collected
User prompt
Make number pattern double the current size
User prompt
Make the numbers fill up the arena
User prompt
Remove high score background on title screen
User prompt
Create title screen with titlescreen asset as backdrop and add start button and high score button to titlescreen βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
Remove high score tally from screen during gameplay
User prompt
Leave high score screen up and add a start button and reset scores button
User prompt
Add high score tally with top 10 scores at beginning and end of the game βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Decrease popcorn size to original size
User prompt
Make popcorn numbers bigger and centred in the arena
User prompt
Make popcorn numbers bigger and stay on screen longer
User prompt
Make popcorn appear in number patterns from 1 to 9
User prompt
If chicken moves in a figure 8 award player 1000000 points
User prompt
If chicken jockey moves in a figure 8 award player 1000000 points
User prompt
Award 1000000 points of the player draws an 8
User prompt
Remove the X5 bonus
User prompt
Reset the flag every time it has been awarded
User prompt
When arena has no popcorn left on screen award X5 bonus
User prompt
Make popcorn move randomly around arena
User prompt
Randomly position superpopcorn 200 pixels away from ropes
User prompt
Randomly position popcorn at least 200 pixels away from ropes
User prompt
Move popcorn away from ropes
User prompt
Remove bounce from ropes
/**** 
* 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; // No gravity
	self.bounceDecay = 0.8; // Reduced energy loss per bounce
	self.friction = 0.99; // Reduced friction to maintain horizontal momentum
	self.launched = false;
	self.bounceCount = 0;
	self.maxBounces = 10;
	// Rotation properties
	self.rotationSpeed = 0;
	self.path = [];
	self.currentPathIndex = 0;
	self.pathSpeed = 15; // Speed at which chicken follows the path
	self.launch = function (power, angle, path) {
		// Store the path for later use
		self.path = path || [];
		self.currentPathIndex = 0;
		// Reset values
		self.vx = 0;
		self.vy = 0;
		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.update = function () {
		if (!self.launched) {
			return;
		}
		// Follow path if we have one
		if (self.path.length > 0 && self.currentPathIndex < self.path.length) {
			// Get target point
			var targetPoint = self.path[self.currentPathIndex];
			// Calculate direction to target
			var dx = targetPoint.x - self.x;
			var dy = targetPoint.y - self.y;
			var distance = Math.sqrt(dx * dx + dy * dy);
			// Move towards target point
			if (distance > self.pathSpeed) {
				self.vx = dx / distance * self.pathSpeed;
				self.vy = dy / distance * self.pathSpeed;
			} else {
				// Reached current target point, move to next
				self.currentPathIndex++;
				if (self.currentPathIndex >= self.path.length) {
					// End of path
					self.vx = 0;
					self.vy = 0;
				}
			}
		} else {
			// Apply friction when not following path
			self.vx *= self.friction;
			self.vy *= self.friction;
		}
		// Update position
		self.x += self.vx;
		self.y += self.vy;
		// Apply rotation based on movement direction
		if (Math.abs(self.vx) > 0.1 || Math.abs(self.vy) > 0.1) {
			var targetRotation = Math.atan2(self.vy, self.vx);
			// Gradually rotate towards movement direction
			var rotDiff = targetRotation - self.rotation;
			// Normalize angle
			while (rotDiff > Math.PI) {
				rotDiff -= Math.PI * 2;
			}
			while (rotDiff < -Math.PI) {
				rotDiff += Math.PI * 2;
			}
			// Apply rotation
			self.rotation += rotDiff * 0.1;
		}
		// Check if stopped
		if (Math.abs(self.vx) < 0.5 && Math.abs(self.vy) < 0.5 && (self.bounceCount > 0 || self.currentPathIndex >= self.path.length)) {
			self.launched = false;
			// Notify game that chicken jockey has stopped
			if (typeof game.onChickenJockeyStop === 'function') {
				game.onChickenJockeyStop();
			}
		}
		// 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 Launcher = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach launcher asset with alpha 0 to make it invisible
	var launcherGraphics = self.attachAsset('launcher', {
		anchorX: 0.5,
		anchorY: 0.5,
		alpha: 0
	});
	// Create aim line (initially invisible)
	var aimLine = self.attachAsset('aimLine', {
		anchorX: 0,
		anchorY: 0.5,
		alpha: 0
	});
	// Launcher properties
	self.angle = -45; // Starting angle in degrees
	self.power = 20; // Increased starting power
	self.maxPower = 40; // Increased maximum power
	self.aiming = false;
	self.drawingPath = false;
	self.points = [];
	self.startX = 0;
	self.startY = 0;
	self.currentX = 0;
	self.currentY = 0;
	self.lastPointTime = 0;
	self.pathStep = 0;
	// Create trajectory path visualization
	self.trajectoryPath = new TrajectoryPath();
	// Start aim by drawing a path
	self.startAim = function (x, y) {
		self.aiming = true;
		self.drawingPath = true;
		self.startX = x;
		self.startY = y;
		self.currentX = x;
		self.currentY = y;
		self.points = [{
			x: x,
			y: y
		}];
		self.lastPointTime = LK.ticks;
		// Show the trajectory path
		if (self.trajectoryPath.parent) {
			self.trajectoryPath.show();
		}
	};
	// Store for drawing path
	self.pathGraphics = new Container();
	self.addChild(self.pathGraphics);
	self.updateAim = function (x, y) {
		if (!self.aiming) {
			return;
		}
		if (self.drawingPath) {
			// Update current position
			self.currentX = x;
			self.currentY = y;
			// Add a point every few frames to avoid too many points
			if (LK.ticks - self.lastPointTime > 2) {
				self.points.push({
					x: x,
					y: y
				});
				// Visualize the path point
				var pathPoint = LK.getAsset('aimLine', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y,
					scaleX: 0.3,
					scaleY: 0.3,
					alpha: 0.7
				});
				self.pathGraphics.addChild(pathPoint);
				self.lastPointTime = LK.ticks;
				// Update trajectory path to show the actual path
				if (self.trajectoryPath.parent && self.points.length > 1) {
					self.trajectoryPath.updatePathFromPoints(self.points);
				}
			}
			// Calculate direction vector from start to current position
			var dx = x - self.startX;
			var dy = y - self.startY;
			// Calculate angle in degrees (0 is right, 90 is up)
			self.angle = Math.atan2(dy, dx) * 180 / Math.PI;
			// Calculate power based on path length
			var distance = Math.sqrt(dx * dx + dy * dy);
			self.power = Math.min(distance / 10, self.maxPower);
			// Update launcher rotation
			self.rotation = self.angle * Math.PI / 180;
		}
	};
	self.endAim = function () {
		self.aiming = false;
		self.drawingPath = false;
		// Hide trajectory path
		if (self.trajectoryPath.parent) {
			self.trajectoryPath.hide();
		}
		// Keep a copy of the path points
		var pathPoints = self.points.slice();
		// Clear the path visualization after a delay
		LK.setTimeout(function () {
			// Remove all path point graphics
			while (self.pathGraphics.children.length > 0) {
				self.pathGraphics.removeChild(self.pathGraphics.children[0]);
			}
		}, 500);
		// Calculate final launch parameters
		var finalAngle = self.angle + 180; // Reverse direction
		// Return launch parameters
		return {
			angle: finalAngle,
			power: self.power
		};
	};
	return self;
});
var NumberPattern = Container.expand(function () {
	var self = Container.call(this);
	// Patterns for numbers 1-9, each represented as a 5x5 grid
	// 1 = popcorn, 0 = empty space
	self.patterns = {
		1: [[0, 0, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0]],
		2: [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 1, 0, 0, 0], [1, 1, 1, 1, 1]],
		3: [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]],
		4: [[0, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 1, 0]],
		5: [[1, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 1], [1, 1, 1, 1, 0]],
		6: [[0, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]],
		7: [[1, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0]],
		8: [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]],
		9: [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [0, 1, 1, 1, 1], [0, 0, 0, 0, 1], [0, 1, 1, 1, 0]]
	};
	// Create popcorn in a number pattern
	self.createPattern = function (number, centerX, centerY, spacing) {
		if (number < 1 || number > 9 || !self.patterns[number]) {
			return [];
		}
		var pattern = self.patterns[number];
		var patternHeight = pattern.length;
		var patternWidth = pattern[0].length;
		var createdPopcorns = [];
		// Calculate starting position to center the pattern
		var startX = centerX - patternWidth * spacing / 2;
		var startY = centerY - patternHeight * spacing / 2;
		// Create popcorn for each position in the pattern
		for (var row = 0; row < patternHeight; row++) {
			for (var col = 0; col < patternWidth; col++) {
				if (pattern[row][col] === 1) {
					var popcorn = new Popcorn();
					popcorn.x = startX + col * spacing;
					popcorn.y = startY + row * spacing;
					createdPopcorns.push(popcorn);
				}
			}
		}
		return createdPopcorns;
	};
	return self;
});
var NumberPatternGrid = Container.expand(function () {
	var self = Container.call(this);
	// Grid properties
	self.cellSize = 100; // Size of each grid cell
	self.padding = 50; // Padding around the grid
	self.currentPattern = null; // Current active pattern
	self.gridCells = []; // Store all grid cells
	// Initialize grid based on available space
	self.initGrid = function (arenaWidth, arenaHeight, bounds) {
		// Calculate grid dimensions
		self.columns = Math.floor((arenaWidth - self.padding * 2) / self.cellSize);
		self.rows = Math.floor((arenaHeight - self.padding * 2) / self.cellSize);
		// Clear existing grid
		while (self.children.length > 0) {
			self.removeChild(self.children[0]);
		}
		self.gridCells = [];
		// Create grid
		for (var row = 0; row < self.rows; row++) {
			self.gridCells[row] = [];
			for (var col = 0; col < self.columns; col++) {
				var cell = new Container();
				cell.x = bounds.left + self.padding + col * self.cellSize + self.cellSize / 2;
				cell.y = bounds.top + self.padding + row * self.cellSize + self.cellSize / 2;
				cell.row = row;
				cell.col = col;
				cell.filled = false;
				cell.popcorn = null;
				self.addChild(cell);
				self.gridCells[row][col] = cell;
			}
		}
	};
	// Fill the grid with a number pattern
	self.fillWithPattern = function (number) {
		if (number < 1 || number > 9) {
			return;
		}
		self.currentPattern = number;
		// Clear any existing popcorns
		self.clearAllPopcorn();
		// Create number pattern matrix (using patterns from NumberPattern class)
		var patternGen = new NumberPattern();
		var pattern = patternGen.patterns[number];
		// Center the pattern in the grid
		var patternHeight = pattern.length;
		var patternWidth = pattern[0].length;
		var startRow = Math.floor((self.rows - patternHeight) / 2);
		var startCol = Math.floor((self.columns - patternWidth) / 2);
		// Place popcorn for each '1' in the pattern
		for (var row = 0; row < patternHeight; row++) {
			for (var col = 0; col < patternWidth; col++) {
				var gridRow = startRow + row;
				var gridCol = startCol + col;
				// Skip if outside grid
				if (gridRow < 0 || gridRow >= self.rows || gridCol < 0 || gridCol >= self.columns) {
					continue;
				}
				var cell = self.gridCells[gridRow][gridCol];
				if (pattern[row][col] === 1) {
					// Create popcorn
					var popcorn = new Popcorn();
					popcorn.x = 0; // Position relative to cell
					popcorn.y = 0;
					cell.addChild(popcorn);
					cell.popcorn = popcorn;
					cell.filled = true;
				}
			}
		}
		return self.getPopcornList();
	};
	// Get a list of all popcorn in the grid
	self.getPopcornList = function () {
		var popcornList = [];
		for (var row = 0; row < self.rows; row++) {
			for (var col = 0; col < self.columns; col++) {
				var cell = self.gridCells[row][col];
				if (cell.filled && cell.popcorn) {
					popcornList.push(cell.popcorn);
				}
			}
		}
		return popcornList;
	};
	// Clear all popcorn from the grid
	self.clearAllPopcorn = function () {
		for (var row = 0; row < self.rows; row++) {
			for (var col = 0; col < self.columns; col++) {
				var cell = self.gridCells[row][col];
				if (cell.popcorn) {
					cell.removeChild(cell.popcorn);
					cell.popcorn = null;
					cell.filled = false;
				}
			}
		}
	};
	// Collect a specific popcorn
	self.collectPopcorn = function (popcorn) {
		for (var row = 0; row < self.rows; row++) {
			for (var col = 0; col < self.columns; col++) {
				var cell = self.gridCells[row][col];
				if (cell.popcorn === popcorn) {
					cell.filled = false;
					cell.popcorn = null;
					return true;
				}
			}
		}
		return false;
	};
	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 with spinning and scaling
		tween(self, {
			y: self.y - 100,
			rotation: Math.PI * 4,
			// Spin multiple times
			scaleX: 1.5,
			// Grow while spinning
			scaleY: 1.5,
			// Grow while spinning
			alpha: 0
		}, {
			duration: 800,
			// Longer duration for more visible animation
			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.targetX = self.x;
			self.targetY = self.y;
			self.moveTimer = 0;
			self.moveDuration = 180 + Math.random() * 120; // 3-5 seconds at 60fps
		}
		// Smooth hovering
		self.y = self.baseY + Math.sin(LK.ticks * self.animationSpeed + self.animationOffset) * 5;
		// Random movement
		self.moveTimer++;
		if (self.moveTimer >= self.moveDuration) {
			// Set new random target within arena bounds (with padding)
			var padding = 200;
			var newX = bounds.left + padding + Math.random() * (arena.width - padding * 2);
			var newY = bounds.top + padding + Math.random() * (arena.height - padding * 2);
			// Check distance from ropes
			var validPosition = true;
			for (var j = 0; j < ropes.length; j++) {
				var dx = newX - ropes[j].x;
				var dy = newY - ropes[j].y;
				var distance = Math.sqrt(dx * dx + dy * dy);
				if (distance < 200) {
					validPosition = false;
					break;
				}
			}
			if (validPosition) {
				self.targetX = newX;
				self.targetY = newY;
				self.baseY = newY;
				self.moveTimer = 0;
			}
		}
		// Move toward target with easing
		if (self.targetX !== self.x || self.targetY !== self.y) {
			self.x += (self.targetX - self.x) * 0.01;
			self.y += (self.targetY - self.y) * 0.01;
		}
	};
	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; // No tension for no bounce effect
	self.bounce = function (chickenJockey) {
		// No velocity change - completely removed bounce effect
		// Set velocity to zero in the direction of the rope
		if (self.rotation === 0 || self.rotation === Math.PI) {
			// Horizontal rope (top or bottom)
			chickenJockey.vy = 0;
		} else {
			// Vertical rope (left or right)
			chickenJockey.vx = 0;
		}
		// Still increment bounce count for tracking
		chickenJockey.bounceCount++;
		// Play bounce sound
		LK.getSound('bounce').play();
		// Flash rope to indicate contact
		LK.effects.flashObject(self, 0xFFFFFF, 200);
	};
	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 Superpopcorn = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach Superpopcorn asset
	var superPopcornGraphics = self.attachAsset('Superpopcorn', {
		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 with spinning and scaling
		tween(self, {
			y: self.y - 150,
			// Fly higher for superpopcorn
			rotation: Math.PI * 6,
			// Spin more times for superpopcorn
			scaleX: 2.0,
			// Grow larger while spinning
			scaleY: 2.0,
			// Grow larger while spinning
			alpha: 0
		}, {
			duration: 1000,
			// Longer duration for more visible animation
			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.targetX = self.x;
			self.targetY = self.y;
			self.moveTimer = 0;
			self.moveDuration = 120 + Math.random() * 60; // 2-3 seconds at 60fps (faster than regular popcorn)
		}
		// Smooth hovering with larger amplitude for superpopcorn
		self.y = self.baseY + Math.sin(LK.ticks * self.animationSpeed + self.animationOffset) * 8;
		// Random movement
		self.moveTimer++;
		if (self.moveTimer >= self.moveDuration) {
			// Set new random target within arena bounds (with padding)
			var padding = 200;
			var newX = bounds.left + padding + Math.random() * (arena.width - padding * 2);
			var newY = bounds.top + padding + Math.random() * (arena.height - padding * 2);
			// Check distance from ropes
			var validPosition = true;
			for (var j = 0; j < ropes.length; j++) {
				var dx = newX - ropes[j].x;
				var dy = newY - ropes[j].y;
				var distance = Math.sqrt(dx * dx + dy * dy);
				if (distance < 200) {
					validPosition = false;
					break;
				}
			}
			if (validPosition) {
				self.targetX = newX;
				self.targetY = newY;
				self.baseY = newY;
				self.moveTimer = 0;
			}
		}
		// Move toward target with easing (slightly faster than regular popcorn)
		if (self.targetX !== self.x || self.targetY !== self.y) {
			self.x += (self.targetX - self.x) * 0.015;
			self.y += (self.targetY - self.y) * 0.015;
		}
	};
	return self;
});
var TrajectoryPath = Container.expand(function () {
	var self = Container.call(this);
	// Properties
	self.points = [];
	self.maxPoints = 40; // Increased number of trajectory points for better visualization
	self.visible = false;
	// Create path line graphics
	self.pathLine = new Container();
	self.addChild(self.pathLine);
	// Create trajectory points
	self.createPoints = function () {
		// Clear existing points
		for (var i = 0; i < self.points.length; i++) {
			self.removeChild(self.points[i]);
		}
		self.points = [];
		// Create new points
		for (var i = 0; i < self.maxPoints; i++) {
			var point = new TrajectoryPoint();
			point.alpha = 1 - i / self.maxPoints;
			self.addChild(point);
			self.points.push(point);
		}
	};
	// Update trajectory path based on path points
	self.updatePathFromPoints = function (pathPoints) {
		if (!self.visible || !pathPoints || pathPoints.length < 2) {
			return;
		}
		// Clear existing path visualization
		while (self.pathLine.children.length > 0) {
			self.pathLine.removeChild(self.pathLine.children[0]);
		}
		// Draw path line segments
		for (var i = 0; i < pathPoints.length - 1; i++) {
			self.drawPathSegment(pathPoints[i], pathPoints[i + 1], i, pathPoints.length);
		}
		// Update trajectory points along the path
		for (var i = 0; i < self.points.length; i++) {
			var pointIndex = Math.floor(i * (pathPoints.length - 1) / self.points.length);
			if (pointIndex < pathPoints.length - 1) {
				var percent = i * (pathPoints.length - 1) / self.points.length - pointIndex;
				var p1 = pathPoints[pointIndex];
				var p2 = pathPoints[pointIndex + 1];
				self.points[i].x = p1.x + (p2.x - p1.x) * percent;
				self.points[i].y = p1.y + (p2.y - p1.y) * percent;
				self.points[i].alpha = 0.7 * (1 - i / self.points.length);
			}
		}
	};
	// Draw a segment of the path between two points
	self.drawPathSegment = function (p1, p2, index, total) {
		var segment = LK.getAsset('aimLine', {
			anchorX: 0,
			anchorY: 0.5,
			alpha: 0.6 * (1 - index / total),
			scaleX: 0.5,
			scaleY: 0.3
		});
		// Position at start point
		segment.x = p1.x;
		segment.y = p1.y;
		// Calculate segment length and angle
		var dx = p2.x - p1.x;
		var dy = p2.y - p1.y;
		var distance = Math.sqrt(dx * dx + dy * dy);
		var angle = Math.atan2(dy, dx);
		// Set length and rotation
		segment.width = distance;
		segment.rotation = angle;
		self.pathLine.addChild(segment);
	};
	// Update trajectory path based on launch parameters
	self.updatePath = function (startX, startY, angle, power) {
		if (!self.visible) {
			return;
		}
		// Convert angle to radians
		var radians = angle * Math.PI / 180;
		// Calculate initial velocity
		var vx = Math.cos(radians) * power;
		var vy = Math.sin(radians) * power;
		// Simulate trajectory for each point
		var x = startX;
		var y = startY;
		var tempVX = vx;
		var tempVY = vy;
		for (var i = 0; i < self.points.length; i++) {
			// Update position based on velocity
			x += tempVX;
			y += tempVY;
			// Apply only friction (no gravity)
			tempVX *= 0.99; // friction
			// Position the trajectory point
			self.points[i].x = x;
			self.points[i].y = y;
		}
	};
	// Show trajectory
	self.show = function () {
		self.visible = true;
		self.pathLine.alpha = 1;
		for (var i = 0; i < self.points.length; i++) {
			self.points[i].alpha = 1 - i / self.maxPoints;
		}
	};
	// Hide trajectory
	self.hide = function () {
		self.visible = false;
		self.pathLine.alpha = 0;
		for (var i = 0; i < self.points.length; i++) {
			self.points[i].alpha = 0;
		}
	};
	// Initialize points on creation
	self.createPoints();
	return self;
});
var TrajectoryPoint = Container.expand(function () {
	var self = Container.call(this);
	// Create and attach point asset
	var pointGraphics = self.attachAsset('centerCircle', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: 0.2,
		scaleY: 0.2,
		alpha: 0.5
	});
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB // Sky blue background
});
/**** 
* Game Code
****/ 
// Game state
var gameState = "ready"; // ready, aiming, launched, gameOver
var score = 0;
var launches = 0;
var maxLaunches = 50;
var popcorns = [];
var superPopcorns = [];
var ropes = [];
var numberPatternGrid;
// Create wrestling arena
var arena = game.addChild(LK.getAsset('arena', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2,
	y: 2732 / 2
}));
// Create chicken jockey
var chickenJockey = game.addChild(new ChickenJockey());
var launcher = game.addChild(new Launcher());
// 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 = 20;
LK.gui.topLeft.addChild(launchesText);
var instructionText = new Text2("Draw a path to 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;
	gameState = "ready";
	// Update UI
	scoreText.setText("Score: " + score);
	launchesText.setText("Launches: " + launches + "/" + maxLaunches);
	// Reset chicken jockey
	resetChickenJockey();
	// Update instruction text to show current pattern number
	var currentNumber = launches % 9 + 1;
	instructionText.setText("Collect number " + currentNumber + " pattern!");
	// Clear existing popcorn and ropes
	clearPopcornsAndRopes();
	// Create ropes around the arena
	createRopes();
	// Initialize or update the number pattern grid
	if (!numberPatternGrid) {
		numberPatternGrid = new NumberPatternGrid();
		game.addChild(numberPatternGrid);
		numberPatternGrid.initGrid(arena.width, arena.height, bounds);
	} else {
		numberPatternGrid.initGrid(arena.width, arena.height, bounds);
	}
	// Create popcorn scattered around the arena
	createPopcorn(15);
	// Add trajectory path to game
	game.addChild(launcher.trajectoryPath);
	// Play background music
	LK.playMusic('gameMusic');
	// Add Steve to the top left corner of the arena
	var steve = game.addChild(LK.getAsset('Steve', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: bounds.left + 625,
		y: bounds.top + 325
	}));
	// Play gamestart sound
	LK.getSound('Gamestart').play();
	// Remove Steve after 2 seconds
	LK.setTimeout(function () {
		if (steve && steve.parent) {
			steve.parent.removeChild(steve);
		}
	}, 2000);
}
function resetChickenJockey() {
	chickenJockey.reset();
	// Position chicken in the center of the arena
	chickenJockey.x = arena.x;
	chickenJockey.y = arena.y;
	// Position launcher at the same position
	launcher.x = chickenJockey.x;
	launcher.y = chickenJockey.y;
	launcher.rotation = -Math.PI / 4; // 45 degrees upward
	// Reset instruction text when chicken is reset
	instructionText.setText("Draw a path to launch the chicken!");
}
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 superpopcorn
	for (var i = 0; i < superPopcorns.length; i++) {
		if (superPopcorns[i].parent) {
			superPopcorns[i].parent.removeChild(superPopcorns[i]);
		}
	}
	superPopcorns = [];
	// Remove all ropes
	for (var i = 0; i < ropes.length; i++) {
		if (ropes[i].parent) {
			ropes[i].parent.removeChild(ropes[i]);
		}
	}
	ropes = [];
}
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;
	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);
}
function createPopcorn(count) {
	// Determine which number to display (1-9)
	var currentNumber = launches % 9 + 1;
	// Update instruction text to show current pattern number
	instructionText.setText("Collect number " + currentNumber + " pattern!");
	// Fill the grid with the pattern
	var newPopcorns = numberPatternGrid.fillWithPattern(currentNumber);
	// Add all created popcorn to our tracking array
	popcorns = newPopcorns;
	// If we need more popcorn to reach the count (shouldn't happen with grid pattern)
	if (popcorns.length < count) {
		for (var i = popcorns.length; i < count; i++) {
			var popcorn = new Popcorn();
			// Random position within arena bounds
			var validPosition = false;
			var attempts = 0;
			var maxAttempts = 50;
			// Keep trying until we find a valid position
			while (!validPosition && attempts < maxAttempts) {
				// Generate random position within arena bounds
				popcorn.x = bounds.left + 200 + Math.random() * (arena.width - 400);
				popcorn.y = bounds.top + 200 + Math.random() * (arena.height - 400);
				// Check distance from each rope
				validPosition = true;
				for (var j = 0; j < ropes.length; j++) {
					var dx = popcorn.x - ropes[j].x;
					var dy = popcorn.y - ropes[j].y;
					var distance = Math.sqrt(dx * dx + dy * dy);
					// If too close to a rope, try again
					if (distance < 200) {
						validPosition = false;
						break;
					}
				}
				attempts++;
			}
			// Add to game
			game.addChild(popcorn);
			popcorns.push(popcorn);
		}
	}
}
function createSuperPopcorn(count) {
	for (var i = 0; i < count; i++) {
		var superPopcorn = new Superpopcorn();
		// Random position within arena bounds
		var validPosition = false;
		var attempts = 0;
		var maxAttempts = 50;
		// Keep trying until we find a valid position
		while (!validPosition && attempts < maxAttempts) {
			// Generate random position within arena bounds
			superPopcorn.x = bounds.left + 200 + Math.random() * (arena.width - 400);
			superPopcorn.y = bounds.top + 200 + Math.random() * (arena.height - 400);
			// Check distance from each rope
			validPosition = true;
			for (var j = 0; j < ropes.length; j++) {
				var dx = superPopcorn.x - ropes[j].x;
				var dy = superPopcorn.y - ropes[j].y;
				var distance = Math.sqrt(dx * dx + dy * dy);
				// If too close to a rope, try again
				if (distance < 200) {
					validPosition = false;
					break;
				}
			}
			attempts++;
		}
		// Add to game
		game.addChild(superPopcorn);
		superPopcorns.push(superPopcorn);
	}
}
// Game events
game.onChickenJockeyStop = function () {
	gameState = "ready";
	// Check if we need to add more popcorn
	if (popcorns.length < 5) {
		createPopcorn(5);
	}
	// 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();
		// Update the instruction text to show the current number pattern
		var currentNumber = launches % 9 + 1;
		instructionText.setText("Collect number " + currentNumber + " pattern!");
	}
};
game.onMaxBouncesReached = function () {
	// Same as onChickenJockeyStop for now
	game.onChickenJockeyStop();
};
// Input handling
var dragStartX = 0;
var dragStartY = 0;
game.down = function (x, y, obj) {
	if (gameState === "ready") {
		gameState = "aiming";
		dragStartX = x;
		dragStartY = y;
		launcher.startAim(x, y);
	}
};
game.move = function (x, y, obj) {
	if (gameState === "aiming") {
		launcher.updateAim(x, y);
	}
};
game.up = function (x, y, obj) {
	if (gameState === "aiming") {
		// Make sure we have enough points to create a valid path
		if (launcher.points.length < 2) {
			// Not enough points, cancel launch
			launcher.endAim();
			gameState = "ready";
			instructionText.setText("Draw a longer path to launch!");
			return;
		}
		// Get launch parameters
		var launchParams = launcher.endAim();
		// Create a smoothed path if needed
		var pathToDraw = launcher.points;
		if (pathToDraw.length > 20) {
			// Take fewer points if path is very long
			var smoothedPath = [];
			for (var i = 0; i < pathToDraw.length; i += Math.ceil(pathToDraw.length / 20)) {
				smoothedPath.push(pathToDraw[i]);
			}
			// Make sure we include the last point
			if (smoothedPath[smoothedPath.length - 1] !== pathToDraw[pathToDraw.length - 1]) {
				smoothedPath.push(pathToDraw[pathToDraw.length - 1]);
			}
			pathToDraw = smoothedPath;
		}
		// Launch the chicken jockey with the drawn path
		chickenJockey.launch(launchParams.power, launchParams.angle, pathToDraw);
		// Update game state
		gameState = "launched";
		launches++;
		launchesText.setText("Launches: " + launches + "/" + maxLaunches);
		instructionText.setText("Watch the chicken follow your path!");
		// Add 3 superpopcorn after each launch
		createSuperPopcorn(3);
	}
};
// Main game loop
game.update = function () {
	// Update all game objects
	if (gameState === "launched") {
		chickenJockey.update();
		// Check for collisions with arena boundaries
		if (chickenJockey.x < bounds.left) {
			chickenJockey.x = bounds.left;
			chickenJockey.vx = -chickenJockey.vx * chickenJockey.bounceDecay;
			chickenJockey.bounceCount++;
			LK.getSound('bounce').play();
		} else if (chickenJockey.x > bounds.right) {
			chickenJockey.x = bounds.right;
			chickenJockey.vx = -chickenJockey.vx * chickenJockey.bounceDecay;
			chickenJockey.bounceCount++;
			LK.getSound('bounce').play();
		}
		if (chickenJockey.y < bounds.top) {
			chickenJockey.y = bounds.top;
			chickenJockey.vy = -chickenJockey.vy * chickenJockey.bounceDecay;
			chickenJockey.bounceCount++;
			LK.getSound('bounce').play();
		} else if (chickenJockey.y > bounds.bottom) {
			chickenJockey.y = bounds.bottom;
			chickenJockey.vy = -chickenJockey.vy * chickenJockey.bounceDecay;
			chickenJockey.bounceCount++;
			LK.getSound('bounce').play();
		}
		// Check for collisions with ropes
		for (var i = 0; i < ropes.length; i++) {
			if (chickenJockey.intersects(ropes[i])) {
				ropes[i].bounce(chickenJockey);
			}
		}
		// Check for collisions with popcorn
		for (var i = popcorns.length - 1; i >= 0; i--) {
			if (chickenJockey.intersects(popcorns[i])) {
				// Collect popcorn
				popcorns[i].collect();
				// Remove from array
				popcorns.splice(i, 1);
				// Increase score
				score += 10;
				scoreText.setText("Score: " + score);
				// Save score to LK
				LK.setScore(score);
				// If all popcorn collected, move to next number pattern
				if (popcorns.length === 0) {
					// Reset chicken position for next launch
					resetChickenJockey();
					// Update to next number pattern
					var nextNumber = (launches + 1) % 9 + 1;
					instructionText.setText("Now collect number " + nextNumber + " pattern!");
					// Create new pattern after a short delay
					LK.setTimeout(function () {
						createPopcorn(15);
					}, 1000);
				}
			}
		}
		// Check for collisions with superpopcorn
		for (var i = superPopcorns.length - 1; i >= 0; i--) {
			if (chickenJockey.intersects(superPopcorns[i])) {
				// Collect superpopcorn
				superPopcorns[i].collect();
				// Remove from array
				superPopcorns.splice(i, 1);
				// Increase score
				score += 1000;
				scoreText.setText("Score: " + score);
				// Save score to LK
				LK.setScore(score);
			}
		}
	}
	// Update popcorn animations
	for (var i = 0; i < popcorns.length; i++) {
		popcorns[i].update();
	}
	// Update superpopcorn animations
	for (var i = 0; i < superPopcorns.length; i++) {
		superPopcorns[i].update();
	}
};
// Initialize the game
initGame();
; ===================================================================
--- original.js
+++ change.js
@@ -6,56 +6,8 @@
 
 /**** 
 * Classes
 ****/ 
-var Button = Container.expand(function () {
-	var self = Container.call(this);
-	// Create button shape
-	var buttonShape = self.attachAsset('Hiscorebackdrop', {
-		anchorX: 0.5,
-		anchorY: 0.5
-	});
-	// Button text
-	var buttonText = new Text2("", {
-		size: 60,
-		fill: 0xFFFFFF
-	});
-	buttonText.anchor.set(0.5, 0.5);
-	self.addChild(buttonText);
-	// Button properties
-	self.text = "";
-	self.enabled = true;
-	// Set button text
-	self.setText = function (text) {
-		self.text = text;
-		buttonText.setText(text);
-	};
-	// Set button color
-	self.setColor = function (color) {
-		buttonShape.tint = color;
-	};
-	// Handle down event
-	self.down = function (x, y, obj) {
-		if (!self.enabled) {
-			return;
-		}
-		self.scale.set(0.95);
-		self.alpha = 0.8;
-	};
-	// Handle up event
-	self.up = function (x, y, obj) {
-		if (!self.enabled) {
-			return;
-		}
-		self.scale.set(1.0);
-		self.alpha = 1.0;
-		// Call onClick if it exists
-		if (typeof self.onClick === 'function') {
-			self.onClick();
-		}
-	};
-	return self;
-});
 var ChickenJockey = Container.expand(function () {
 	var self = Container.call(this);
 	// Create and attach chicken asset
 	var chickenGraphics = self.attachAsset('chicken', {
@@ -163,77 +115,8 @@
 		}
 	};
 	return self;
 });
-var HighScores = Container.expand(function () {
-	var self = Container.call(this);
-	// Title text
-	var titleText = new Text2("TOP 10 HIGH SCORES", {
-		size: 80,
-		fill: 0xFFFFFF
-	});
-	titleText.anchor.set(0.5, 0);
-	titleText.y = -backdrop.height / 2 + 50;
-	self.addChild(titleText);
-	// Array to hold score text objects
-	self.scoreTexts = [];
-	// Create score text slots
-	for (var i = 0; i < 10; i++) {
-		var scoreText = new Text2(i + 1 + ". -----", {
-			size: 50,
-			fill: 0xFFFFFF
-		});
-		scoreText.anchor.set(0.5, 0);
-		scoreText.y = -backdrop.height / 2 + 150 + i * 60;
-		self.addChild(scoreText);
-		self.scoreTexts.push(scoreText);
-	}
-	// Function to update high scores display
-	self.updateScores = function () {
-		// Get high scores array from storage
-		var highScores = storage.highScores || [];
-		// Update each score text object
-		for (var i = 0; i < 10; i++) {
-			if (i < highScores.length) {
-				self.scoreTexts[i].setText(i + 1 + ". " + highScores[i]);
-			} else {
-				self.scoreTexts[i].setText(i + 1 + ". -----");
-			}
-		}
-	};
-	// Show with animation
-	self.show = function () {
-		self.updateScores();
-		self.alpha = 0;
-		self.scale.set(0.5);
-		tween(self, {
-			alpha: 1,
-			scaleX: 1,
-			scaleY: 1
-		}, {
-			duration: 500,
-			easing: tween.easeOut
-		});
-	};
-	// Hide with animation
-	self.hide = function () {
-		tween(self, {
-			alpha: 0,
-			scaleX: 0.5,
-			scaleY: 0.5
-		}, {
-			duration: 500,
-			easing: tween.easeIn,
-			onFinish: function onFinish() {
-				if (self.parent) {
-					self.parent.removeChild(self);
-				}
-			}
-		});
-	};
-	return self;
-});
-// Function to show high scores
 var Launcher = Container.expand(function () {
 	var self = Container.call(this);
 	// Create and attach launcher asset with alpha 0 to make it invisible
 	var launcherGraphics = self.attachAsset('launcher', {
@@ -393,8 +276,122 @@
 		return createdPopcorns;
 	};
 	return self;
 });
+var NumberPatternGrid = Container.expand(function () {
+	var self = Container.call(this);
+	// Grid properties
+	self.cellSize = 100; // Size of each grid cell
+	self.padding = 50; // Padding around the grid
+	self.currentPattern = null; // Current active pattern
+	self.gridCells = []; // Store all grid cells
+	// Initialize grid based on available space
+	self.initGrid = function (arenaWidth, arenaHeight, bounds) {
+		// Calculate grid dimensions
+		self.columns = Math.floor((arenaWidth - self.padding * 2) / self.cellSize);
+		self.rows = Math.floor((arenaHeight - self.padding * 2) / self.cellSize);
+		// Clear existing grid
+		while (self.children.length > 0) {
+			self.removeChild(self.children[0]);
+		}
+		self.gridCells = [];
+		// Create grid
+		for (var row = 0; row < self.rows; row++) {
+			self.gridCells[row] = [];
+			for (var col = 0; col < self.columns; col++) {
+				var cell = new Container();
+				cell.x = bounds.left + self.padding + col * self.cellSize + self.cellSize / 2;
+				cell.y = bounds.top + self.padding + row * self.cellSize + self.cellSize / 2;
+				cell.row = row;
+				cell.col = col;
+				cell.filled = false;
+				cell.popcorn = null;
+				self.addChild(cell);
+				self.gridCells[row][col] = cell;
+			}
+		}
+	};
+	// Fill the grid with a number pattern
+	self.fillWithPattern = function (number) {
+		if (number < 1 || number > 9) {
+			return;
+		}
+		self.currentPattern = number;
+		// Clear any existing popcorns
+		self.clearAllPopcorn();
+		// Create number pattern matrix (using patterns from NumberPattern class)
+		var patternGen = new NumberPattern();
+		var pattern = patternGen.patterns[number];
+		// Center the pattern in the grid
+		var patternHeight = pattern.length;
+		var patternWidth = pattern[0].length;
+		var startRow = Math.floor((self.rows - patternHeight) / 2);
+		var startCol = Math.floor((self.columns - patternWidth) / 2);
+		// Place popcorn for each '1' in the pattern
+		for (var row = 0; row < patternHeight; row++) {
+			for (var col = 0; col < patternWidth; col++) {
+				var gridRow = startRow + row;
+				var gridCol = startCol + col;
+				// Skip if outside grid
+				if (gridRow < 0 || gridRow >= self.rows || gridCol < 0 || gridCol >= self.columns) {
+					continue;
+				}
+				var cell = self.gridCells[gridRow][gridCol];
+				if (pattern[row][col] === 1) {
+					// Create popcorn
+					var popcorn = new Popcorn();
+					popcorn.x = 0; // Position relative to cell
+					popcorn.y = 0;
+					cell.addChild(popcorn);
+					cell.popcorn = popcorn;
+					cell.filled = true;
+				}
+			}
+		}
+		return self.getPopcornList();
+	};
+	// Get a list of all popcorn in the grid
+	self.getPopcornList = function () {
+		var popcornList = [];
+		for (var row = 0; row < self.rows; row++) {
+			for (var col = 0; col < self.columns; col++) {
+				var cell = self.gridCells[row][col];
+				if (cell.filled && cell.popcorn) {
+					popcornList.push(cell.popcorn);
+				}
+			}
+		}
+		return popcornList;
+	};
+	// Clear all popcorn from the grid
+	self.clearAllPopcorn = function () {
+		for (var row = 0; row < self.rows; row++) {
+			for (var col = 0; col < self.columns; col++) {
+				var cell = self.gridCells[row][col];
+				if (cell.popcorn) {
+					cell.removeChild(cell.popcorn);
+					cell.popcorn = null;
+					cell.filled = false;
+				}
+			}
+		}
+	};
+	// Collect a specific popcorn
+	self.collectPopcorn = function (popcorn) {
+		for (var row = 0; row < self.rows; row++) {
+			for (var col = 0; col < self.columns; col++) {
+				var cell = self.gridCells[row][col];
+				if (cell.popcorn === popcorn) {
+					cell.filled = false;
+					cell.popcorn = null;
+					return true;
+				}
+			}
+		}
+		return false;
+	};
+	return self;
+});
 var Popcorn = Container.expand(function () {
 	var self = Container.call(this);
 	// Create and attach popcorn asset
 	var popcornGraphics = self.attachAsset('popcorn', {
@@ -592,69 +589,8 @@
 		}
 	};
 	return self;
 });
-var TitleScreen = Container.expand(function () {
-	var self = Container.call(this);
-	// Create backdrop
-	var backdrop = self.attachAsset('Titlescreen', {
-		anchorX: 0.5,
-		anchorY: 0.5
-	});
-	// Create start button
-	var startButton = new Button();
-	startButton.setText("START GAME");
-	startButton.setColor(0x4CAF50); // Green color
-	startButton.x = 0;
-	startButton.y = 200;
-	startButton.onClick = function () {
-		self.onStartClick();
-	};
-	self.addChild(startButton);
-	// Create high scores button
-	var highScoresButton = new Button();
-	highScoresButton.setText("HIGH SCORES");
-	highScoresButton.setColor(0x2196F3); // Blue color
-	highScoresButton.x = 0;
-	highScoresButton.y = 350;
-	highScoresButton.onClick = function () {
-		self.onHighScoresClick();
-	};
-	self.addChild(highScoresButton);
-	// Show with animation
-	self.show = function () {
-		self.alpha = 0;
-		self.scale.set(0.8);
-		tween(self, {
-			alpha: 1,
-			scaleX: 1,
-			scaleY: 1
-		}, {
-			duration: 500,
-			easing: tween.easeOut
-		});
-	};
-	// Hide with animation
-	self.hide = function (callback) {
-		tween(self, {
-			alpha: 0,
-			scaleX: 0.8,
-			scaleY: 0.8
-		}, {
-			duration: 500,
-			easing: tween.easeIn,
-			onFinish: function onFinish() {
-				if (typeof callback === 'function') {
-					callback();
-				}
-				if (self.parent) {
-					self.parent.removeChild(self);
-				}
-			}
-		});
-	};
-	return self;
-});
 var TrajectoryPath = Container.expand(function () {
 	var self = Container.call(this);
 	// Properties
 	self.points = [];
@@ -795,21 +731,16 @@
 /**** 
 * Game Code
 ****/ 
 // Game state
-var gameState = "title"; // title, ready, aiming, launched, gameOver
+var gameState = "ready"; // ready, aiming, launched, gameOver
 var score = 0;
 var launches = 0;
 var maxLaunches = 50;
 var popcorns = [];
 var superPopcorns = [];
 var ropes = [];
-var highScoresDisplay = null;
-var titleScreen = null;
-// Initialize high scores if they don't exist
-if (!storage.highScores) {
-	storage.highScores = [];
-}
+var numberPatternGrid;
 // Create wrestling arena
 var arena = game.addChild(LK.getAsset('arena', {
 	anchorX: 0.5,
 	anchorY: 0.5,
@@ -852,21 +783,50 @@
 function initGame() {
 	// Reset variables
 	score = 0;
 	launches = 0;
-	gameState = "title";
+	gameState = "ready";
 	// Update UI
 	scoreText.setText("Score: " + score);
 	launchesText.setText("Launches: " + launches + "/" + maxLaunches);
-	// Hide launcher and chicken initially
-	chickenJockey.visible = false;
-	launcher.visible = false;
-	// Hide the score and launches text initially
-	scoreText.visible = false;
-	launchesText.visible = false;
-	instructionText.visible = false;
-	// Show title screen
-	showTitleScreen();
+	// Reset chicken jockey
+	resetChickenJockey();
+	// Update instruction text to show current pattern number
+	var currentNumber = launches % 9 + 1;
+	instructionText.setText("Collect number " + currentNumber + " pattern!");
+	// Clear existing popcorn and ropes
+	clearPopcornsAndRopes();
+	// Create ropes around the arena
+	createRopes();
+	// Initialize or update the number pattern grid
+	if (!numberPatternGrid) {
+		numberPatternGrid = new NumberPatternGrid();
+		game.addChild(numberPatternGrid);
+		numberPatternGrid.initGrid(arena.width, arena.height, bounds);
+	} else {
+		numberPatternGrid.initGrid(arena.width, arena.height, bounds);
+	}
+	// Create popcorn scattered around the arena
+	createPopcorn(15);
+	// Add trajectory path to game
+	game.addChild(launcher.trajectoryPath);
+	// Play background music
+	LK.playMusic('gameMusic');
+	// Add Steve to the top left corner of the arena
+	var steve = game.addChild(LK.getAsset('Steve', {
+		anchorX: 0.5,
+		anchorY: 0.5,
+		x: bounds.left + 625,
+		y: bounds.top + 325
+	}));
+	// Play gamestart sound
+	LK.getSound('Gamestart').play();
+	// Remove Steve after 2 seconds
+	LK.setTimeout(function () {
+		if (steve && steve.parent) {
+			steve.parent.removeChild(steve);
+		}
+	}, 2000);
 }
 function resetChickenJockey() {
 	chickenJockey.reset();
 	// Position chicken in the center of the arena
@@ -930,42 +890,17 @@
 	game.addChild(leftRope);
 	ropes.push(leftRope);
 }
 function createPopcorn(count) {
-	// Create a number pattern generator
-	var patternGenerator = new NumberPattern();
-	// Calculate spacing based on the arena size
-	var spacing = 70; // Reduced spacing to make the pattern smaller
 	// Determine which number to display (1-9)
 	var currentNumber = launches % 9 + 1;
-	// Create popcorn in the number pattern
-	var newPopcorns = patternGenerator.createPattern(currentNumber, arena.x,
-	// Center X position
-	arena.y,
-	// Center Y position
-	spacing // Spacing between popcorn
-	);
-	// Add all created popcorn to the game
-	for (var i = 0; i < newPopcorns.length; i++) {
-		var popcorn = newPopcorns[i];
-		// Verify position is valid (not too close to ropes)
-		var validPosition = true;
-		for (var j = 0; j < ropes.length; j++) {
-			var dx = popcorn.x - ropes[j].x;
-			var dy = popcorn.y - ropes[j].y;
-			var distance = Math.sqrt(dx * dx + dy * dy);
-			if (distance < 100) {
-				validPosition = false;
-				break;
-			}
-		}
-		// Only add if position is valid
-		if (validPosition) {
-			game.addChild(popcorn);
-			popcorns.push(popcorn);
-		}
-	}
-	// If we need more popcorn to reach the count, add some randomly
+	// Update instruction text to show current pattern number
+	instructionText.setText("Collect number " + currentNumber + " pattern!");
+	// Fill the grid with the pattern
+	var newPopcorns = numberPatternGrid.fillWithPattern(currentNumber);
+	// Add all created popcorn to our tracking array
+	popcorns = newPopcorns;
+	// If we need more popcorn to reach the count (shouldn't happen with grid pattern)
 	if (popcorns.length < count) {
 		for (var i = popcorns.length; i < count; i++) {
 			var popcorn = new Popcorn();
 			// Random position within arena bounds
@@ -1039,21 +974,12 @@
 	if (launches >= maxLaunches) {
 		// Game over
 		instructionText.setText("Game Over! Final Score: " + score);
 		gameState = "gameOver";
-		// Add score to high scores
-		addHighScore(score);
-		// Show high scores first
-		showHighScores();
-		// Then return to title screen after a delay
+		// Show game over after a short delay
 		LK.setTimeout(function () {
-			// Reset for next game
-			score = 0;
-			launches = 0;
-			gameState = "title";
-			// Show title screen
-			showTitleScreen();
-		}, 5000);
+			LK.showGameOver();
+		}, 2000);
 	} else {
 		// Reset for next launch
 		resetChickenJockey();
 		// Update the instruction text to show the current number pattern
@@ -1068,12 +994,8 @@
 // Input handling
 var dragStartX = 0;
 var dragStartY = 0;
 game.down = function (x, y, obj) {
-	if (gameState === "title") {
-		// Title screen interactions are handled by the buttons
-		return;
-	}
 	if (gameState === "ready") {
 		gameState = "aiming";
 		dragStartX = x;
 		dragStartY = y;
@@ -1167,9 +1089,20 @@
 				score += 10;
 				scoreText.setText("Score: " + score);
 				// Save score to LK
 				LK.setScore(score);
-				// Check if all popcorn has been collected - X5 bonus removed
+				// If all popcorn collected, move to next number pattern
+				if (popcorns.length === 0) {
+					// Reset chicken position for next launch
+					resetChickenJockey();
+					// Update to next number pattern
+					var nextNumber = (launches + 1) % 9 + 1;
+					instructionText.setText("Now collect number " + nextNumber + " pattern!");
+					// Create new pattern after a short delay
+					LK.setTimeout(function () {
+						createPopcorn(15);
+					}, 1000);
+				}
 			}
 		}
 		// Check for collisions with superpopcorn
 		for (var i = superPopcorns.length - 1; i >= 0; i--) {
@@ -1194,113 +1127,7 @@
 	for (var i = 0; i < superPopcorns.length; i++) {
 		superPopcorns[i].update();
 	}
 };
-// Function to show title screen
-function showTitleScreen() {
-	// Clear any existing stuff
-	clearPopcornsAndRopes();
-	// Create title screen if it doesn't exist
-	if (!titleScreen) {
-		titleScreen = new TitleScreen();
-		titleScreen.x = 2048 / 2;
-		titleScreen.y = 2732 / 2;
-		// Set up button callbacks
-		titleScreen.onStartClick = function () {
-			startGame();
-		};
-		titleScreen.onHighScoresClick = function () {
-			showHighScores();
-		};
-		game.addChild(titleScreen);
-	}
-	// Show the title screen with animation
-	titleScreen.show();
-}
-// Function to start the game
-function startGame() {
-	// Hide title screen
-	if (titleScreen && titleScreen.parent) {
-		titleScreen.hide(function () {
-			// Make sure title screen is fully removed
-			if (titleScreen && titleScreen.parent) {
-				titleScreen.parent.removeChild(titleScreen);
-			}
-		});
-	}
-	// Change game state
-	gameState = "ready";
-	// Show game elements
-	chickenJockey.visible = true;
-	launcher.visible = true;
-	scoreText.visible = true;
-	launchesText.visible = true;
-	instructionText.visible = true;
-	// Reset chicken jockey
-	resetChickenJockey();
-	// Update instruction text to show current pattern number
-	var currentNumber = launches % 9 + 1;
-	instructionText.setText("Collect number " + currentNumber + " pattern!");
-	// Create ropes around the arena
-	createRopes();
-	// Create popcorn scattered around the arena
-	createPopcorn(15);
-	// Add trajectory path to game
-	game.addChild(launcher.trajectoryPath);
-	// Play background music
-	LK.playMusic('gameMusic');
-	// Add Steve to the top left corner of the arena
-	var steve = game.addChild(LK.getAsset('Steve', {
-		anchorX: 0.5,
-		anchorY: 0.5,
-		x: bounds.left + 625,
-		y: bounds.top + 325
-	}));
-	// Play gamestart sound
-	LK.getSound('Gamestart').play();
-	// Remove Steve after 2 seconds
-	LK.setTimeout(function () {
-		if (steve && steve.parent) {
-			steve.parent.removeChild(steve);
-		}
-	}, 2000);
-}
 // Initialize the game
 initGame();
-;
-// Function to show high scores
-function showHighScores() {
-	// Create high scores display if it doesn't exist
-	if (!highScoresDisplay) {
-		highScoresDisplay = new HighScores();
-		highScoresDisplay.x = 2048 / 2;
-		highScoresDisplay.y = 2732 / 2;
-		game.addChild(highScoresDisplay);
-	}
-	// Show high scores
-	highScoresDisplay.show();
-	// Hide after different time based on game state
-	var hideDelay = gameState === "title" ? 5000 : 3000;
-	// Hide after delay
-	LK.setTimeout(function () {
-		if (highScoresDisplay && highScoresDisplay.parent) {
-			highScoresDisplay.hide();
-		}
-	}, hideDelay);
-}
-// Function to add a new high score
-function addHighScore(newScore) {
-	// Get current high scores
-	var highScores = storage.highScores || [];
-	// Add new score
-	highScores.push(newScore);
-	// Sort in descending order
-	highScores.sort(function (a, b) {
-		return b - a;
-	});
-	// Keep only top 10
-	if (highScores.length > 10) {
-		highScores = highScores.slice(0, 10);
-	}
-	// Save back to storage
-	storage.highScores = highScores;
-}
\ No newline at end of file
+;
\ No newline at end of file
: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