User prompt
Let the animation of zoom and zoom back played even before the click on startgamebutton.
User prompt
Add short zooming to the screen and back smoothly and continuously for startgamebutton βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
don't make it on background0 just front of its image.
User prompt
center the startgamebutton
User prompt
Add the startgame as button to the game when clicked remove it with background0
User prompt
reorder startgame button with background0
User prompt
make the startgame button on the first
User prompt
reorder 'background0' with 'startgame'
User prompt
Add the "startgame" asset as button on the background0
User prompt
Make background0 the first image on the screen
User prompt
reorder 'build' asset to appear after background0 image on the screen.
User prompt
reorder 'build' asset to appear before background0 image on the screen.
User prompt
reoder 'build' to appear behind background0
User prompt
Reorder background0 to be before the build, coin, scorewall, and scoretext assets
User prompt
Please fix the bug: 'The supplied DisplayObject must be a child of the caller' in or related to this line: 'game.setChildIndex(buildAsset, game.children.length - 1);' Line Number: 89
User prompt
Reorder it to be after the 'build', 'coin' that is beside scorwall, 'scorewall', 'scoretext' on the screen.
User prompt
make it front of build asset
User prompt
Reorder it to front of all assets of the game
User prompt
Add a new asset background0 to the game on the front of the screen, and before the start of the game
User prompt
Add countdownStarted flag to tree16 down event handler to prevent timer reset when clicked. Modify tree16 placed duplicate up event handler to prevent dragging/resetting timer during countdown.
User prompt
Add countdownStarted flag to tree15 down event handler to prevent timer reset when clicked. Modify tree15 placed duplicate up event handler to prevent dragging/resetting timer during countdown.
Code edit (1 edits merged)
Please save this source code
User prompt
move the coin to the top
Code edit (1 edits merged)
Please save this source code
User prompt
Add countdownStarted flag to tree14 down event handler to prevent timer reset when clicked. Modify tree14 placed duplicate up event handler to prevent dragging/resetting timer during countdown.
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x73f8a8
});
/**** 
* Game Code
****/ 
// Add background0 as an intro screen
var background0 = LK.getAsset('background0', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2,
	// Center horizontally
	y: 2732 / 2 // Center vertically
});
game.addChildAt(background0, 0);
// Add startgame button to the intro screen
var startGameButton = LK.getAsset('Startgame', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2,
	// Center horizontally
	y: 2732 / 2 // Center vertically
});
game.addChild(startGameButton);
// Make sure background0 is at the bottom
game.setChildIndex(background0, 0);
// Create continuous zoom animation
function createButtonPulse() {
	tween(startGameButton, {
		scale: 1.1
	}, {
		duration: 800,
		easing: tween.easeInOut,
		onFinish: function onFinish() {
			tween(startGameButton, {
				scale: 1
			}, {
				duration: 800,
				easing: tween.easeInOut,
				onFinish: createButtonPulse
			});
		}
	});
}
// Start the continuous pulse animation immediately
createButtonPulse();
// Add click functionality to start button
startGameButton.down = function () {
	// Cancel ongoing animations
	tween.cancel(startGameButton);
	// Add a quick zoom animation when button is clicked
	tween(this, {
		scale: 1.2
	}, {
		duration: 200,
		easing: tween.easeOut,
		onFinish: function onFinish() {
			// Zoom back and then hide the elements
			tween(startGameButton, {
				scale: 1
			}, {
				duration: 150,
				easing: tween.easeIn,
				onFinish: function onFinish() {
					// Hide intro screen and show game screen
					background0.visible = false;
					startGameButton.visible = false;
					background1.visible = true;
					// Start the game music
					LK.playMusic('Gamemusic1');
				}
			});
		}
	});
};
// Setup background1 for the main game
var background1 = LK.getAsset('background1', {
	anchorX: 0.5,
	anchorY: 0.5,
	x: 2048 / 2,
	// Center horizontally
	y: 2732 / 2,
	// Center vertically
	speed: 5,
	// Add speed property for background1
	hd: true,
	// Enable HD mode for the image
	quality: "hd",
	// Explicitly set HD quality
	visible: false // Initially hidden until game starts
});
background1.dragOffset = {
	x: 0,
	y: 0
}; // Initialize dragOffset
// Add drag functionality to background1
background1.down = function (x, y, obj) {
	this.dragging = true;
	this.data = obj;
	var newPosition = this.parent.toLocal(obj.global);
	this.dragOffset.x = this.x - newPosition.x; // Calculate offset
	this.dragOffset.y = this.y - newPosition.y; // Calculate offset
};
background1.move = function (x, y, obj) {
	if (this.dragging) {
		var newPosition = this.parent.toLocal(obj.global);
		var deltaX = newPosition.x + this.dragOffset.x - this.x; // Calculate deltaX
		var deltaY = newPosition.y + this.dragOffset.y - this.y; // Calculate deltaY
		this.x += deltaX; // Update position
		this.y += deltaY; // Update position
		button2Text.x -= deltaX; // Prevent button2Text from moving
		button2Text.y -= deltaY; // Prevent button2Text from moving
		button1Text.x -= deltaX; // Prevent button1Text from moving
		button1Text.y -= deltaY; // Prevent button1Text from moving
		scoreText.x -= deltaX; // Prevent scoreText from moving
		scoreText.y -= deltaY; // Prevent scoreText from moving
		scoreWall.x -= deltaX; // Prevent scoreWall from moving
		scoreWall.y -= deltaY; // Prevent scoreWall from moving
		if (house1.timerText) {
			house1.timerText.x = house1.x; // Reposition house1 timerText to house1's x
			house1.timerText.y = house1.y - house1.height / 2 - 20; // Reposition house1 timerText to above and close to house1
		}
		coinIcon.x -= deltaX; // Prevent coinIcon from moving
		coinIcon.y -= deltaY; // Prevent coinIcon from moving
		// Sync grid movement directly with background1
		game.children.forEach(function (child) {
			if (child !== background1 && child !== buildAsset && child !== button1Asset && child !== button2Asset && child !== background2 && child !== background3 && child !== scrollbar && child !== scrollbutton && child !== scrollbutton3 && child !== scrollbar3) {
				child.x += deltaX; // Move grid with the same delta as background1
				child.y += deltaY; // Move grid with the same delta as background1
			}
		});
	}
};
background1.up = function () {
	this.dragging = false;
	this.data = null;
	// Removed timer text addition and positioning from background1
};
game.addChildAt(background1, 0);
game.children.forEach(function (child) {
	if (child.assetId === 'Grid') {
		game.setChildIndex(child, game.children.length - 1);
	}
});
var scrollbar = LK.getAsset('scrollbar', {
	anchorX: 1.0,
	anchorY: 0.0,
	x: 2048,
	y: 0,
	visible: false // Initially hidden
});
var scrollbutton = LK.getAsset('scrollbutton', {
	anchorX: 1.0,
	anchorY: 0.5,
	x: 2048,
	y: 0,
	visible: false // Initially hidden
});
game.addChildAt(background1, 0);
var background2 = LK.getAsset('background2', {
	anchorX: 0.0,
	anchorY: 0.0,
	x: 0,
	y: 0,
	speed: 10,
	// Speed property for background2
	visible: false // Initially hidden
});
game.addChildAt(background2, game.children.length);
game.addChild(scrollbar);
game.addChild(scrollbutton);
background2.children.forEach(function (child) {
	return child.visible = false;
});
var background3 = LK.getAsset('background3', {
	anchorX: 0.0,
	anchorY: 0.0,
	x: 0,
	y: 0,
	speed: 10,
	// Speed property for background3
	visible: false // Initially hidden
});
game.children.forEach(function (child) {
	if (child.assetId === 'Grid') {
		game.setChildIndex(child, game.children.length - 1);
	}
});
game.addChildAt(background3, game.children.length);
background3.children.forEach(function (child) {
	return child.visible = false;
});
var scrollbar3 = LK.getAsset('scrollbar', {
	anchorX: 1.0,
	anchorY: 0.0,
	x: 2048,
	y: 0,
	visible: false // Initially hidden
});
game.addChild(scrollbar3);
var scrollbutton3 = LK.getAsset('scrollbutton', {
	anchorX: 1.0,
	anchorY: 0.5,
	x: 2048,
	y: 0,
	visible: false // Initially hidden
});
game.addChild(scrollbutton3);
var slotSpacing3 = 50; // Define the space between slots for background3
for (var i = 0; i < 4; i++) {
	var slot3 = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing3 + 450) + slotSpacing3 + 200,
		y: 300 // Arbitrary y position
	});
	background3.addChildAt(slot3, background3.children.length);
	// Add pricewall below each slot
	var pricewall3 = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot3.x,
		y: slot3.y + slot3.height / 2 + 0 // Position below the slot
	});
	background3.addChild(pricewall3);
	// Add trees to the slots of background3
	if (i === 0) {
		var tree1 = LK.getAsset('tree1', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree1);
		// Add pricetext below tree1
		var priceTextTree1 = new Text2('200AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree1.anchor.set(0.5, 0);
		priceTextTree1.x = slot3.x;
		priceTextTree1.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree1);
		tree1.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree1
			if (LK.getScore() >= 200) {
				LK.setScore(LK.getScore() - 200);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree1', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background1) + 1);
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('2:30', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownStarted = true; // Set flag
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										// Adjusted to drop to the bottom of the tree
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										// Bounce 3 times
										if (coin.y > this.y + 50 - bounceHeight) {
											// Adjusted to bounce from the bottom of the tree
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var tree2 = LK.getAsset('tree2', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree2);
		// Add pricetext below tree2
		var priceTextTree2 = new Text2('200AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree2.anchor.set(0.5, 0);
		priceTextTree2.x = slot3.x;
		priceTextTree2.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree2);
		tree2.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree2
			if (LK.getScore() >= 200) {
				LK.setScore(LK.getScore() - 200);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree2', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background1) + 1);
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging initially before placement
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('2:30', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					// Set flag to indicate countdown has started
					this.countdownStarted = true;
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									// Use 'this' which refers to the duplicate tree instance
									if (coin.y < this.y + 50) {
										//{6c} // Check against duplicate.y
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce.call(this); // Call bounce in the context of duplicate
									}
								}
								function bounce() {
									// Use 'this' which refers to the duplicate tree instance
									if (bounceCount < 3) {
										// Bounce 3 times
										if (coin.y > this.y + 50 - bounceHeight) {
											//{6m} // Check against duplicate.y
											coin.y -= bounceSpeed;
											LK.setTimeout(bounce.bind(this), 16); //{6s} // Continue bouncing
										} else {
											bounceCount++;
											bounceHeight /= 2;
											LK.setTimeout(bounce.bind(this), 16); //{6s} // Continue bouncing or start drop if done
										}
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} //{5j} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 2) {
		var tree3 = LK.getAsset('tree3', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree3);
		// Add pricetext below tree3
		var priceTextTree3 = new Text2('200AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree3.anchor.set(0.5, 0);
		priceTextTree3.x = slot3.x;
		priceTextTree3.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree3);
		tree3.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree3
			if (LK.getScore() >= 200) {
				LK.setScore(LK.getScore() - 200);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree3', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background1) + 1);
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('2:30', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} //{1u1} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 3) {
		var tree4 = LK.getAsset('tree4', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree4);
		// Add pricetext below tree4
		var priceTextTree4 = new Text2('200AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree4.anchor.set(0.5, 0);
		priceTextTree4.x = slot3.x;
		priceTextTree4.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree4);
		tree4.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree4
			if (LK.getScore() >= 200) {
				LK.setScore(LK.getScore() - 200);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree4', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background1) + 1);
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('2:30', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce.call(this); // Call bounce in the context of duplicate
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
											LK.setTimeout(bounce.bind(this), 16); // Continue bouncing
										} else {
											bounceCount++;
											bounceHeight /= 2;
											LK.setTimeout(bounce.bind(this), 16); // Continue bouncing or start drop if done
										}
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 13);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} //{fz} // End of if (!this.countdownStarted)
			};
		};
	}
}
// Add 4 slots below the first slots that are synced in background3
for (var i = 0; i < 4; i++) {
	var slot3 = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing3 + 450) + slotSpacing3 + 200,
		y: 900 // Increase y position to add more space
	});
	background3.addChildAt(slot3, background3.children.length);
	// Add pricewall below each slot in the second line
	var pricewall3 = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot3.x,
		y: slot3.y + slot3.height / 2 + 0 // Position below the slot
	});
	background3.addChild(pricewall3);
	// Add trees to the slots of background3
	if (i === 0) {
		var tree5 = LK.getAsset('tree5', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree5);
		// Add pricetext below tree5
		var priceTextTree5 = new Text2('300AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree5.anchor.set(0.5, 0);
		priceTextTree5.x = slot3.x;
		priceTextTree5.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree5);
		tree5.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree5
			if (LK.getScore() >= 300) {
				LK.setScore(LK.getScore() - 300);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree5', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var tree6 = LK.getAsset('tree6', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree6);
		// Add pricetext below tree6
		var priceTextTree6 = new Text2('300AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree6.anchor.set(0.5, 0);
		priceTextTree6.x = slot3.x;
		priceTextTree6.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree6);
		tree6.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree6
			if (LK.getScore() >= 300) {
				LK.setScore(LK.getScore() - 300);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree6', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce.call(this);
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										//{gs} // Bounce 3 times
										if (coin.y > this.y + 50 - bounceHeight) {
											//{gt} // Check against duplicate.y
											coin.y -= bounceSpeed;
											LK.setTimeout(bounce.bind(this), 16); // Continue bouncing
										} else {
											bounceCount++;
											bounceHeight /= 2;
											LK.setTimeout(bounce.bind(this), 16); // Continue bouncing or start drop if done
										}
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} //{fp} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 2) {
		var tree7 = LK.getAsset('tree7', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree7);
		// Add pricetext below tree7
		var priceTextTree7 = new Text2('300AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree7.anchor.set(0.5, 0);
		priceTextTree7.x = slot3.x;
		priceTextTree7.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree7);
		tree7.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree7
			if (LK.getScore() >= 300) {
				LK.setScore(LK.getScore() - 300);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree7', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 3) {
		var tree8 = LK.getAsset('tree8', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree8);
		// Add pricetext below tree8
		var priceTextTree8 = new Text2('300AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree8.anchor.set(0.5, 0);
		priceTextTree8.x = slot3.x;
		priceTextTree8.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree8);
		tree8.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree8
			if (LK.getScore() >= 300) {
				LK.setScore(LK.getScore() - 300);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree8', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 18);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	}
}
// Add another 4 slots below the second 4 slots
for (var i = 0; i < 4; i++) {
	var slot3 = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing3 + 450) + slotSpacing3 + 200,
		y: 1500 // Increase y position to add more space
	});
	background3.addChildAt(slot3, background3.children.length);
	// Add pricewall below each slot in the third line
	var pricewall3 = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot3.x,
		y: slot3.y + slot3.height / 2 + 0 // Position below the slot
	});
	background3.addChild(pricewall3);
	// Add trees to the slots of background3
	if (i === 0) {
		var tree9 = LK.getAsset('tree9', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree9);
		var priceTextTree9 = new Text2('400AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree9.anchor.set(0.5, 0);
		priceTextTree9.x = slot3.x;
		priceTextTree9.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree9);
		tree9.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree9
			if (LK.getScore() >= 400) {
				LK.setScore(LK.getScore() - 400);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree9', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 27);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 27);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 1) {
		var tree10 = LK.getAsset('tree10', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree10);
		var priceTextTree10 = new Text2('400AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree10.anchor.set(0.5, 0);
		priceTextTree10.x = slot3.x;
		priceTextTree10.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree10);
		tree10.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree10
			if (LK.getScore() >= 400) {
				LK.setScore(LK.getScore() - 400);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree10', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 27);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 27);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 2) {
		var tree11 = LK.getAsset('tree11', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree11);
		var priceTextTree11 = new Text2('400AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree11.anchor.set(0.5, 0);
		priceTextTree11.x = slot3.x;
		priceTextTree11.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree11);
		tree11.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree11
			if (LK.getScore() >= 400) {
				LK.setScore(LK.getScore() - 400);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree11', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 35);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 35);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 3) {
		var tree12 = LK.getAsset('tree12', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree12);
		var priceTextTree12 = new Text2('400AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree12.anchor.set(0.5, 0);
		priceTextTree12.x = slot3.x;
		priceTextTree12.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree12);
		tree12.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree12
			if (LK.getScore() >= 400) {
				LK.setScore(LK.getScore() - 400);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree12', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 35);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 35);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	}
}
// Add another 4 slots below the third 4 slots
for (var i = 0; i < 4; i++) {
	var slot3 = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing3 + 450) + slotSpacing3 + 200,
		y: 2100 // Increase y position to add more space
	});
	background3.addChildAt(slot3, background3.children.length);
	// Add pricewall below each slot in the fourth line
	var pricewall3 = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot3.x,
		y: slot3.y + slot3.height / 2 + 0 // Position below the slot
	});
	background3.addChild(pricewall3);
	// Add trees to the slots of background3
	if (i === 0) {
		var tree13 = LK.getAsset('tree13', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree13);
		// Add pricetext below tree13
		var priceTextTree13 = new Text2('500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree13.anchor.set(0.5, 0);
		priceTextTree13.x = slot3.x;
		priceTextTree13.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree13);
		tree13.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree13
			if (LK.getScore() >= 500) {
				LK.setScore(LK.getScore() - 500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree13', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true; //{xn} // Keep original xn identifier
					this.data = obj;
				} //{xo} // Keep original xo identifier
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false; //{xy} // Keep original xy identifier
					this.data = null;
					// Add timer text above the placed tree
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 1) {
		var tree14 = LK.getAsset('tree14', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree14);
		// Add pricetext below tree14
		var priceTextTree14 = new Text2('500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree14.anchor.set(0.5, 0);
		priceTextTree14.x = slot3.x;
		priceTextTree14.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree14);
		tree14.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree14
			if (LK.getScore() >= 500) {
				LK.setScore(LK.getScore() - 500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree14', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 2) {
		var tree15 = LK.getAsset('tree15', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree15);
		// Add pricetext below tree15
		var priceTextTree15 = new Text2('500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree15.anchor.set(0.5, 0);
		priceTextTree15.x = slot3.x;
		priceTextTree15.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree15);
		tree15.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree15
			if (LK.getScore() >= 500) {
				LK.setScore(LK.getScore() - 500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree15', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 45);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 45);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	} else if (i === 3) {
		var tree16 = LK.getAsset('tree16', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot3.x,
			y: slot3.y
		});
		background3.addChild(tree16);
		// Add pricetext below tree16
		var priceTextTree16 = new Text2('500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceTextTree16.anchor.set(0.5, 0);
		priceTextTree16.x = slot3.x;
		priceTextTree16.y = slot3.y + slot3.height / 2;
		background3.addChild(priceTextTree16);
		tree16.down = function (x, y, obj) {
			// Check if player has enough score to purchase tree16
			if (LK.getScore() >= 500) {
				LK.setScore(LK.getScore() - 500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('tree16', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background2));
			} else {
				return; // Not enough score, don't create duplicate
			}
			// Add timer text above the placed tree
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the tree
			duplicate.dragging = true;
			duplicate.data = obj;
			duplicate.countdownStarted = false; // Initialize countdown flag
			// Hide background3 and its components
			background3.visible = false;
			background1.visible = true;
			scrollbar3.visible = false;
			scrollbutton3.visible = false;
			background3.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Allow dragging only if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed tree
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the tree
					// Start countdown
					this.countdownStarted = true; // Set flag to indicate countdown has started
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - tree is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag when done
							// Spawn 2 coins in front of the tree
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - 100 // Start from the top to the bottom of the tree
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 3) {
										if (coin.y > this.y + 50 - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 45);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 45);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				} // End of if (!this.countdownStarted)
			};
		};
	}
}
scrollbutton3.down = function (x, y, obj) {
	this.dragging = true;
	this.data = obj;
	this.alpha = 0.5;
};
scrollbutton3.up = function () {
	this.alpha = 1;
	this.dragging = false;
	this.data = null;
};
scrollbutton3.move = function (x, y, obj) {
	if (this.dragging) {
		var newPosition = this.parent.toLocal(obj.global);
		// Limit the y position of the scrollbutton to the height of the scrollbar
		this.y = Math.max(Math.min(newPosition.y, scrollbar3.height - this.height / 2), this.height / 2);
		// Calculate the ratio of the scrollbutton's position to the scrollbar's height
		var ratio = (this.y - this.height / 2) / (scrollbar3.height - this.height);
		// Move the background3 up or down based on the ratio and the speed
		background3.y = -ratio * (background3.height - game.height);
	}
};
var buildAsset = LK.getAsset('Build', {
	anchorX: 0.5,
	// Center the anchor point horizontally
	anchorY: 0.0,
	// Anchor point at the top
	x: 150,
	// Position on the left side of the screen
	y: 400 // Position directly below the pause button
});
game.addChild(buildAsset);
var button1Asset = LK.getAsset('button1', {
	anchorX: 0.5,
	anchorY: 0.0,
	x: 400,
	y: 0,
	visible: false // Initially hidden
});
game.addChild(button1Asset);
var button2Asset = LK.getAsset('button2', {
	anchorX: 0.5,
	anchorY: 0.0,
	x: button1Asset.x + button1Asset.width + 10,
	y: 0,
	visible: false // Initially hidden
});
game.addChild(button2Asset);
// Add text 'House' to button1
var button1Text = new Text2('House', {
	size: 80,
	fill: 0xFFFFFF
});
button1Text.anchor.set(0.5, 0.5); // Center the text on the button
button1Text.x = button1Asset.x;
button1Text.y = button1Asset.y + button1Asset.height / 2;
button1Text.visible = false;
game.addChild(button1Text);
// Add text 'Tree' to button2
var button2Text = new Text2('Tree', {
	size: 80,
	fill: 0xFFFFFF
});
button2Text.anchor.set(0.5, 0.5); // Center the text on the button
button2Text.x = button2Asset.x;
button2Text.y = button2Asset.y + button2Asset.height / 2;
button2Text.visible = false;
game.addChild(button2Text);
// Add score text to the top right corner
var scoreWall = LK.getAsset('scorewall', {
	anchorX: 1,
	anchorY: 0,
	x: 2048,
	y: 0
});
game.addChild(scoreWall);
var coinIcon = LK.getAsset('Coin', {
	anchorX: 1,
	anchorY: 0,
	x: scoreWall.x - scoreWall.width - 10,
	// Position coin to the left of scoreWall
	y: -10
});
game.addChild(coinIcon);
var scoreText = new Text2('1000', {
	size: 100,
	fill: 0xFFFFFF
});
LK.setScore(1000);
scoreText.anchor.set(1, 0.5); // Anchor to the right middle
scoreText.x = scoreWall.x - 35; // Position near the right edge of scoreWall
scoreText.y = scoreWall.y + scoreWall.height / 2; // Center vertically with scoreWall
game.addChild(scoreText);
// When score changes, animate expansion from right to left
var originalUpdateScore = LK.setScore;
LK.setScore = function (value) {
	originalUpdateScore(value);
	// Animate expansion from right to left when score increases
	tween(scoreText, {
		scale: 1.2
	}, {
		duration: 200,
		easing: tween.easeOut,
		onFinish: function onFinish() {
			tween(scoreText, {
				scale: 1
			}, {
				duration: 200,
				easing: tween.easeIn
			});
		}
	});
	scoreText.setText(value);
};
// Function to update score
function updateScore() {
	var score = 0;
	game.children.forEach(function (child) {
		if (child.assetId && child.assetId.startsWith('tree')) {
			score++;
		}
	});
	scoreText.setText('Score: ' + score);
}
// Add click event to button2 to toggle visibility of background3, its slots, and scroll components
button2Asset.down = function (x, y, obj) {
	// Toggle visibility of background3 and its components
	background3.visible = !background3.visible;
	game.children.forEach(function (child) {
		if (child.assetId === 'Grid') {
			child.visible = false;
		}
	});
	scrollbar3.visible = !scrollbar3.visible;
	scrollbutton3.visible = !scrollbutton3.visible;
	background3.children.forEach(function (child) {
		child.visible = background3.visible;
	});
	// Toggle visibility of background1 based on background2 and background3 visibility
	background1.visible = !(background2.visible || background3.visible);
	// Hide all grids when button2 is clicked
};
// Add click event to button1 to toggle visibility of background2, its slots, and scroll components
button1Asset.down = function (x, y, obj) {
	// Toggle visibility of background2 and its components
	background2.visible = !background2.visible;
	game.children.forEach(function (child) {
		if (child.assetId === 'Grid') {
			child.visible = false;
		}
	});
	scrollbar.visible = !scrollbar.visible;
	scrollbutton.visible = !scrollbutton.visible;
	background2.children.forEach(function (child) {
		child.visible = background2.visible;
	});
	// Toggle visibility of background1 based on background2 and background3 visibility
	background1.visible = !(background2.visible || background3.visible);
	// Hide all grids when button1 is clicked
};
// Add click event to build asset to hide background2 and background3 with their components
buildAsset.down = function (x, y, obj) {
	button1Asset.visible = !button1Asset.visible;
	button1Text.visible = !button1Text.visible;
	button2Asset.visible = !button2Asset.visible;
	button2Text.visible = !button2Text.visible;
	background2.visible = false;
	scrollbar.visible = false;
	scrollbutton.visible = false;
	background3.visible = false;
	scrollbar3.visible = false;
	scrollbutton3.visible = false;
	background1.visible = true; // Ensure background1 is always visible when build is clicked
};
var slotSpacing = 50; // Define the space between slots
for (var i = 0; i < 4; i++) {
	var slot = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing + 450) + slotSpacing + 200,
		// Position slots with space between them
		y: 300 // Arbitrary y position
	});
	background2.addChildAt(slot, background2.children.length);
	// Add pricewall below each slot
	var pricewall = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot.x,
		y: slot.y + slot.height / 2 + 0 // Position below the slot
	});
	background2.addChild(pricewall);
	// Add house1 to the first slot on the left
	if (i === 0) {
		var house1 = LK.getAsset('house1', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house1);
		// Add pricetext below house1
		var priceText1 = new Text2('50AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText1.anchor.set(0.5, 0);
		priceText1.x = pricewall.x;
		priceText1.y = pricewall.y + pricewall.height / 2 - priceText1.height / 2;
		background2.addChild(priceText1);
		house1.down = function (x, y, obj) {
			// Check if player has enough score to purchase house1
			if (LK.getScore() >= 50) {
				LK.setScore(LK.getScore() - 50);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house1', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house - prevent dragging and timer reset
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house only if it doesn't exist yet
				if (!this.timerText) {
					this.timerText = new Text2('2:30', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
				// Removed grid snapping logic for house1
			};
		};
	} else if (i === 1) {
		var house2 = LK.getAsset('house2', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house2);
		// Add pricetext below house2
		var priceText2 = new Text2('50AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText2.anchor.set(0.5, 0);
		priceText2.x = pricewall.x;
		priceText2.y = pricewall.y + pricewall.height / 2 - priceText2.height / 2;
		background2.addChild(priceText2);
		house2.down = function (x, y, obj) {
			// Check if player has enough score to purchase house2
			if (LK.getScore() >= 50) {
				LK.setScore(LK.getScore() - 50);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house2', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house - prevent dragging and timer reset
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house only if it doesn't exist yet
				if (!this.timerText) {
					this.timerText = new Text2('2:30', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
				// Removed grid snapping logic for house1
			};
		};
	} else if (i === 2) {
		var house3 = LK.getAsset('house3', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house3);
		// Add pricetext below house3
		var priceText3 = new Text2('150AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText3.anchor.set(0.5, 0);
		priceText3.x = pricewall.x;
		priceText3.y = pricewall.y + pricewall.height / 2 - priceText3.height / 2;
		background2.addChild(priceText3);
		house3.down = function (x, y, obj) {
			// Check if player has enough score to purchase house3
			if (LK.getScore() >= 150) {
				LK.setScore(LK.getScore() - 150);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house3', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house - prevent dragging and timer reset
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house
				if (!this.timerText) {
					this.timerText = new Text2('2:30', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 3) {
		var house4 = LK.getAsset('house4', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house4);
		// Add pricetext below house4
		var priceText4 = new Text2('250AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText4.anchor.set(0.5, 0);
		priceText4.x = pricewall.x;
		priceText4.y = pricewall.y + pricewall.height / 2 - priceText4.height / 2;
		background2.addChild(priceText4);
		house4.down = function (x, y, obj) {
			// Check if player has enough score to purchase house4
			if (LK.getScore() >= 250) {
				LK.setScore(LK.getScore() - 250);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house4', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('2:30', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house - prevent dragging and timer reset
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house
				if (!this.timerText) {
					this.timerText = new Text2('2:30', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 150; // 2:30 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 11);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
				// Removed grid snapping logic for house4
			};
		};
	}
}
// Add 4 slots below the first line of slots that are synced in background2
for (var i = 0; i < 4; i++) {
	var slot = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing + 450) + slotSpacing + 200,
		y: 900 // Increase y position to add more space
	});
	background2.addChildAt(slot, background2.children.length);
	// Add pricewall below each slot in the second line
	var pricewall = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot.x,
		y: slot.y + slot.height / 2 + 0 // Position below the slot
	});
	background2.addChild(pricewall);
	// Add house5 to the first slot in the second line
	if (i === 0) {
		var house5 = LK.getAsset('house5', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house5);
		// Add pricetext below house5
		var priceText5 = new Text2('300AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText5.anchor.set(0.5, 0);
		priceText5.x = pricewall.x;
		priceText5.y = pricewall.y + pricewall.height / 2 - priceText5.height / 2;
		background2.addChild(priceText5);
		house5.down = function (x, y, obj) {
			// Check if player has enough score to purchase house5
			if (LK.getScore() >= 300) {
				LK.setScore(LK.getScore() - 300);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house5', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house - prevent dragging and timer reset
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house
				if (!this.timerText) {
					this.timerText = new Text2('10:00', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
				// Removed grid snapping logic for house5
			};
		};
	} else if (i === 1) {
		var house6 = LK.getAsset('house6', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house6);
		// Add pricetext below house6
		var priceText6 = new Text2('700AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText6.anchor.set(0.5, 0);
		priceText6.x = pricewall.x;
		priceText6.y = pricewall.y + pricewall.height / 2 - priceText6.height / 2;
		background2.addChild(priceText6);
		house6.down = function (x, y, obj) {
			// Check if player has enough score to purchase house6
			if (LK.getScore() >= 700) {
				LK.setScore(LK.getScore() - 700);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house6', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				this.dragging = false;
				this.data = null;
				// Add timer text above the placed house
				if (!this.timerText) {
					this.timerText = new Text2('10:00', {
						size: 50,
						fill: 0xFFFFFF
					});
					this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
					game.addChild(this.timerText);
				}
				this.timerText.x = this.x;
				this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
				// Start countdown only if not already started
				if (!this.countdownStarted) {
					this.countdownStarted = true;
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
				// Removed grid snapping logic for house6
			};
		};
	} else if (i === 2) {
		var house7 = LK.getAsset('house7', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house7);
		// Add pricetext below house7
		var priceText7 = new Text2('1500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText7.anchor.set(0.5, 0);
		priceText7.x = pricewall.x;
		priceText7.y = pricewall.y + pricewall.height / 2 - priceText7.height / 2;
		background2.addChild(priceText7);
		house7.down = function (x, y, obj) {
			// Check if player has enough score to purchase house7
			if (LK.getScore() >= 1500) {
				LK.setScore(LK.getScore() - 1500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house7', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Only add timer text if it doesn't exist AND countdown hasn't started yet
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown only if not already started
					this.countdownStarted = true;
					this.countdown = 600; // 10:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 14);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 3) {
		var house8 = LK.getAsset('house8', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house8);
		// Add pricetext below house8
		var priceText8 = new Text2('2250AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText8.anchor.set(0.5, 0);
		priceText8.x = pricewall.x;
		priceText8.y = pricewall.y + pricewall.height / 2 - priceText8.height / 2;
		background2.addChild(priceText8);
		house8.down = function (x, y, obj) {
			// Check if player has enough score to purchase house8
			if (LK.getScore() >= 2250) {
				LK.setScore(LK.getScore() - 2250);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house8', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('10:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('10:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown only if not already started
					if (!this.countdownStarted) {
						this.countdownStarted = true;
						this.countdown = 600; // 10:00 minutes
						if (this.countdownInterval) {
							LK.clearInterval(this.countdownInterval);
						}
						// Prevent further movement after placing and before countdown finishes
						this.down = function () {
							// Do nothing - house is now fixed in place until timer finishes
						};
						this.move = function () {
							// Do nothing - house is now fixed in place until timer finishes
						};
						this.countdownInterval = LK.setInterval(function () {
							this.countdown--;
							var minutes = Math.floor(this.countdown / 60);
							var seconds = this.countdown % 60;
							this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
							if (this.countdown <= 0) {
								LK.clearInterval(this.countdownInterval);
								game.removeChild(this.timerText);
								this.timerText = null; // Reset timerText to null
								this.countdownStarted = false; // Reset countdown started flag
								// Spawn 2 coins in front of the house
								var coin1 = LK.getAsset('Coin', {
									anchorX: 0.5,
									anchorY: 0.5,
									x: this.x - 50,
									y: this.y - this.height
								});
								var coin2 = LK.getAsset('Coin', {
									anchorX: 0.5,
									anchorY: 0.5,
									x: this.x + 50,
									y: this.y - this.height
								});
								game.addChildAt(coin1, game.getChildIndex(background2));
								game.addChildAt(coin2, game.getChildIndex(background2));
								// Function to animate the coin drop and bounce
								var animateCoin = function animateCoin(coin) {
									var bounceCount = 0;
									var bounceHeight = 20;
									var dropSpeed = 5;
									var bounceSpeed = 2;
									function drop() {
										if (coin.y < this.y + 50) {
											coin.y += dropSpeed;
											LK.setTimeout(drop.bind(this), 16);
										} else {
											bounce();
										}
									}
									function bounce() {
										if (bounceCount < 2) {
											if (coin.y > this.y - bounceHeight) {
												coin.y -= bounceSpeed;
											} else {
												bounceCount++;
												bounceHeight /= 2;
											}
											LK.setTimeout(bounce.bind(this), 16);
										}
									}
									drop.call(this);
								};
								animateCoin.call(this, coin1);
								animateCoin.call(this, coin2);
								coin1.down = function () {
									game.removeChild(coin1);
									LK.setScore(LK.getScore() + 14);
									scoreText.setText(LK.getScore());
								};
								coin2.down = function () {
									game.removeChild(coin2);
									LK.setScore(LK.getScore() + 14);
									scoreText.setText(LK.getScore());
								};
							}
						}.bind(this), 1000);
					}
				}
			};
		};
	}
}
// Add 4 slots below the second line of slots that are synced in background2
for (var i = 0; i < 4; i++) {
	var slot = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing + 450) + slotSpacing + 200,
		y: 1500 // Increase y position to add more space
	});
	background2.addChildAt(slot, background2.children.length);
	// Add pricewall below each slot in the third line
	var pricewall = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot.x,
		y: slot.y + slot.height / 2 + 0 // Position below the slot
	});
	background2.addChild(pricewall);
	// Add houses to the third line of slots
	if (i === 0) {
		var house9 = LK.getAsset('house9', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house9);
		// Add pricetext below house9
		var priceText9 = new Text2('4540AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText9.anchor.set(0.5, 0);
		priceText9.x = pricewall.x;
		priceText9.y = pricewall.y + pricewall.height / 2 - priceText9.height / 2;
		background2.addChild(priceText9);
		house9.down = function (x, y, obj) {
			// Check if player has enough score to purchase house9
			if (LK.getScore() >= 4540) {
				LK.setScore(LK.getScore() - 4540);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house9', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var house10 = LK.getAsset('house10', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house10);
		// Add pricetext below house10
		var priceText10 = new Text2('7410AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText10.anchor.set(0.5, 0);
		priceText10.x = pricewall.x;
		priceText10.y = pricewall.y + pricewall.height / 2 - priceText10.height / 2;
		background2.addChild(priceText10);
		house10.down = function (x, y, obj) {
			// Check if player has enough score to purchase house10
			if (LK.getScore() >= 7410) {
				LK.setScore(LK.getScore() - 7410);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house10', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.countdownStarted = false; // Initialize countdown flag
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 2) {
		var house11 = LK.getAsset('house11', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house11);
		// Add pricetext below house11
		var priceText11 = new Text2('8330AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText11.anchor.set(0.5, 0);
		priceText11.x = pricewall.x;
		priceText11.y = pricewall.y + pricewall.height / 2 - priceText11.height / 2;
		background2.addChild(priceText11);
		house11.down = function (x, y, obj) {
			// Check if player has enough score to purchase house11
			if (LK.getScore() >= 8330) {
				LK.setScore(LK.getScore() - 8330);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house11', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 3) {
		var house12 = LK.getAsset('house12', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house12);
		// Add pricetext below house12
		var priceText12 = new Text2('9210AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText12.anchor.set(0.5, 0);
		priceText12.x = pricewall.x;
		priceText12.y = pricewall.y + pricewall.height / 2 - priceText12.height / 2;
		background2.addChild(priceText12);
		house12.down = function (x, y, obj) {
			// Check if player has enough score to purchase house12
			if (LK.getScore() >= 9210) {
				LK.setScore(LK.getScore() - 9210);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house12', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var house10 = LK.getAsset('house10', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house10);
		// Add pricetext below house10
		var priceText10 = new Text2('7410AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText10.anchor.set(0.5, 0);
		priceText10.x = pricewall.x;
		priceText10.y = pricewall.y + pricewall.height / 2 - priceText10.height / 2;
		background2.addChild(priceText10);
		house10.down = function (x, y, obj) {
			// Check if player has enough score to purchase house10
			if (LK.getScore() >= 7410) {
				LK.setScore(LK.getScore() - 7410);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house10', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('15:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.countdownStarted = false; // Initialize countdown flag
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('15:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 900; // 15:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 20);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	}
}
// Add 4 slots below the third line of slots that are synced in background2
for (var i = 0; i < 4; i++) {
	var slot = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing + 450) + slotSpacing + 200,
		y: 2100 // Increase y position to add more space
	});
	background2.addChildAt(slot, background2.children.length);
	// Add pricewall below each slot in the third line
	var pricewall = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot.x,
		y: slot.y + slot.height / 2 + 0 // Position below the slot
	});
	background2.addChild(pricewall);
	// Add houses to the fourth line of slots
	if (i === 0) {
		var house13 = LK.getAsset('house13', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house13);
		// Add pricetext below house13
		var priceText13 = new Text2('14500AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText13.anchor.set(0.5, 0);
		priceText13.x = pricewall.x;
		priceText13.y = pricewall.y + pricewall.height / 2 - priceText13.height / 2;
		background2.addChild(priceText13);
		house13.down = function (x, y, obj) {
			// Check if player has enough score to purchase house13
			if (LK.getScore() >= 14500) {
				LK.setScore(LK.getScore() - 14500);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house13', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var house14 = LK.getAsset('house14', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house14);
		// Add pricetext below house14
		var priceText14 = new Text2('18000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText14.anchor.set(0.5, 0);
		priceText14.x = pricewall.x;
		priceText14.y = pricewall.y + pricewall.height / 2 - priceText14.height / 2;
		background2.addChild(priceText14);
		house14.down = function (x, y, obj) {
			// Check if player has enough score to purchase house14
			if (LK.getScore() >= 18000) {
				LK.setScore(LK.getScore() - 18000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house14', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 2) {
		var house15 = LK.getAsset('house15', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house15);
		// Add pricetext below house15
		var priceText15 = new Text2('25000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText15.anchor.set(0.5, 0);
		priceText15.x = pricewall.x;
		priceText15.y = pricewall.y + pricewall.height / 2 - priceText15.height / 2;
		background2.addChild(priceText15);
		house15.down = function (x, y, obj) {
			// Check if player has enough score to purchase house15
			if (LK.getScore() >= 25000) {
				LK.setScore(LK.getScore() - 25000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house15', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 3) {
		var house16 = LK.getAsset('house16', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house16);
		// Add pricetext below house16
		var priceText16 = new Text2('50000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText16.anchor.set(0.5, 0);
		priceText16.x = pricewall.x;
		priceText16.y = pricewall.y + pricewall.height / 2 - priceText16.height / 2;
		background2.addChild(priceText16);
		house16.down = function (x, y, obj) {
			// Check if player has enough score to purchase house16
			if (LK.getScore() >= 50000) {
				LK.setScore(LK.getScore() - 50000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house16', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('20:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('20:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1200; // 20:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 28);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	}
}
// Add 4 slots below the forth line of slots that are synced in background2
for (var i = 0; i < 4; i++) {
	var slot = LK.getAsset('Slot', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: i * (slotSpacing + 450) + slotSpacing + 200,
		y: 2700 // Increase y position to add more space
	});
	background2.addChildAt(slot, background2.children.length);
	// Add pricewall below each slot in the fourth line
	var pricewall = LK.getAsset('pricewall', {
		anchorX: 0.5,
		anchorY: 0.0,
		x: slot.x,
		y: slot.y + slot.height / 2 + 0 // Position below the slot
	});
	background2.addChild(pricewall);
	// Add house17 to the first slot in the fifth line
	if (i === 0) {
		var house17 = LK.getAsset('house17', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house17);
		var priceText17 = new Text2('60000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText17.anchor.set(0.5, 0);
		priceText17.x = pricewall.x;
		priceText17.y = pricewall.y + pricewall.height / 2 - priceText17.height / 2;
		background2.addChild(priceText17);
		house17.down = function (x, y, obj) {
			// Check if player has enough score to purchase house17
			if (LK.getScore() >= 60000) {
				LK.setScore(LK.getScore() - 60000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house17', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('25:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('25:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown only if not already started
					this.countdownStarted = true;
					this.countdown = 1500; // 25:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset countdown started flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 1) {
		var house18 = LK.getAsset('house18', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house18);
		var priceText18 = new Text2('75000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText18.anchor.set(0.5, 0);
		priceText18.x = pricewall.x;
		priceText18.y = pricewall.y + pricewall.height / 2 - priceText18.height / 2;
		background2.addChild(priceText18);
		house18.down = function (x, y, obj) {
			// Check if player has enough score to purchase house18
			if (LK.getScore() >= 75000) {
				LK.setScore(LK.getScore() - 75000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house18', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('25:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.down = function (x, y, obj) {
				if (!this.countdownStarted) {
					this.dragging = true;
					this.data = obj;
				}
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				if (!this.countdownStarted) {
					// Only run placement/timer logic if countdown hasn't started
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('25:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1500; // 25:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 2) {
		var house19 = LK.getAsset('house19', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house19);
		// Add pricetext below house19
		var priceText19 = new Text2('90000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText19.anchor.set(0.5, 0);
		priceText19.x = pricewall.x;
		priceText19.y = pricewall.y + pricewall.height / 2 - priceText19.height / 2;
		background2.addChild(priceText19);
		house19.down = function (x, y, obj) {
			// Check if player has enough score to purchase house19
			if (LK.getScore() >= 90000) {
				LK.setScore(LK.getScore() - 90000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house19', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('25:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.countdownStarted = false; // Initialize countdown flag
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('25:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1500; // 25:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	} else if (i === 3) {
		var house20 = LK.getAsset('house20', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: slot.x,
			y: slot.y
		});
		background2.addChild(house20);
		// Add pricetext below house20
		var priceText20 = new Text2('100000AD', {
			size: 70,
			fill: 0xFFFFFF
		});
		priceText20.anchor.set(0.5, 0);
		priceText20.x = pricewall.x;
		priceText20.y = pricewall.y + pricewall.height / 2 - priceText20.height / 2;
		background2.addChild(priceText20);
		house20.down = function (x, y, obj) {
			// Check if player has enough score to purchase house20
			if (LK.getScore() >= 100000) {
				LK.setScore(LK.getScore() - 100000);
				scoreText.setText(LK.getScore());
				var duplicate = LK.getAsset('house20', {
					anchorX: 0.5,
					anchorY: 0.5,
					x: x,
					y: y
				});
				game.addChildAt(duplicate, game.getChildIndex(background1) + 1);
			} else {
				return; // Not enough score, don't create duplicate
			}
			duplicate.dragging = true;
			duplicate.data = obj;
			// Add timer text above the placed house
			if (!duplicate.timerText) {
				duplicate.timerText = new Text2('25:00', {
					size: 50,
					fill: 0xFFFFFF
				});
				duplicate.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
				game.addChildAt(duplicate.timerText, game.getChildIndex(background2));
			}
			duplicate.timerText.x = duplicate.x;
			duplicate.timerText.y = duplicate.y - duplicate.height / 2 - 10; // Position above the house
			duplicate.dragging = true;
			duplicate.data = obj;
			// Hide background2 and its components
			background2.visible = false;
			background1.visible = true;
			scrollbar.visible = false;
			scrollbutton.visible = false;
			background2.children.forEach(function (child) {
				child.visible = false;
			});
			duplicate.countdownStarted = false; // Initialize countdown flag
			duplicate.down = function (x, y, obj) {
				// Do nothing when clicking on the placed house if countdown has started
				if (this.countdownStarted) {
					return;
				}
				this.dragging = true;
				this.data = obj;
			};
			duplicate.move = function (x, y, obj) {
				if (this.dragging) {
					var newPosition = this.parent.toLocal(obj.global);
					this.x = newPosition.x;
					this.y = newPosition.y;
				}
			};
			duplicate.up = function () {
				// Only run placement/timer logic if countdown hasn't started
				if (!this.countdownStarted) {
					this.dragging = false;
					this.data = null;
					// Add timer text above the placed house
					if (!this.timerText) {
						this.timerText = new Text2('25:00', {
							size: 50,
							fill: 0xFFFFFF
						});
						this.timerText.anchor.set(0.5, 1); // Anchor to the bottom center
						game.addChild(this.timerText);
					}
					this.timerText.x = this.x;
					this.timerText.y = this.y - this.height / 2 - 10; // Position above the house
					// Start countdown
					this.countdownStarted = true; // Set flag
					this.countdown = 1500; // 25:00 minutes
					if (this.countdownInterval) {
						LK.clearInterval(this.countdownInterval);
					}
					// Prevent further movement after placing and before countdown finishes
					this.down = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.move = function () {
						// Do nothing - house is now fixed in place until timer finishes
					};
					this.countdownInterval = LK.setInterval(function () {
						this.countdown--;
						var minutes = Math.floor(this.countdown / 60);
						var seconds = this.countdown % 60;
						this.timerText.setText(minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
						if (this.countdown <= 0) {
							LK.clearInterval(this.countdownInterval);
							game.removeChild(this.timerText);
							this.timerText = null; // Reset timerText to null
							this.countdownStarted = false; // Reset flag
							// Spawn 2 coins in front of the house
							var coin1 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x - 50,
								y: this.y - this.height
							});
							var coin2 = LK.getAsset('Coin', {
								anchorX: 0.5,
								anchorY: 0.5,
								x: this.x + 50,
								y: this.y - this.height
							});
							game.addChildAt(coin1, game.getChildIndex(background2));
							game.addChildAt(coin2, game.getChildIndex(background2));
							// Function to animate the coin drop and bounce
							var animateCoin = function animateCoin(coin) {
								var bounceCount = 0;
								var bounceHeight = 20;
								var dropSpeed = 5;
								var bounceSpeed = 2;
								function drop() {
									if (coin.y < this.y + 50) {
										coin.y += dropSpeed;
										LK.setTimeout(drop.bind(this), 16);
									} else {
										bounce();
									}
								}
								function bounce() {
									if (bounceCount < 2) {
										if (coin.y > this.y - bounceHeight) {
											coin.y -= bounceSpeed;
										} else {
											bounceCount++;
											bounceHeight /= 2;
										}
										LK.setTimeout(bounce.bind(this), 16);
									}
								}
								drop.call(this);
							};
							animateCoin.call(this, coin1);
							animateCoin.call(this, coin2);
							coin1.down = function () {
								game.removeChild(coin1);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
							coin2.down = function () {
								game.removeChild(coin2);
								LK.setScore(LK.getScore() + 40);
								scoreText.setText(LK.getScore());
							};
						}
					}.bind(this), 1000);
				}
			};
		};
	}
}
scrollbutton.down = function (x, y, obj) {
	this.dragging = true;
	this.data = obj;
	this.alpha = 0.5;
};
scrollbutton.up = function () {
	this.alpha = 1;
	this.dragging = false;
	this.data = null;
};
scrollbutton.move = function (x, y, obj) {
	if (this.dragging) {
		var newPosition = this.parent.toLocal(obj.global);
		// Limit the y position of the scrollbutton to the height of the scrollbar
		this.y = Math.max(Math.min(newPosition.y, scrollbar.height - this.height / 2), this.height / 2);
		// Calculate the ratio of the scrollbutton's position to the scrollbar's height
		var ratio = (this.y - this.height / 2) / (scrollbar.height - this.height);
		// Move the background2 up or down based on the ratio and the speed
		background2.y = -ratio * (background2.height - game.height);
		// Removed synchronization of scrollbar with background2 movement
	}
};
// Removed up functionality from scrollbutton; ===================================================================
--- original.js
+++ change.js
@@ -32,10 +32,32 @@
 });
 game.addChild(startGameButton);
 // Make sure background0 is at the bottom
 game.setChildIndex(background0, 0);
+// Create continuous zoom animation
+function createButtonPulse() {
+	tween(startGameButton, {
+		scale: 1.1
+	}, {
+		duration: 800,
+		easing: tween.easeInOut,
+		onFinish: function onFinish() {
+			tween(startGameButton, {
+				scale: 1
+			}, {
+				duration: 800,
+				easing: tween.easeInOut,
+				onFinish: createButtonPulse
+			});
+		}
+	});
+}
+// Start the continuous pulse animation immediately
+createButtonPulse();
 // Add click functionality to start button
 startGameButton.down = function () {
+	// Cancel ongoing animations
+	tween.cancel(startGameButton);
 	// Add a quick zoom animation when button is clicked
 	tween(this, {
 		scale: 1.2
 	}, {
:quality(85)/https://cdn.frvr.ai/67c144c0310f4513cc0488ae.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/67c86e45b201e1e482307bf3.png%3F3) 
 2D wreckage of wood, square, HD colors. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/67d9f7ccf23af70acf976d39.png%3F3) 
 House from the front facing the screen with big sign above it have description "SHOP", Hd colors
:quality(85)/https://cdn.frvr.ai/67ea3374a35b1b526c09ee9a.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/67ea3872a6cee3f813bae2c4.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/67eb560b1ec93ed14f2e8261.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/680e64beab85e831f2b10126.png%3F3) 
 coin with colors, have "DA", hd colors. have black circles and black line for the "DA", between the 2 circles do small black lines all around. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6810f1a471168f2d5711d673.png%3F3) 
 Modern App Store icon, square with rounded corners, HD colors for a 2d game titled "The Collector" and with the description "about building houses and trees and decorations on a map to make it look like city, which then generate "DA" coins after a countdown timer expires. Players can collect these coins to increase their score, which they can then use to purchase more houses and trees and decorations from the shop button on the middle left side of the screen". with text on the middle top of the banner "the collector"!
:quality(85)/https://cdn.frvr.ai/68110ad271168f2d5711d742.png%3F3)