User prompt
The upgrade tab needs to be centered
User prompt
Please fix the bug: 'TypeError: easing is not a function. (In 'easing(t)', 'easing' is "easeOutBack")' in or related to this line: 'tween(panel, {' Line Number: 1439 โช๐ก Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the upgrade button take you to a new screen with a frame saying upgrades
User prompt
Make the upgrade tab appear in the middle
User prompt
Delete the hire staff upgrade
User prompt
Delete the studio equipment upgrade
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: memeUpgradeButton' in or related to this line: 'memeUpgradeButton.enable();' Line Number: 1890
User prompt
Delete the meme quality upgrade
User prompt
Delete the 3 upgrade buttons, not the upgrade button thats under the create videos button
User prompt
Delete the upgrade buttons
User prompt
Make a new button under the create videos buttons named upgrades
User prompt
Make it so the buttons arent darker than the others
User prompt
Make the buttons not locked anymore
User prompt
Make the sliding puzle locked if you dont have over 250 subscribers
User prompt
Make it so instead kf the sliding puzzle being numbers, make it the meme3 asset
User prompt
Make a puzzle game otion in the create video game selection
User prompt
Make it so when you have 100 subscribers or more, the matching game is no longer locked and it is its normal color
User prompt
Make the 100 followers needed text bigger
User prompt
Make it so in the create video game selection, you can only play the matching game if you have over 100 followers, if you have under 100 followers it is locked and it says 100 followers needed
User prompt
Make a button on the bottom left hand corner say reset progress, and if you click it, it resets all your progress, including your upgrdaes bought, your monye, and your followers โช๐ก Consider importing and using the following plugins: @upit/storage.v1
User prompt
Make the connect 4 ai smarter
User prompt
Niw create a matching game choice in the create video selection screen
User prompt
Ok now the connect 4 game doesnt work, pls fix
User prompt
The create video button doesnt work
User prompt
Make it so when you press the create video button, it takes you to a new screen that asks you what game you want to play and record, the first game choice i will add is a game of connect 4. When you press the connect 4 button, it takes you tk play connect 4 against a bot. Whenever the game ends doesnt matter who won, the video gets uploaded and you get more followers and money than a regular meme.
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
	money: 100,
	followers: 0,
	memeLevel: 1,
	studioLevel: 1,
	staffLevel: 0,
	marketingLevel: 0,
	autoEarningRate: 0,
	lastPlayed: "undefined"
});
/**** 
* Classes
****/ 
var Button = Container.expand(function (text, width, height, color) {
	var self = Container.call(this);
	var buttonShape = self.attachAsset('button', {
		width: width || 600,
		height: height || 200,
		color: color || 0x4CAF50,
		anchorX: 0.5,
		anchorY: 0.5
	});
	var buttonText = new Text2(text, {
		size: 60,
		fill: 0xFFFFFF
	});
	buttonText.anchor.set(0.5, 0.5);
	self.addChild(buttonText);
	self.setText = function (newText) {
		buttonText.setText(newText);
	};
	self.setColor = function (newColor) {
		buttonShape.tint = newColor;
	};
	self.down = function (x, y, obj) {
		tween(buttonShape, {
			scaleX: 0.95,
			scaleY: 0.95
		}, {
			duration: 100
		});
		LK.getSound('click').play();
	};
	self.up = function (x, y, obj) {
		tween(buttonShape, {
			scaleX: 1,
			scaleY: 1
		}, {
			duration: 100
		});
	};
	return self;
});
var Connect4Game = Container.expand(function () {
	var self = Container.call(this);
	// Constants
	var COLS = 7;
	var ROWS = 6;
	var CELL_SIZE = 150;
	var PLAYER_COLOR = 0xff0000;
	var AI_COLOR = 0xffff00;
	var BOARD_COLOR = 0x0000ff;
	var EMPTY = 0;
	var PLAYER = 1;
	var AI = 2;
	// Game state
	var board = [];
	var currentPlayer = PLAYER;
	var gameOver = false;
	var gameResult = null;
	// Create board background
	var boardBackground = self.attachAsset('memeCanvas', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: COLS * CELL_SIZE + 40,
		height: ROWS * CELL_SIZE + 40,
		color: BOARD_COLOR
	});
	// Initialize board data
	function initBoard() {
		board = [];
		for (var i = 0; i < COLS; i++) {
			board[i] = [];
			for (var j = 0; j < ROWS; j++) {
				board[i][j] = EMPTY;
			}
		}
		currentPlayer = PLAYER;
		gameOver = false;
		gameResult = null;
	}
	// Create visual board
	var cells = [];
	var circles = [];
	function createVisualBoard() {
		// Create cell containers
		for (var col = 0; col < COLS; col++) {
			cells[col] = [];
			circles[col] = [];
			for (var row = 0; row < ROWS; row++) {
				var cell = new Container();
				cell.x = (col - COLS / 2 + 0.5) * CELL_SIZE;
				cell.y = (row - ROWS / 2 + 0.5) * CELL_SIZE;
				var cellCircle = LK.getAsset('centerCircle', {
					anchorX: 0.5,
					anchorY: 0.5,
					width: CELL_SIZE - 20,
					height: CELL_SIZE - 20,
					color: 0xffffff
				});
				cell.addChild(cellCircle);
				self.addChild(cell);
				cells[col][row] = cell;
				circles[col][row] = cellCircle;
			}
		}
	}
	// Create status text
	var statusText = new Text2("Your turn", {
		size: 60,
		fill: 0xffffff
	});
	statusText.anchor.set(0.5, 0.5);
	statusText.y = -500;
	self.addChild(statusText);
	// Create finish button
	var finishButton = new Button("Finish Recording", 600, 150, 0xff5555);
	finishButton.y = 600;
	finishButton.visible = false;
	self.addChild(finishButton);
	// Drop piece in column
	function dropPiece(col) {
		if (gameOver) {
			return false;
		}
		// Find the first empty row
		var row = ROWS - 1;
		while (row >= 0 && board[col][row] !== EMPTY) {
			row--;
		}
		// If column is full
		if (row < 0) {
			return false;
		}
		// Drop piece
		board[col][row] = currentPlayer;
		updateVisualBoard();
		// Check for win
		if (checkWin(col, row)) {
			gameOver = true;
			gameResult = currentPlayer;
			finishButton.visible = true;
			statusText.setText(currentPlayer === PLAYER ? "You win!" : "AI wins!");
			return true;
		}
		// Check for draw
		if (checkDraw()) {
			gameOver = true;
			gameResult = 0;
			finishButton.visible = true;
			statusText.setText("It's a draw!");
			return true;
		}
		// Switch player
		currentPlayer = currentPlayer === PLAYER ? AI : PLAYER;
		statusText.setText(currentPlayer === PLAYER ? "Your turn" : "AI thinking...");
		return true;
	}
	// Update the visual representation of the board
	function updateVisualBoard() {
		for (var col = 0; col < COLS; col++) {
			for (var row = 0; row < ROWS; row++) {
				if (board[col][row] === EMPTY) {
					circles[col][row].tint = 0xffffff;
				} else if (board[col][row] === PLAYER) {
					circles[col][row].tint = PLAYER_COLOR;
				} else {
					circles[col][row].tint = AI_COLOR;
				}
			}
		}
	}
	// Check if current player won
	function checkWin(col, row) {
		var player = board[col][row];
		// Check horizontal
		var count = 0;
		for (var c = 0; c < COLS; c++) {
			if (board[c][row] === player) {
				count++;
				if (count >= 4) {
					return true;
				}
			} else {
				count = 0;
			}
		}
		// Check vertical
		count = 0;
		for (var r = 0; r < ROWS; r++) {
			if (board[col][r] === player) {
				count++;
				if (count >= 4) {
					return true;
				}
			} else {
				count = 0;
			}
		}
		// Check diagonal (/)
		for (var c = 0; c < COLS - 3; c++) {
			for (var r = 3; r < ROWS; r++) {
				if (board[c][r] === player && board[c + 1][r - 1] === player && board[c + 2][r - 2] === player && board[c + 3][r - 3] === player) {
					return true;
				}
			}
		}
		// Check diagonal (\)
		for (var c = 0; c < COLS - 3; c++) {
			for (var r = 0; r < ROWS - 3; r++) {
				if (board[c][r] === player && board[c + 1][r + 1] === player && board[c + 2][r + 2] === player && board[c + 3][r + 3] === player) {
					return true;
				}
			}
		}
		return false;
	}
	// Check if the game is a draw
	function checkDraw() {
		for (var col = 0; col < COLS; col++) {
			if (board[col][0] === EMPTY) {
				return false;
			}
		}
		return true;
	}
	// AI move
	function aiMove() {
		// Smarter AI using minimax with alpha-beta pruning
		var validColumns = [];
		var scores = [];
		// Get all valid columns
		for (var col = 0; col < COLS; col++) {
			if (board[col][0] === EMPTY) {
				validColumns.push(col);
			}
		}
		// Evaluate each possible move
		for (var i = 0; i < validColumns.length; i++) {
			var col = validColumns[i];
			var tempBoard = copyBoard(board);
			var row = dropPieceInTempBoard(tempBoard, col, AI);
			// Check for immediate win
			if (checkWinInBoard(tempBoard, col, row, AI)) {
				// AI can win in this move, take it immediately
				LK.setTimeout(function () {
					dropPiece(col);
				}, 1000);
				return;
			}
			// Otherwise, evaluate this move
			var score = evaluateMove(tempBoard, col, row, 4); // Look 4 moves ahead
			scores.push({
				col: col,
				score: score
			});
		}
		// Find best move
		var bestMoves = [];
		var bestScore = -Infinity;
		for (var i = 0; i < scores.length; i++) {
			if (scores[i].score > bestScore) {
				bestScore = scores[i].score;
				bestMoves = [scores[i].col];
			} else if (scores[i].score === bestScore) {
				bestMoves.push(scores[i].col);
			}
		}
		// Choose randomly among best moves for some unpredictability
		var bestCol = bestMoves[Math.floor(Math.random() * bestMoves.length)];
		LK.setTimeout(function () {
			dropPiece(bestCol);
		}, 1000);
	}
	// Creates a copy of the current board
	function copyBoard(originalBoard) {
		var newBoard = [];
		for (var i = 0; i < COLS; i++) {
			newBoard[i] = [];
			for (var j = 0; j < ROWS; j++) {
				newBoard[i][j] = originalBoard[i][j];
			}
		}
		return newBoard;
	}
	// Drops a piece in a temporary board for evaluation
	function dropPieceInTempBoard(tempBoard, col, player) {
		var row = ROWS - 1;
		while (row >= 0 && tempBoard[col][row] !== EMPTY) {
			row--;
		}
		if (row >= 0) {
			tempBoard[col][row] = player;
		}
		return row;
	}
	// Check for win in temporary board
	function checkWinInBoard(board, col, row, player) {
		// Check horizontal
		var count = 0;
		for (var c = 0; c < COLS; c++) {
			if (board[c][row] === player) {
				count++;
				if (count >= 4) {
					return true;
				}
			} else {
				count = 0;
			}
		}
		// Check vertical
		count = 0;
		for (var r = 0; r < ROWS; r++) {
			if (board[col][r] === player) {
				count++;
				if (count >= 4) {
					return true;
				}
			} else {
				count = 0;
			}
		}
		// Check diagonal (/)
		for (var c = 0; c < COLS - 3; c++) {
			for (var r = 3; r < ROWS; r++) {
				if (board[c][r] === player && board[c + 1][r - 1] === player && board[c + 2][r - 2] === player && board[c + 3][r - 3] === player) {
					return true;
				}
			}
		}
		// Check diagonal (\)
		for (var c = 0; c < COLS - 3; c++) {
			for (var r = 0; r < ROWS - 3; r++) {
				if (board[c][r] === player && board[c + 1][r + 1] === player && board[c + 2][r + 2] === player && board[c + 3][r + 3] === player) {
					return true;
				}
			}
		}
		return false;
	}
	// Evaluate the board position using heuristics
	function evaluateMove(tempBoard, col, row, depth) {
		// Base score
		var score = 0;
		// Check if this is a winning move
		if (checkWinInBoard(tempBoard, col, row, AI)) {
			return 1000;
		}
		// Look for opponent's winning move and block it
		for (var c = 0; c < COLS; c++) {
			if (tempBoard[c][0] === EMPTY) {
				var tempRow = dropPieceInTempBoard(copyBoard(tempBoard), c, PLAYER);
				if (tempRow >= 0 && checkWinInBoard(tempBoard, c, tempRow, PLAYER)) {
					score -= 800; // Prioritize blocking opponent win
				}
			}
		}
		// Evaluate center control (center column is strategically valuable)
		var centerCol = Math.floor(COLS / 2);
		var centerCount = 0;
		for (var r = 0; r < ROWS; r++) {
			if (tempBoard[centerCol][r] === AI) {
				centerCount++;
			}
		}
		score += centerCount * 30;
		// Evaluate connections (2 in a row, 3 in a row)
		score += evaluateConnections(tempBoard, AI) * 10;
		score -= evaluateConnections(tempBoard, PLAYER) * 8;
		// Prefer lower rows (more stable position)
		score += (ROWS - row) * 5;
		// If depth allows, do minimax for deeper evaluation
		if (depth > 0) {
			// Simulate player's best response
			var minScore = Infinity;
			for (var c = 0; c < COLS; c++) {
				if (tempBoard[c][0] === EMPTY) {
					var newBoard = copyBoard(tempBoard);
					var newRow = dropPieceInTempBoard(newBoard, c, PLAYER);
					if (newRow >= 0) {
						// Check if player wins
						if (checkWinInBoard(newBoard, c, newRow, PLAYER)) {
							return -900; // Very bad for AI
						}
						// Recursive evaluation with reduced depth
						var moveScore = evaluateMove(newBoard, c, newRow, depth - 1);
						if (moveScore < minScore) {
							minScore = moveScore;
						}
					}
				}
			}
			// Add minimax result with lower weight
			score += minScore * 0.5;
		}
		return score;
	}
	// Evaluate connected pieces (2 or 3 in a row)
	function evaluateConnections(board, player) {
		var score = 0;
		// Check horizontal connections
		for (var r = 0; r < ROWS; r++) {
			for (var c = 0; c < COLS - 1; c++) {
				if (board[c][r] === player && board[c + 1][r] === player) {
					score += 1; // 2 in a row
					if (c + 2 < COLS && board[c + 2][r] === player) {
						score += 5; // 3 in a row
					}
				}
			}
		}
		// Check vertical connections
		for (var c = 0; c < COLS; c++) {
			for (var r = 0; r < ROWS - 1; r++) {
				if (board[c][r] === player && board[c][r + 1] === player) {
					score += 1; // 2 in a row
					if (r + 2 < ROWS && board[c][r + 2] === player) {
						score += 5; // 3 in a row
					}
				}
			}
		}
		// Diagonal connections would be similar but more complex
		// Adding them would make the AI even smarter
		return score;
	}
	// Handle column click
	self.down = function (x, y) {
		if (currentPlayer !== PLAYER || gameOver) {
			return;
		}
		// Convert coordinates to column
		var boardX = x;
		var col = Math.floor((boardX + COLS / 2 * CELL_SIZE) / CELL_SIZE);
		// Check if valid column
		if (col >= 0 && col < COLS) {
			if (dropPiece(col) && !gameOver) {
				aiMove();
			}
		}
	};
	// Set finish callback
	self.setFinishCallback = function (callback) {
		finishButton.up = function () {
			tween(finishButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback();
			}
		};
	};
	// Initialize
	initBoard();
	createVisualBoard();
	updateVisualBoard();
	return self;
});
var GameSelector = Container.expand(function () {
	var self = Container.call(this);
	var background = self.attachAsset('studioBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: 2048,
		height: 2732,
		color: 0xdddddd
	});
	var titleText = new Text2("Choose A Game To Record", {
		size: 80,
		fill: 0x333333
	});
	titleText.anchor.set(0.5, 0.5);
	titleText.y = -900;
	self.addChild(titleText);
	var connect4Button = new Button("Connect 4", 600, 200, 0x4CAF50);
	connect4Button.y = -700;
	self.addChild(connect4Button);
	var matchingButton = new Button("Memory Match", 600, 200, 0x2196F3);
	matchingButton.y = -400;
	self.addChild(matchingButton);
	// Create locked indicator for matching game
	var lockedText = new Text2("100 followers needed", {
		size: 32,
		fill: 0xFF5733
	});
	lockedText.anchor.set(0.5, 0.5);
	lockedText.y = -330;
	lockedText.visible = false;
	self.addChild(lockedText);
	var backButton = new Button("Go Back", 400, 130, 0xff5555);
	backButton.y = 900;
	self.addChild(backButton);
	// Update lock status based on follower count
	self.updateLockStatus = function (followerCount) {
		if (followerCount >= 100) {
			matchingButton.setColor(0x2196F3); // Normal color
			lockedText.visible = false;
		} else {
			matchingButton.setColor(0x888888); // Grayed out
			lockedText.visible = true;
		}
	};
	self.setGameCallback = function (callback) {
		connect4Button.up = function (x, y, obj) {
			tween(connect4Button, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback("connect4");
			}
		};
		matchingButton.up = function (x, y, obj) {
			tween(matchingButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				// Only allow matching game if followers >= 100
				if (followers >= 100) {
					callback("matching");
				} else {
					// Show a temporary message that game is locked
					tween(lockedText, {
						alpha: 1,
						y: -330
					}, {
						duration: 300,
						onFinish: function onFinish() {
							LK.setTimeout(function () {
								tween(lockedText, {
									alpha: 0,
									y: -310
								}, {
									duration: 300
								});
							}, 1500);
						}
					});
				}
			}
		};
	};
	self.setBackCallback = function (callback) {
		backButton.up = function (x, y, obj) {
			tween(backButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback();
			}
		};
	};
	return self;
});
var MatchingGame = Container.expand(function () {
	var self = Container.call(this);
	// Constants
	var GRID_SIZE = 4; // 4x4 grid
	var CARD_SIZE = 150;
	var CARD_MARGIN = 20;
	var CARD_COLOR = 0x2196F3;
	var CARD_BACK_COLOR = 0x607D8B;
	// Game state
	var cards = [];
	var flippedCards = [];
	var matchedPairs = 0;
	var totalPairs = 8;
	var canFlip = true;
	var gameOver = false;
	// Create background
	var boardBackground = self.attachAsset('memeCanvas', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: (CARD_SIZE + CARD_MARGIN) * GRID_SIZE + 40,
		height: (CARD_SIZE + CARD_MARGIN) * GRID_SIZE + 40,
		color: 0x333333
	});
	// Create status text
	var statusText = new Text2("Match all pairs", {
		size: 60,
		fill: 0xffffff
	});
	statusText.anchor.set(0.5, 0.5);
	statusText.y = -500;
	self.addChild(statusText);
	// Create finish button
	var finishButton = new Button("Finish Recording", 600, 150, 0xff5555);
	finishButton.y = 600;
	finishButton.visible = false;
	self.addChild(finishButton);
	// Symbols for matching (emojis represented as text)
	var symbols = ["๐", "๐", "๐", "๐ฎ", "๐", "โฝ", "๐ต", "๐จ"];
	// Initialize game
	function initGame() {
		cards = [];
		flippedCards = [];
		matchedPairs = 0;
		gameOver = false;
		canFlip = true;
		// Create all card pairs
		var cardValues = [];
		for (var i = 0; i < totalPairs; i++) {
			cardValues.push(i);
			cardValues.push(i);
		}
		// Shuffle the cards
		for (var i = cardValues.length - 1; i > 0; i--) {
			var j = Math.floor(Math.random() * (i + 1));
			var temp = cardValues[i];
			cardValues[i] = cardValues[j];
			cardValues[j] = temp;
		}
		// Create card grid
		for (var row = 0; row < GRID_SIZE; row++) {
			for (var col = 0; col < GRID_SIZE; col++) {
				var index = row * GRID_SIZE + col;
				// Create card container
				var card = new Container();
				card.x = (col - GRID_SIZE / 2 + 0.5) * (CARD_SIZE + CARD_MARGIN);
				card.y = (row - GRID_SIZE / 2 + 0.5) * (CARD_SIZE + CARD_MARGIN);
				// Card back (shown initially)
				var cardBack = LK.getAsset('centerCircle', {
					anchorX: 0.5,
					anchorY: 0.5,
					width: CARD_SIZE,
					height: CARD_SIZE,
					color: CARD_BACK_COLOR
				});
				// Card front (hidden initially)
				var cardFront = LK.getAsset('centerCircle', {
					anchorX: 0.5,
					anchorY: 0.5,
					width: CARD_SIZE,
					height: CARD_SIZE,
					color: CARD_COLOR
				});
				cardFront.visible = false;
				// Symbol text
				var symbolText = new Text2(symbols[cardValues[index]], {
					size: 60,
					fill: 0xFFFFFF
				});
				symbolText.anchor.set(0.5, 0.5);
				symbolText.visible = false;
				// Add to card container
				card.addChild(cardBack);
				card.addChild(cardFront);
				card.addChild(symbolText);
				// Store card data
				card.value = cardValues[index];
				card.isFlipped = false;
				card.isMatched = false;
				// Add to game
				self.addChild(card);
				cards.push(card);
				// Make clickable
				card.interactive = true;
			}
		}
	}
	// Flip a card
	function flipCard(card) {
		if (!canFlip || card.isFlipped || card.isMatched || gameOver) {
			return;
		}
		// Flip animation
		card.isFlipped = true;
		card.children[0].visible = false; // Hide back
		card.children[1].visible = true; // Show front
		card.children[2].visible = true; // Show symbol
		// Add to flipped cards
		flippedCards.push(card);
		// Check for match if we have 2 cards flipped
		if (flippedCards.length === 2) {
			canFlip = false;
			// Check for match
			if (flippedCards[0].value === flippedCards[1].value) {
				// Cards match
				LK.setTimeout(function () {
					flippedCards[0].isMatched = true;
					flippedCards[1].isMatched = true;
					// Highlight matched cards
					tween(flippedCards[0].children[1], {
						tint: 0x4CAF50 // Green tint
					}, {
						duration: 300
					});
					tween(flippedCards[1].children[1], {
						tint: 0x4CAF50 // Green tint
					}, {
						duration: 300
					});
					matchedPairs++;
					flippedCards = [];
					canFlip = true;
					// Check for game over
					if (matchedPairs === totalPairs) {
						gameOver = true;
						statusText.setText("You win!");
						finishButton.visible = true;
					}
				}, 500);
			} else {
				// Cards don't match, flip back
				LK.setTimeout(function () {
					flippedCards[0].isFlipped = false;
					flippedCards[0].children[0].visible = true; // Show back
					flippedCards[0].children[1].visible = false; // Hide front
					flippedCards[0].children[2].visible = false; // Hide symbol
					flippedCards[1].isFlipped = false;
					flippedCards[1].children[0].visible = true; // Show back
					flippedCards[1].children[1].visible = false; // Hide front
					flippedCards[1].children[2].visible = false; // Hide symbol
					flippedCards = [];
					canFlip = true;
				}, 1000);
			}
		}
	}
	// Handle click
	self.down = function (x, y) {
		if (gameOver) {
			return;
		}
		// Convert coordinates to find clicked card
		for (var i = 0; i < cards.length; i++) {
			var card = cards[i];
			var cardBounds = {
				x: card.x - CARD_SIZE / 2,
				y: card.y - CARD_SIZE / 2,
				width: CARD_SIZE,
				height: CARD_SIZE
			};
			if (x >= cardBounds.x && x <= cardBounds.x + cardBounds.width && y >= cardBounds.y && y <= cardBounds.y + cardBounds.height) {
				flipCard(card);
				break;
			}
		}
	};
	// Set finish callback
	self.setFinishCallback = function (callback) {
		finishButton.up = function () {
			tween(finishButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback();
			}
		};
	};
	// Initialize the game
	initGame();
	return self;
});
// MatchingGame instance (initially null)
var MemeStudio = Container.expand(function () {
	var self = Container.call(this);
	var studioBackground = self.attachAsset('studioBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		height: 1800
	});
	var memeCanvas = self.attachAsset('memeCanvas', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: 400,
		height: 400,
		y: -250
	});
	var memeText = new Text2("Your Meme Here", {
		size: 54,
		fill: 0x000000
	});
	memeText.anchor.set(0.5, 0.5);
	memeText.y = -250;
	self.addChild(memeText);
	// Current displayed meme asset
	var currentMemeAsset = null;
	// Function to display a random meme
	function displayRandomMeme() {
		// Remove previous meme if exists
		if (currentMemeAsset) {
			self.removeChild(currentMemeAsset);
		}
		// Generate random number between 1-4 to select a meme
		var memeNumber = Math.floor(Math.random() * 4) + 1;
		var memeId = 'Meme' + memeNumber;
		// Create the new meme asset
		currentMemeAsset = LK.getAsset(memeId, {
			anchorX: 0.5,
			anchorY: 0.5,
			y: -250,
			width: 400,
			height: 400
		});
		// Add the meme to display
		self.addChild(currentMemeAsset);
	}
	var earningsText = new Text2("Earnings: $0", {
		size: 48,
		fill: 0x333333
	});
	earningsText.anchor.set(0.5, 0.5);
	earningsText.y = 20;
	self.addChild(earningsText);
	var createButton = new Button("Create Meme!", 420, 130, 0x4CAF50);
	createButton.y = 150;
	self.addChild(createButton);
	var createVideoButton = new Button("Create Video", 420, 130, 0x4CAF50);
	createVideoButton.y = 270;
	self.addChild(createVideoButton);
	var followerGainText = new Text2("+0 followers", {
		size: 42,
		fill: 0xFF5733
	});
	followerGainText.anchor.set(0.5, 0.5);
	followerGainText.y = 250;
	followerGainText.alpha = 0;
	self.addChild(followerGainText);
	// Update the meme canvas based on current studio level
	self.updateMemeQuality = function (level) {
		var quality = ["Potato Quality", "Standard Meme", "HD Meme", "Ultra HD Meme", "Viral-Ready Meme"];
		var colors = [0xCCCCCC, 0xFFFFFF, 0xFFFFDD, 0xDDFFFF, 0xFFDDFF];
		if (level > quality.length) {
			level = quality.length;
		}
		memeText.setText(quality[level - 1]);
		memeCanvas.tint = colors[level - 1];
		// Scale the meme canvas slightly with each level
		var scale = 1 + (level - 1) * 0.1;
		memeCanvas.scale.set(scale, scale);
	};
	// Show the earnings animation
	self.showEarnings = function (amount, followers) {
		earningsText.setText("Earnings: $" + amount);
		tween(earningsText, {
			scaleX: 1.3,
			scaleY: 1.3
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(earningsText, {
					scaleX: 1,
					scaleY: 1
				}, {
					duration: 300
				});
			}
		});
		if (followers > 0) {
			followerGainText.setText("+" + followers + " followers");
			followerGainText.alpha = 1;
			tween(followerGainText, {
				y: 230,
				alpha: 0
			}, {
				duration: 1500
			});
		}
	};
	self.setCreateButtonCallback = function (callback) {
		createButton.up = function (x, y, obj) {
			tween(createButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			// Display a random meme when creating a new meme
			displayRandomMeme();
			if (callback) {
				callback();
			}
		};
	};
	self.setCreateVideoButtonCallback = function (callback) {
		createVideoButton.up = function (x, y, obj) {
			tween(createVideoButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback();
			}
		};
	};
	return self;
});
var TabSystem = Container.expand(function (tabs) {
	var self = Container.call(this);
	var tabButtons = [];
	var tabContents = [];
	var activeTab = 0;
	// Create tab buttons
	for (var i = 0; i < tabs.length; i++) {
		var tab = tabs[i];
		var index = i;
		var tabButton = new Button(tab.name, 240, 80, 0x607D8B);
		tabButton.x = i * 320 - (tabs.length - 1) * 160;
		tabButton.y = -1300 / 2 + 30;
		tabButton.up = function (x, y, obj) {
			tween(tabButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			setActiveTab(index);
		};
		self.addChild(tabButton);
		tabButtons.push(tabButton);
		// Create and add content container
		var content = tab.content;
		content.visible = i === 0; // Only first tab visible initially
		self.addChild(content);
		tabContents.push(content);
	}
	function setActiveTab(index) {
		if (index === activeTab) {
			return;
		}
		// Update button colors
		tabButtons[activeTab].setColor(0x607D8B);
		tabButtons[index].setColor(0x2196F3);
		// Hide old content, show new
		tabContents[activeTab].visible = false;
		tabContents[index].visible = true;
		activeTab = index;
	}
	// Initialize first tab as active
	setActiveTab(0);
	return self;
});
var UpgradeButton = Container.expand(function (title, description, price, level, onUpgrade) {
	var self = Container.call(this);
	var buttonShape = self.attachAsset('upgradeButton', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: 420,
		height: 140
	});
	var titleText = new Text2(title, {
		size: 42,
		fill: 0xFFFFFF
	});
	titleText.anchor.set(0.5, 0);
	titleText.y = -buttonShape.height / 2 + 15;
	self.addChild(titleText);
	var descText = new Text2(description, {
		size: 30,
		fill: 0xFFFFFF
	});
	descText.anchor.set(0.5, 0);
	descText.y = -buttonShape.height / 2 + 50;
	self.addChild(descText);
	var levelText = new Text2("Level: " + level, {
		size: 34,
		fill: 0xFFD700
	});
	levelText.anchor.set(0, 1);
	levelText.x = -buttonShape.width / 2 + 15;
	levelText.y = buttonShape.height / 2 - 10;
	self.addChild(levelText);
	var priceText = new Text2("$" + price, {
		size: 36,
		fill: 0xFFD700
	});
	priceText.anchor.set(1, 1);
	priceText.x = buttonShape.width / 2 - 15;
	priceText.y = buttonShape.height / 2 - 10;
	self.addChild(priceText);
	self.updateLevel = function (newLevel) {
		levelText.setText("Level: " + newLevel);
	};
	self.updatePrice = function (newPrice) {
		priceText.setText("$" + newPrice);
	};
	self.disable = function () {
		buttonShape.tint = 0x888888;
		self.interactive = false;
	};
	self.enable = function () {
		buttonShape.tint = 0x2196F3;
		self.interactive = true;
	};
	self.down = function (x, y, obj) {
		tween(buttonShape, {
			scaleX: 0.95,
			scaleY: 0.95
		}, {
			duration: 100
		});
		LK.getSound('click').play();
	};
	self.up = function (x, y, obj) {
		tween(buttonShape, {
			scaleX: 1,
			scaleY: 1
		}, {
			duration: 100
		});
		if (onUpgrade) {
			onUpgrade();
		}
	};
	return self;
});
var UpgradePanel = Container.expand(function () {
	var self = Container.call(this);
	var background = self.attachAsset('studioBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: 1600,
		height: 1000,
		color: 0xdddddd
	});
	var titleText = new Text2("Upgrade Your Channel", {
		size: 64,
		fill: 0x333333
	});
	titleText.anchor.set(0.5, 0);
	titleText.y = -background.height / 2 + 50;
	self.addChild(titleText);
	var closeButton = new Button("Close", 240, 80, 0xff5555);
	closeButton.x = background.width / 2 - 130;
	closeButton.y = -background.height / 2 + 50;
	self.addChild(closeButton);
	self.setCloseCallback = function (callback) {
		closeButton.up = function (x, y, obj) {
			tween(closeButton, {
				scaleX: 1,
				scaleY: 1
			}, {
				duration: 100
			});
			if (callback) {
				callback();
			}
		};
	};
	self.addUpgradeButton = function (title, description, price, level, maxLevel, x, y, onUpgrade) {
		var button = new UpgradeButton(title, description, price, level, function () {
			if (onUpgrade) {
				onUpgrade(button);
			}
		});
		button.x = x;
		button.y = y;
		if (maxLevel !== undefined && level >= maxLevel) {
			button.updatePrice("MAXED");
			button.disable();
		}
		self.addChild(button);
		return button;
	};
	return self;
});
var UpgradeScreen = Container.expand(function () {
	var self = Container.call(this);
	// Semi-transparent background
	var overlay = LK.getAsset('studioBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		width: 2048,
		height: 2732,
		color: 0x000000
	});
	overlay.alpha = 0.7;
	self.addChild(overlay);
	var panel = new UpgradePanel();
	panel.y = 0;
	self.addChild(panel);
	var qualityButton, membershipButton, staffButton, equipmentButton;
	self.initialize = function (game, prices, levels) {
		// Quality upgrade button
		qualityButton = panel.addUpgradeButton("Video Quality", "Better videos = more subscribers", prices.quality, levels.quality, undefined, -600, 100, function (button) {
			if (game.money >= prices.quality) {
				game.money -= prices.quality;
				levels.quality++;
				prices.quality = Math.floor(prices.quality * 1.5);
				button.updateLevel(levels.quality);
				button.updatePrice(prices.quality);
				LK.getSound('levelUp').play();
				game.memeLevel = levels.quality;
				game.updateStorage();
			}
		});
		// Membership upgrade button
		membershipButton = panel.addUpgradeButton("Membership", "One-time: +50% money per video", prices.membership, levels.membership, 1, -600, 250, function (button) {
			if (game.money >= prices.membership && levels.membership === 0) {
				game.money -= prices.membership;
				levels.membership = 1;
				button.updateLevel(levels.membership);
				button.updatePrice("MAXED");
				button.disable();
				LK.getSound('levelUp').play();
				game.updateStorage();
			}
		});
		// Staff upgrade button - centered in the screen (x: 0)
		staffButton = panel.addUpgradeButton("Hire Staff", "More staff = faster auto-uploads", prices.staff, levels.staff, undefined, 600, 100, function (button) {
			if (game.money >= prices.staff) {
				game.money -= prices.staff;
				levels.staff++;
				prices.staff = Math.floor(prices.staff * 1.5);
				button.updateLevel(levels.staff);
				button.updatePrice(prices.staff);
				LK.getSound('levelUp').play();
				game.staffLevel = levels.staff;
				game.updateAutoEarningRate();
				game.updateStorage();
			}
		});
		// Equipment upgrade button - centered in the screen (x: 0)
		equipmentButton = panel.addUpgradeButton("Equipment", "Better gear = quality & income boost", prices.equipment, levels.equipment, undefined, 600, 250, function (button) {
			if (game.money >= prices.equipment) {
				game.money -= prices.equipment;
				levels.equipment++;
				prices.equipment = Math.floor(prices.equipment * 1.5);
				button.updateLevel(levels.equipment);
				button.updatePrice(prices.equipment);
				LK.getSound('levelUp').play();
				game.studioLevel = levels.equipment;
				game.updateStorage();
			}
		});
		panel.setCloseCallback(function () {
			self.visible = false;
		});
	};
	self.show = function () {
		self.visible = true;
		tween(panel, {
			scaleX: 1,
			scaleY: 1,
			alpha: 1
		}, {
			duration: 300
		});
	};
	self.updateButtons = function (game, prices) {
		// Enable/disable buttons based on available money
		if (qualityButton) {
			if (game.money >= prices.quality) {
				qualityButton.enable();
			} else {
				qualityButton.disable();
			}
		}
		if (staffButton) {
			if (game.money >= prices.staff) {
				staffButton.enable();
			} else {
				staffButton.disable();
			}
		}
		if (equipmentButton) {
			if (game.money >= prices.equipment) {
				equipmentButton.enable();
			} else {
				equipmentButton.disable();
			}
		}
		if (membershipButton && game.levels.membership === 0) {
			if (game.money >= prices.membership) {
				membershipButton.enable();
			} else {
				membershipButton.disable();
			}
		}
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x87CEEB
});
/**** 
* Game Code
****/ 
// Game variables
var money = storage.money || 100;
var followers = storage.followers || 0;
var memeLevel = storage.memeLevel || 1;
var studioLevel = storage.studioLevel || 1;
var staffLevel = storage.staffLevel || 0;
var marketingLevel = storage.marketingLevel || 0;
var autoEarningRate = storage.autoEarningRate || 0;
var lastPlayed = storage.lastPlayed || Date.now();
var membershipLevel = storage.membershipLevel || 0;
var equipmentLevel = storage.equipmentLevel || 1;
// Upgrade prices
var upgradePrices = {
	quality: calculateUpgradeCost(1, memeLevel),
	membership: 500,
	staff: calculateUpgradeCost(3, staffLevel),
	equipment: calculateUpgradeCost(2, studioLevel)
};
// Upgrade levels
var upgradeLevels = {
	quality: memeLevel,
	membership: membershipLevel,
	staff: staffLevel,
	equipment: studioLevel
};
// Constants
var MEME_BASE_INCOME = 10;
var MEME_BASE_FOLLOWERS = 5;
var UPGRADE_BASE_COST = 100;
var AUTO_EARNINGS_INTERVAL = 20000; // ms (20 seconds)
var OFFLINE_EARNINGS_MAX_HOURS = 24;
// Calculate offline earnings
function calculateOfflineEarnings() {
	var now = Date.now();
	var timeDiff = now - lastPlayed;
	var secondsDiff = timeDiff / 1000;
	var periods = secondsDiff / 20; // How many 20-second periods elapsed
	// Cap at max hours (converted to 20-second periods)
	var maxPeriods = OFFLINE_EARNINGS_MAX_HOURS * 60 * 60 / 20;
	if (periods > maxPeriods) {
		periods = maxPeriods;
	}
	// Only calculate if we have auto earnings
	if (autoEarningRate > 0 && periods > 0) {
		var hourlyRate = autoEarningRate;
		var periodRate = hourlyRate / 180; // Convert from hourly to per 20-second period
		var earnings = Math.floor(periodRate * periods);
		money += earnings;
		// Show welcome back message here if needed
		console.log("Welcome back! You earned $" + earnings + " while away.");
	}
	lastPlayed = now;
	storage.lastPlayed = now;
}
// Calculate costs for upgrades
function calculateUpgradeCost(baseLevel, currentLevel) {
	return Math.floor(UPGRADE_BASE_COST * baseLevel * Math.pow(1.5, currentLevel));
}
// Update storage
function updateStorage() {
	storage.money = money;
	storage.followers = followers;
	storage.memeLevel = memeLevel;
	storage.studioLevel = studioLevel;
	storage.staffLevel = staffLevel;
	storage.marketingLevel = marketingLevel;
	storage.autoEarningRate = autoEarningRate;
	storage.membershipLevel = membershipLevel;
}
// Calculate meme creation result
function createMeme() {
	// Base earnings affected by meme quality and studio level
	var earnings = MEME_BASE_INCOME * memeLevel * (1 + studioLevel * 0.5);
	// Followers gained affected by marketing level
	var newFollowers = Math.floor(MEME_BASE_FOLLOWERS * (1 + marketingLevel * 0.5));
	// Boost from followers (virality factor)
	var followerBoost = 1 + followers / 1000;
	earnings = Math.floor(earnings * followerBoost);
	// Apply membership bonus if active
	if (membershipLevel > 0) {
		earnings = Math.floor(earnings * 1.5);
	}
	// Apply randomness for variability (80% to 120% of calculated value)
	var randomFactor = 0.8 + Math.random() * 0.4;
	earnings = Math.floor(earnings * randomFactor);
	// Small chance for meme to go viral
	if (Math.random() < 0.05) {
		earnings *= 5;
		newFollowers *= 3;
		console.log("Your meme went viral!");
	}
	// Update game state
	money += earnings;
	followers += newFollowers;
	// Update storage
	updateStorage();
	// Return results
	return {
		earnings: earnings,
		followers: newFollowers
	};
}
// Update auto earnings rate based on staff
function updateAutoEarningRate() {
	autoEarningRate = staffLevel * 250 * memeLevel * studioLevel; // MASSIVELY increased earning rate
	storage.autoEarningRate = autoEarningRate;
}
// Create game selector screen (initially hidden)
var gameSelector = new GameSelector();
gameSelector.x = 2048 / 2;
gameSelector.y = 2732 / 2;
gameSelector.visible = false;
game.addChild(gameSelector);
// Function to show game selector
function showGameSelector() {
	gameSelector.visible = true;
	memeStudio.visible = false;
	statsContainer.visible = false;
	studioContent.visible = false;
	// Update matching game lock status based on current follower count
	gameSelector.updateLockStatus(followers);
}
// Function to hide game selector and show the main screen
function hideGameSelector() {
	gameSelector.visible = false;
	memeStudio.visible = true;
	statsContainer.visible = true;
	studioContent.visible = true;
}
// Set callbacks for game selector
gameSelector.setGameCallback(function (gameType) {
	if (gameType === "connect4") {
		startConnect4Game();
	} else if (gameType === "matching") {
		startMatchingGame();
	}
});
gameSelector.setBackCallback(function () {
	hideGameSelector();
});
// Connect4 game instance (initially null)
var connect4Game = null;
// Function to start Connect4 game
function startConnect4Game() {
	// Hide game selector
	gameSelector.visible = false;
	// Create new Connect4 game or reset existing one
	if (!connect4Game) {
		connect4Game = new Connect4Game();
		connect4Game.x = 2048 / 2;
		connect4Game.y = 2732 / 2;
		game.addChild(connect4Game);
	} else {
		// Remove existing game and create a new one
		game.removeChild(connect4Game);
		connect4Game = new Connect4Game();
		connect4Game.x = 2048 / 2;
		connect4Game.y = 2732 / 2;
		game.addChild(connect4Game);
	}
	// Show the game
	connect4Game.visible = true;
	// Set callback for when game finishes
	connect4Game.setFinishCallback(function () {
		// Hide Connect4 game
		connect4Game.visible = false;
		// Show main screen
		hideGameSelector();
		// Give rewards for completing video game
		var videoEarnings = MEME_BASE_INCOME * memeLevel * studioLevel * 3;
		var videoFollowers = MEME_BASE_FOLLOWERS * memeLevel * 3;
		// Apply membership bonus if active
		if (membershipLevel > 0) {
			videoEarnings = Math.floor(videoEarnings * 1.5);
		}
		// Apply randomness
		var randomFactor = 0.9 + Math.random() * 0.2;
		videoEarnings = Math.floor(videoEarnings * randomFactor);
		// Update game state
		money += videoEarnings;
		followers += videoFollowers;
		// Show earnings
		memeStudio.showEarnings(videoEarnings, videoFollowers);
		// Play coin sound
		LK.getSound('coin').play();
		// Update storage
		updateStorage();
	});
}
// Create UI elements
// Main studio
var memeStudio = new MemeStudio();
memeStudio.x = 2048 / 2;
memeStudio.y = 2732 / 2;
game.addChild(memeStudio);
// Initialize with current meme quality
memeStudio.updateMemeQuality(memeLevel);
// Reset Progress button
var resetButton = new Button("Reset Progress", 300, 100, 0xff5555);
resetButton.x = 200; // Position in bottom left
resetButton.y = 2732 - 100; // Position near bottom
resetButton.up = function (x, y, obj) {
	tween(resetButton, {
		scaleX: 1,
		scaleY: 1
	}, {
		duration: 100
	});
	// Reset all progress
	money = 100;
	followers = 0;
	memeLevel = 1;
	studioLevel = 1;
	staffLevel = 0;
	marketingLevel = 0;
	autoEarningRate = 0;
	membershipLevel = 0;
	// Reset upgrade levels
	upgradeLevels.quality = memeLevel;
	upgradeLevels.membership = membershipLevel;
	upgradeLevels.staff = staffLevel;
	upgradeLevels.equipment = studioLevel;
	// Reset upgrade prices
	upgradePrices.quality = calculateUpgradeCost(1, memeLevel);
	upgradePrices.membership = 500;
	upgradePrices.staff = calculateUpgradeCost(3, staffLevel);
	upgradePrices.equipment = calculateUpgradeCost(2, studioLevel);
	// Update storage
	updateStorage();
	// Update UI
	memeStudio.updateMemeQuality(memeLevel);
	memeUpgradeButton.updateLevel(memeLevel);
	memeUpgradeButton.updatePrice(calculateUpgradeCost(1, memeLevel));
	studioUpgradeButton.updateLevel(studioLevel);
	studioUpgradeButton.updatePrice(calculateUpgradeCost(2, studioLevel));
	staffUpgradeButton.updateLevel(staffLevel);
	staffUpgradeButton.updatePrice(calculateUpgradeCost(3, staffLevel));
	// Play sound
	LK.getSound('levelUp').play();
};
game.addChild(resetButton);
// Stats display
var statsContainer = new Container();
statsContainer.x = 2048 / 2;
statsContainer.y = 180;
game.addChild(statsContainer);
var moneyIcon = LK.getAsset('moneyIcon', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: -600
});
statsContainer.addChild(moneyIcon);
var moneyText = new Text2("$" + money, {
	size: 54,
	fill: 0x000000
});
moneyText.anchor.set(0, 0.5);
moneyText.x = -570;
statsContainer.addChild(moneyText);
var followerIcon = LK.getAsset('followerIcon', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 400
});
statsContainer.addChild(followerIcon);
var followerText = new Text2(followers + " followers", {
	size: 54,
	fill: 0x000000
});
followerText.anchor.set(0, 0.5);
followerText.x = 430;
statsContainer.addChild(followerText);
var autoEarningText = new Text2("", {
	size: 36,
	fill: 0x333333
});
autoEarningText.anchor.set(0.5, 0.5);
autoEarningText.y = 80;
statsContainer.addChild(autoEarningText);
// Create upgrade tab contents
var studioContent = new Container();
// Meme Quality Upgrade
var memeUpgradeButton = new UpgradeButton("Meme Quality", "Better memes = more $$$", calculateUpgradeCost(1, memeLevel), memeLevel, function () {
	var cost = calculateUpgradeCost(1, memeLevel);
	if (money >= cost) {
		money -= cost;
		memeLevel++;
		memeUpgradeButton.updateLevel(memeLevel);
		memeUpgradeButton.updatePrice(calculateUpgradeCost(1, memeLevel));
		memeStudio.updateMemeQuality(memeLevel);
		updateAutoEarningRate();
		updateStorage();
		LK.getSound('levelUp').play();
	}
});
memeUpgradeButton.x = -700;
memeUpgradeButton.y = 0;
studioContent.addChild(memeUpgradeButton);
// Studio Upgrade
var studioUpgradeButton = new UpgradeButton("Studio Equipment", "Better equipment = better production", calculateUpgradeCost(2, studioLevel), studioLevel, function () {
	var cost = calculateUpgradeCost(2, studioLevel);
	if (money >= cost) {
		money -= cost;
		studioLevel++;
		studioUpgradeButton.updateLevel(studioLevel);
		studioUpgradeButton.updatePrice(calculateUpgradeCost(2, studioLevel));
		updateStorage();
		LK.getSound('levelUp').play();
	}
});
studioUpgradeButton.x = 0;
studioUpgradeButton.y = 0;
studioContent.addChild(studioUpgradeButton);
// Staff Upgrade
var staffUpgradeButton = new UpgradeButton("Hire Staff", "More staff = MASSIVE auto-income", calculateUpgradeCost(3, staffLevel), staffLevel, function () {
	var cost = calculateUpgradeCost(3, staffLevel);
	if (money >= cost) {
		money -= cost;
		staffLevel++;
		staffUpgradeButton.updateLevel(staffLevel);
		staffUpgradeButton.updatePrice(calculateUpgradeCost(3, staffLevel));
		updateAutoEarningRate();
		updateStorage();
		LK.getSound('levelUp').play();
	}
});
staffUpgradeButton.x = 700;
staffUpgradeButton.y = 0;
studioContent.addChild(staffUpgradeButton);
// Create upgrade screen (initially hidden)
var upgradeScreen = new UpgradeScreen();
upgradeScreen.visible = false;
game.addChild(upgradeScreen);
// Initialize upgrade screen
upgradeScreen.initialize(game, upgradePrices, upgradeLevels);
// Studio content is displayed directly without tabs
studioContent.x = 2048 / 2;
studioContent.y = 2732 / 2 + 400;
game.addChild(studioContent);
// Set callback for create meme button
memeStudio.setCreateButtonCallback(function () {
	var result = createMeme();
	memeStudio.showEarnings(result.earnings, result.followers);
	LK.getSound('coin').play();
});
// Set callback for create video button
memeStudio.setCreateVideoButtonCallback(function () {
	showGameSelector();
});
// Start background music
LK.playMusic('bgMusic', {
	fade: {
		start: 0,
		end: 0.4,
		duration: 1000
	}
});
// Calculate any offline earnings when game starts
calculateOfflineEarnings();
// Set up auto earning timer
var lastAutoEarningTime = Date.now();
// Update UI with current values
function updateUI() {
	moneyText.setText("$" + Math.floor(money));
	followerText.setText(Math.floor(followers) + " followers");
	if (autoEarningRate > 0) {
		autoEarningText.setText("Auto earning: $" + Math.floor(autoEarningRate / 180) + " / 20 seconds");
	} else {
		autoEarningText.setText("");
	}
}
// Add game reference to global scope so it can be accessed from upgradeScreen
game.money = money;
game.memeLevel = memeLevel;
game.studioLevel = studioLevel;
game.staffLevel = staffLevel;
game.levels = upgradeLevels;
game.updateStorage = updateStorage;
game.updateAutoEarningRate = updateAutoEarningRate;
// Main game update loop
game.update = function () {
	// Handle auto earnings
	var now = Date.now();
	var elapsed = now - lastAutoEarningTime;
	if (elapsed >= AUTO_EARNINGS_INTERVAL && autoEarningRate > 0) {
		// Calculate earnings for this period (20 seconds is 1/180th of an hour)
		var earnings = Math.floor(autoEarningRate / 180);
		if (earnings > 0) {
			money += earnings;
			lastAutoEarningTime = now;
			updateStorage();
		}
	}
	// Update UI elements
	updateUI();
	// Sync game reference values
	game.money = money;
	// Update upgrade screen buttons if visible
	if (upgradeScreen.visible) {
		upgradeScreen.updateButtons(game, upgradePrices);
	}
	// Enable/disable upgrade buttons based on available money
	if (money >= calculateUpgradeCost(1, memeLevel)) {
		memeUpgradeButton.enable();
	} else {
		memeUpgradeButton.disable();
	}
	if (money >= calculateUpgradeCost(2, studioLevel)) {
		studioUpgradeButton.enable();
	} else {
		studioUpgradeButton.disable();
	}
	if (money >= calculateUpgradeCost(3, staffLevel)) {
		staffUpgradeButton.enable();
	} else {
		staffUpgradeButton.disable();
	}
};
// MatchingGame instance (initially null)
var matchingGame = null;
// Function to start Matching game
function startMatchingGame() {
	// Hide game selector
	gameSelector.visible = false;
	// Create new MatchingGame or reset existing one
	if (!matchingGame) {
		matchingGame = new MatchingGame();
		matchingGame.x = 2048 / 2;
		matchingGame.y = 2732 / 2;
		game.addChild(matchingGame);
	} else {
		// Remove existing game and create a new one
		game.removeChild(matchingGame);
		matchingGame = new MatchingGame();
		matchingGame.x = 2048 / 2;
		matchingGame.y = 2732 / 2;
		game.addChild(matchingGame);
	}
	// Show the game
	matchingGame.visible = true;
	// Set callback for when game finishes
	matchingGame.setFinishCallback(function () {
		// Hide Matching game
		matchingGame.visible = false;
		// Show main screen
		hideGameSelector();
		// Give rewards for completing video game - memory games give a bit more followers
		var videoEarnings = MEME_BASE_INCOME * memeLevel * studioLevel * 3.5;
		var videoFollowers = MEME_BASE_FOLLOWERS * memeLevel * 4;
		// Apply membership bonus if active
		if (membershipLevel > 0) {
			videoEarnings = Math.floor(videoEarnings * 1.5);
		}
		// Apply randomness
		var randomFactor = 0.9 + Math.random() * 0.2;
		videoEarnings = Math.floor(videoEarnings * randomFactor);
		// Update game state
		money += videoEarnings;
		followers += videoFollowers;
		// Show earnings
		memeStudio.showEarnings(videoEarnings, videoFollowers);
		// Play coin sound
		LK.getSound('coin').play();
		// Update storage
		updateStorage();
	});
} ===================================================================
--- original.js
+++ change.js
@@ -495,11 +495,30 @@
 	self.addChild(connect4Button);
 	var matchingButton = new Button("Memory Match", 600, 200, 0x2196F3);
 	matchingButton.y = -400;
 	self.addChild(matchingButton);
