User prompt
WHEN CLICKED ON THE STARTBUTTON, THE MACHINE ALSO SELECTS A STONE OF SOME COLOR, BUT IT CANNOT SELECT THE SAME COLOR STONE AS THE PLAYER SELECTED. THE MATCH STARTS AND RANDOMLY EITHER THE PLAYER OR THE MACHINE STARTS PUSHING THE STONES.
User prompt
BUT IF YOU WANT TO START THE MATCH WITH THE MACHINE AT ALL COSTS, THEN START WITH IT AND UNTIL THEN PUT THE PLAYER'S STONE IN THE CENTER, BUT THE MACHINE'S STONE!
User prompt
ENSURE Position machine stone at the lower middle part if the machine starts DO NOT SHOW THE PLAYER'S STONE ON THE COURT UNTIL THE MACHINE STARTS THE MATCH
User prompt
If the machine starts the game, the machine stone should be placed in the lower middle part, where it should start
User prompt
the computer starts too often. Change the starting ratio to half-half so that the player can start the same number of times
User prompt
When restarting the game, the player must be switched so that the computer and the player can start alternately
User prompt
WHEN CLICKED ON THE STARTBUTTON, THE MACHINE ALSO SELECTS A STONE OF SOME COLOR, BUT IT CANNOT SELECT THE SAME COLOR STONE AS THE PLAYER SELECTED. THE MATCH STARTS AND RANDOMLY EITHER THE PLAYER OR THE MACHINE STARTS PUSHING THE STONES. You must write the starting order at the top of the center of the track.
User prompt
Add stoneLightBlue asset to th game
User prompt
STILL NOT DISAPPEAR THE STARTBUTTON
User prompt
START BUTTON CANNOT STAY ON TRACK IF SELECTED!!! MUST DISAPPEAR in any case, IF IT HAS BEEN CLICKED!!!
User prompt
move the bluestone under the redline if the player clicked on the bluestone
User prompt
add select even to the bluestone
User prompt
As long as the start button is not selected, stoneBlue cannot move freely, it can only be selected like other stones
User prompt
ensure startbutton is only visible if a stone is below the redline
User prompt
i said under the redline center, so move the stones between the redline and the center bottom of the map
User prompt
If the player selected playervsai mode the player playing against a computer controlled opponent. When the player clicked on the startbutton asset you should move the selected stone on to the center line bottom, under the redline center.
User prompt
remove duplicated rightbutton asset from the map
User prompt
Then hide it from the map
User prompt
Then do this
User prompt
do it
User prompt
Please fix the bug: 'TypeError: startButton is null' in or related to this line: 'startButton.visible = false;' Line Number: 605
User prompt
Please fix the bug: 'ReferenceError: startButton is not defined' in or related to this line: 'startButton.visible = false;' Line Number: 603
User prompt
YOU SHOULD REMOVE THE TEXTS FROM THE MAP IF PLAYER CLICKED ON STARTBUTTON
User prompt
Please fix the bug: 'ReferenceError: startButton is not defined' in or related to this line: 'game.removeChild(startButton);' Line Number: 603
User prompt
DO IT
/**** * Classes ****/ // The assets will be automatically created and loaded by the LK engine // Create a class for the curling stone var CurlingStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneBlue', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); // Create a class for the game mode selection pop-up var GameModePopup = Container.expand(function () { var self = Container.call(this); // Create background for the pop-up var background = self.attachAsset('whiteCenter', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 4, scaleY: 4 }); // Create text for the pop-up var text = new Text2('Choose Game Mode', { size: 150, fill: 0x000000 }); text.anchor.set(0.5, 0.5); text.x = 2048 / 2; text.y = 2732 / 2; self.addChild(text); // Create text for choosing curling stone var chooseStoneText = new Text2('Choose Curling Stone', { size: 120, fill: 0x000000 }); chooseStoneText.anchor.set(0.5, 0.5); chooseStoneText.x = 2048 / 2; chooseStoneText.y = 2732 / 2 + 600; self.addChild(chooseStoneText); }); var GreenStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneGreen', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var LightBlueStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneLightBlue', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var NeonStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneNeon', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var OrangeStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneOrange', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var PinkStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stonePink', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var PurpleStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stonePurple', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var RedStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneRed', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); var YellowStone = Container.expand(function () { var self = Container.call(this); var stoneGraphics = self.attachAsset('stoneYellow', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 0; self.direction = 0; self.update = function () { self.x += Math.cos(self.direction) * self.speed; self.y += Math.sin(self.direction) * self.speed; self.speed *= 0.99; // friction if (self.speed < 0.1) { self.speed = 0; } }; self["throw"] = function (speed, direction) { self.speed = speed; self.direction = direction; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF // Init game with white background }); /**** * Game Code ****/ function isExactlyOneStoneBelowRedLine() { var stoneLightBlue = game.addChild(new LightBlueStone()); stoneLightBlue.x = startX + stoneSpacing * 8; stoneLightBlue.y = 2732 * 0.75 + 500 - 350; stoneLightBlue.interactive = true; stoneLightBlue.on('down', function () { if (selectedStone && selectedStone !== stoneLightBlue) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneLightBlue.y = stoneLightBlue.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneLightBlue; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon, stoneLightBlue]; var count = 0; stones.forEach(function (stone) { if (stone.y > 2732 * 0.75 + 300) { // Check if stone is below the red line count++; } }); return count === 1; } // Initialize startButton variable var startButton = null; // Function to check the visibility of the start button function checkStartButtonVisibility() { if (gameMode !== null && selectedStone !== null && selectedStone.y > 2732 * 0.75 + 300 && (selectAsset.visible || selectGreenAsset.visible)) { // Logic to display the start button startButton = LK.getAsset('startButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); startButton.visible = true; startButton.interactive = true; startButton.on('down', startButtonClickHandler); game.addChild(startButton); } else { if (startButton) { startButton.visible = false; } } } // Initialize game mode variable var gameMode = null; var selectedStone = null; // Track selected stone // Display the game mode selection pop-up var gameModePopup = new GameModePopup(); game.addChild(gameModePopup); // Add first game mode asset to the map var gameModeAsset1 = LK.getAsset('gameModeAsset', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 }); game.addChild(gameModeAsset1); // Add second game mode asset to the map var gameModeAsset2 = LK.getAsset('gameModeAsset', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 + 600 // Adjusted position for the second asset }); game.addChild(gameModeAsset2); // Add left button to the center of the map var leftButton = LK.getAsset('leftButton', { anchorX: 1.0, // Align right edge anchorY: 0.0, x: 2048 / 2, y: gameModeAsset1.y + gameModeAsset1.height / 2 }); game.addChild(leftButton); // Add playervsplayer asset to the map var playervsplayerAsset = LK.getAsset('playervsplayer', { anchorX: 0.5, anchorY: 0.5, x: leftButton.x - leftButton.width / 2, y: leftButton.y + leftButton.height / 2 }); game.addChild(playervsplayerAsset); // Add select asset to indicate selection var selectAsset = LK.getAsset('select', { anchorX: 0.5, anchorY: 0.5, x: leftButton.x - leftButton.width / 2, y: leftButton.y + leftButton.height / 2 }); selectAsset.visible = false; // Initially hidden game.addChild(selectAsset); // Add right button to the center of the map var rightButton = LK.getAsset('rightButton', { anchorX: 0.0, // Align left edge anchorY: 0.0, x: 2048 / 2, y: gameModeAsset1.y + gameModeAsset1.height / 2 }); game.addChild(rightButton); // Add selectgreen asset to the map var selectGreenAsset = LK.getAsset('selectgreen', { anchorX: 0.5, anchorY: 0.5, x: rightButton.x + rightButton.width / 2, y: rightButton.y + rightButton.height / 2 }); selectGreenAsset.visible = false; // Initially hidden game.addChild(selectGreenAsset); // Function to handle player vs ai mode selection function selectPlayerVsAIMode() { gameMode = 'playerVsAI'; selectGreenAsset.visible = !selectGreenAsset.visible; if (selectGreenAsset.visible) { selectAsset.visible = false; } selectGreenAsset.x = rightButton.x + rightButton.width / 2; selectGreenAsset.y = rightButton.y + rightButton.height / 2; checkStartButtonVisibility(); } // Function to handle player vs player mode selection function selectPlayerVsPlayerMode() { gameMode = 'playerVsPlayer'; selectAsset.visible = !selectAsset.visible; if (selectAsset.visible) { selectGreenAsset.visible = false; } selectAsset.x = leftButton.x - leftButton.width / 2; selectAsset.y = leftButton.y + leftButton.height / 2; checkStartButtonVisibility(); } // Add interaction to playervsplayerAsset playervsplayerAsset.interactive = true; playervsplayerAsset.on('down', selectPlayerVsPlayerMode); // Add playervsai asset to the map var playervsaiAsset = LK.getAsset('playervsai', { anchorX: 0.5, anchorY: 0.5, x: rightButton.x + rightButton.width / 2, y: rightButton.y + rightButton.height / 2 }); playervsaiAsset.interactive = true; playervsaiAsset.on('down', selectPlayerVsAIMode); game.addChild(playervsaiAsset); // Add center line to the game var centerLine = LK.getAsset('centerLine', { anchorX: 0.5, anchorY: 0.0, x: 2048 / 2, y: 0 }); // Add left lane to the game var leftLane = LK.getAsset('leftLane', { anchorX: 0.5, anchorY: 0.0, x: 50, y: 0 }); game.addChild(leftLane); // Add right lane to the game var rightLane = LK.getAsset('rightLane', { anchorX: 0.5, anchorY: 0.0, x: 2048 - 50, y: 0 }); game.addChild(rightLane); // Add red horizontal line to the lower quarter of the map var redLine = LK.getAsset('redLine', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.75 + 300 }); // Add grey horizontal target line to the upper quadrant of the map var targetLine = LK.getAsset('targetLine', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); var whiteRing = LK.getAsset('whiteRing', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); var redRing = LK.getAsset('redRing', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); var blueRing = LK.getAsset('blueRing', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); game.addChild(blueRing); game.addChild(whiteRing); game.addChild(redRing); var whiteCenter = LK.getAsset('whiteCenter', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 }); game.addChild(whiteCenter); game.addChild(centerLine); game.addChild(redLine); game.addChild(targetLine); var stoneSpacing = 200; var totalStones = 8; var startX = 2048 / 2 - stoneSpacing * (totalStones - 1) / 2; var stone = game.addChild(new CurlingStone()); stone.x = startX; stone.y = 2732 * 0.75 + 500 - 350; stone.interactive = true; stone.on('down', function () { if (selectedStone && selectedStone !== stone) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } if (startButton && startButton.visible === false) { stone.y = stone.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; } else { stone.y = 2732 * 0.75 + 400; // Move stoneBlue under the redline } selectedStone = stone; checkStartButtonVisibility(); checkStartButtonVisibility(); }); stone.on('select', function () { // Logic for when stoneBlue is selected console.log("stoneBlue selected"); }); var stoneRed = game.addChild(new RedStone()); stoneRed.x = startX + stoneSpacing; stoneRed.y = 2732 * 0.75 + 500 - 350; stoneRed.interactive = true; stoneRed.on('down', function () { if (selectedStone && selectedStone !== stoneRed) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneRed.y = stoneRed.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneRed; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stoneYellow = game.addChild(new YellowStone()); stoneYellow.x = startX + stoneSpacing * 2; stoneYellow.y = 2732 * 0.75 + 500 - 350; stoneYellow.interactive = true; stoneYellow.on('down', function () { if (selectedStone && selectedStone !== stoneYellow) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneYellow.y = stoneYellow.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneYellow; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stoneGreen = game.addChild(new GreenStone()); stoneGreen.x = startX + stoneSpacing * 3; stoneGreen.y = 2732 * 0.75 + 500 - 350; stoneGreen.interactive = true; stoneGreen.on('down', function () { if (selectedStone && selectedStone !== stoneGreen) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneGreen.y = stoneGreen.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneGreen; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stoneOrange = game.addChild(new OrangeStone()); stoneOrange.x = startX + stoneSpacing * 4; stoneOrange.y = 2732 * 0.75 + 500 - 350; stoneOrange.interactive = true; stoneOrange.on('down', function () { if (selectedStone && selectedStone !== stoneOrange) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneOrange.y = stoneOrange.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneOrange; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stonePink = game.addChild(new PinkStone()); stonePink.x = startX + stoneSpacing * 5; stonePink.y = 2732 * 0.75 + 500 - 350; stonePink.interactive = true; stonePink.on('down', function () { if (selectedStone && selectedStone !== stonePink) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stonePink.y = stonePink.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stonePink; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stonePurple = game.addChild(new PurpleStone()); stonePurple.x = startX + stoneSpacing * 6; stonePurple.y = 2732 * 0.75 + 500 - 350; stonePurple.interactive = true; stonePurple.on('down', function () { if (selectedStone && selectedStone !== stonePurple) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stonePurple.y = stonePurple.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stonePurple; checkStartButtonVisibility(); checkStartButtonVisibility(); }); var stoneNeon = game.addChild(new NeonStone()); stoneNeon.x = startX + stoneSpacing * 7; stoneNeon.y = 2732 * 0.75 + 500 - 350; stoneNeon.interactive = true; stoneNeon.on('down', function () { if (selectedStone && selectedStone !== stoneNeon) { selectedStone.y = 2732 * 0.75 + 500 - 350; // Reset previous stone position } stoneNeon.y = stoneNeon.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneNeon; checkStartButtonVisibility(); checkStartButtonVisibility(); }); // Initialize the game state var throwing = false; var throwStart = null; // Handle touch events game.down = function (x, y, obj) { if (startButton && startButton.visible === false) { throwing = true; } throwStart = { x: x, y: y }; }; game.up = function (x, y, obj) { if (throwing) { var dx = x - throwStart.x; var dy = y - throwStart.y; var speed = Math.sqrt(dx * dx + dy * dy) / 100; var direction = Math.atan2(dy, dx); stone["throw"](speed, direction); throwing = false; } }; // Update the game state game.update = function () { // Removed game over condition when stone intersects target }; function startButtonClickHandler() { // Move the selected stone to the center line bottom under the red line center if (selectedStone) { selectedStone.x = 2048 / 2; // Center horizontally selectedStone.y = 2732 * 0.75 + 400; // Position between the red line and the center bottom } // Select a stone for the machine that is not the same color as the player's selected stone var machineStone = null; var availableStones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon, stoneLightBlue]; availableStones = availableStones.filter(function (stone) { return stone !== selectedStone; }); machineStone = availableStones[Math.floor(Math.random() * availableStones.length)]; machineStone.visible = true; machineStone.x = 2048 / 2; // Center horizontally machineStone.y = 2732 * 0.75 + 500; // Position above the player's stone // Hide non-selected stones var stones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon]; stones.forEach(function (stone) { if (stone !== selectedStone && stone !== machineStone) { stone.visible = false; } }); // Randomly decide whether the player or the machine starts pushing the stones var playerStarts = Math.random() < 0.5; if (playerStarts) { console.log("Player starts pushing the stones."); } else { console.log("Machine starts pushing the stones."); // Logic for machine to push the stone var speed = Math.random() * 5 + 1; // Random speed between 1 and 6 var direction = Math.random() * Math.PI * 2; // Random direction machineStone["throw"](speed, direction); } // Hide other specified assets gameModeAsset1.visible = false; gameModeAsset2.visible = false; leftButton.visible = false; playervsaiAsset.visible = false; playervsplayerAsset.visible = false; rightButton.visible = false; selectAsset.visible = false; selectGreenAsset.visible = false; if (startButton) { startButton.destroy(); // Destroy the startButton to ensure it disappears completely startButton = null; // Set startButton to null to remove reference } // Remove texts from the map gameModePopup.visible = false; }
===================================================================
--- original.js
+++ change.js
@@ -565,9 +565,8 @@
checkStartButtonVisibility();
});
// Initialize the game state
var throwing = false;
-var playerStarts = true; // Track which player starts the game
var throwStart = null;
// Handle touch events
game.down = function (x, y, obj) {
if (startButton && startButton.visible === false) {
@@ -597,29 +596,36 @@
if (selectedStone) {
selectedStone.x = 2048 / 2; // Center horizontally
selectedStone.y = 2732 * 0.75 + 400; // Position between the red line and the center bottom
}
- // Randomly select a stone for the machine that is not the same as the player's selected stone
- var stones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon];
- var availableStones = stones.filter(function (stone) {
+ // Select a stone for the machine that is not the same color as the player's selected stone
+ var machineStone = null;
+ var availableStones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon, stoneLightBlue];
+ availableStones = availableStones.filter(function (stone) {
return stone !== selectedStone;
});
- var machineStone = availableStones[Math.floor(Math.random() * availableStones.length)];
+ machineStone = availableStones[Math.floor(Math.random() * availableStones.length)];
machineStone.visible = true;
- if (!playerStarts) {
- machineStone.x = 2048 / 2; // Center horizontally
- machineStone.y = 2732 * 0.75 + 400; // Position between the red line and the center bottom
- selectedStone.visible = false; // Hide player's stone until the machine starts
- } else {
- selectedStone.x = 2048 / 2; // Center player's stone horizontally
- selectedStone.y = 2732 * 0.75 + 400; // Position player's stone between the red line and the center bottom
- }
+ machineStone.x = 2048 / 2; // Center horizontally
+ machineStone.y = 2732 * 0.75 + 500; // Position above the player's stone
// Hide non-selected stones
+ var stones = [stone, stoneRed, stoneYellow, stoneGreen, stoneOrange, stonePink, stonePurple, stoneNeon];
stones.forEach(function (stone) {
if (stone !== selectedStone && stone !== machineStone) {
stone.visible = false;
}
});
+ // Randomly decide whether the player or the machine starts pushing the stones
+ var playerStarts = Math.random() < 0.5;
+ if (playerStarts) {
+ console.log("Player starts pushing the stones.");
+ } else {
+ console.log("Machine starts pushing the stones.");
+ // Logic for machine to push the stone
+ var speed = Math.random() * 5 + 1; // Random speed between 1 and 6
+ var direction = Math.random() * Math.PI * 2; // Random direction
+ machineStone["throw"](speed, direction);
+ }
// Hide other specified assets
gameModeAsset1.visible = false;
gameModeAsset2.visible = false;
leftButton.visible = false;
@@ -627,18 +633,8 @@
playervsplayerAsset.visible = false;
rightButton.visible = false;
selectAsset.visible = false;
selectGreenAsset.visible = false;
- // Determine who starts first
- playerStarts = !playerStarts; // Switch the starting player to ensure equal turns
- var startingOrderText = new Text2(playerStarts ? 'Player Starts' : 'Machine Starts', {
- size: 100,
- fill: 0x000000
- });
- startingOrderText.anchor.set(0.5, 0.5);
- startingOrderText.x = 2048 / 2;
- startingOrderText.y = 100; // Position at the top center of the track
- game.addChild(startingOrderText);
if (startButton) {
startButton.destroy(); // Destroy the startButton to ensure it disappears completely
startButton = null; // Set startButton to null to remove reference
}
black curling stone with pink top, top view.
Black curlingstone with purple top, top view.
Black curlingstone with yellow top, top view.
Black curlingstone with orange top, top view.
black curlingstone with neongreen top, top view.
Black curlingstone with neonblue top, top view.
add a text to the center: "Player vs Player"
neongreen rectangle with rounded corners, transparent in the middle.
Red button with white start text.