+	// Create locked indicator for matching game
+	var lockedText = new Text2("100 followers needed", {
+		size: 32,
+		fill: 0xFF5733
+	});
+	lockedText.anchor.set(0.5, 0.5);
+	lockedText.y = -330;
+	lockedText.visible = false;
+	self.addChild(lockedText);
 	var backButton = new Button("Go Back", 400, 130, 0xff5555);
 	backButton.y = 900;
 	self.addChild(backButton);
+	// Update lock status based on follower count
+	self.updateLockStatus = function (followerCount) {
+		if (followerCount >= 100) {
+			matchingButton.setColor(0x2196F3); // Normal color
+			lockedText.visible = false;
+		} else {
+			matchingButton.setColor(0x888888); // Grayed out
+			lockedText.visible = true;
+		}
+	};
 	self.setGameCallback = function (callback) {
 		connect4Button.up = function (x, y, obj) {
 			tween(connect4Button, {
 				scaleX: 1,
@@ -518,9 +537,30 @@
 			}, {
 				duration: 100
 			});
 			if (callback) {
-				callback("matching");
+				// Only allow matching game if followers >= 100
+				if (followers >= 100) {
+					callback("matching");
+				} else {
+					// Show a temporary message that game is locked
+					tween(lockedText, {
+						alpha: 1,
+						y: -330
+					}, {
+						duration: 300,
+						onFinish: function onFinish() {
+							LK.setTimeout(function () {
+								tween(lockedText, {
+									alpha: 0,
+									y: -310
+								}, {
+									duration: 300
+								});
+							}, 1500);
+						}
+					});
+				}
 			}
 		};
 	};
 	self.setBackCallback = function (callback) {
@@ -1291,8 +1331,10 @@
 	gameSelector.visible = true;
 	memeStudio.visible = false;
 	statsContainer.visible = false;
 	studioContent.visible = false;
+	// Update matching game lock status based on current follower count
+	gameSelector.updateLockStatus(followers);
 }
 // Function to hide game selector and show the main screen
 function hideGameSelector() {
 	gameSelector.visible = false;
:quality(85)/https://cdn.frvr.ai/6810df98886a67ee710bc15c.png%3F3) 
 Modern App Store icon, high definition, square with rounded corners, for a game titled "Meme Empire Tycoon" and with the description "Build your meme empire from scratch in this addictive tycoon game! Create viral content, hire talented staff, upgrade your studio, and strategically expand your meme business across multiple platforms to become the internet's most influential meme creator.". No text on icon!
:quality(85)/https://cdn.frvr.ai/6810e039886a67ee710bc163.png%3F3) 
 Green button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6810e68d9dcd06d468edb764.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6810e6ad9dcd06d468edb766.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6810e6c89dcd06d468edb768.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6810e6e79dcd06d468edb76a.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6810e81a886a67ee710bc196.png%3F3) 
 Youtube silver play button. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68128e8631e90df6e3a79797.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68128e9d31e90df6e3a79799.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6812903d31e90df6e3a7979b.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6812904331e90df6e3a7979d.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6812904931e90df6e3a7979f.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/6812d1c021b2d4faceef26c8.png%3F3) 
 Wheel of fortune. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68136aad8a910fef600d6a58.png%3F3) 
 Wheel of fortune without the stand. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68136d0031e90df6e3a797c5.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68162d7ff64e46cb4179fd88.png%3F3) 
 Coin potion. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68181bcdb2bf21f1a424646e.png%3F3) 
 Diamond. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6818cbcc34fc36a2e12fd931.png%3F3) 
 Archery target. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6818cdd834fc36a2e12fd940.png%3F3) 
 Arrow. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6818ce7534fc36a2e12fd947.png%3F3) 
 Fish. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6818cebb34fc36a2e12fd951.png%3F3) 
 Purple fish. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6818cef534fc36a2e12fd957.png%3F3) 
 Golden fish. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681b8815f25587d7a0654099.png%3F3) 
 Red cup. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/681bdde6a31d107d050d11fc.png%3F3) 
 Mute music logo. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/68236e2403c085db02359a5c.png%3F3)