User prompt
Ensure start button is not visible if neither leftButton nor rightButton is not active
User prompt
Ensure start button is not visible if neither leftButton nor rightButton is not selected
User prompt
if neither the leftbutton nor the rightbutton is selected, do not show the start button on the track
User prompt
if neither the left button nor the right button is selected, do not show the start button on the track
User prompt
check that only one circular stone can be selected at a time, if the player selects more than one, then place the previous one back among the others in its original place
User prompt
check that if none of the curling stones is selected, the start button is not visible. If the start button is visible and the player pushes the selected stone back among the others, do not show the start button until then
User prompt
Please fix the bug: 'leftButton is not defined' in or related to this line: 'var playervsplayerAsset = LK.getAsset('playervsplayer', {' Line Number: 297
User prompt
Please fix the bug: 'leftButton is not defined' in or related to this line: 'var playervsplayerAsset = LK.getAsset('playervsplayer', {' Line Number: 297
User prompt
Refresh migration to the latest LK Engine
User prompt
not working
User prompt
If there is no curling stone below the red line, a startbutton should not be visible!!
User prompt
Ensure startbutton is not visible if no stone is below the red line
User prompt
If there is no curling stone below the red line, the startbutton should not be visible
User prompt
not working
User prompt
You can only see the startbutton if both Game Mod and Curling Stone are selected. In case player vs ai mode has been selected but there is not exactly 1 stone below the red line, the startbutton should not be visible
User prompt
You can only see the startbutton if both Game Mod and Curling Stone are selected. If player vs ai mode is selected and not 1 stone alone is selected, the startbutton should not appear
User prompt
If you don't see a select asset or selectgreen asset, you can't see a startbutton
User prompt
The startbutton should not be visible until the player has selected both the game mod and curling stone
User prompt
If no curling stone is selected, the startbutton should not be visible
User prompt
Please fix the bug: 'ReferenceError: checkStartButtonVisibility is not defined' in or related to this line: 'checkStartButtonVisibility();' Line Number: 336
User prompt
delete start button from the game
User prompt
do it
User prompt
Once the player has selected the game mod and clicked on one of the curling stones, you can display the start button aligned in the middle of the red ring
User prompt
If select asset is displayed, you cannot see selectgreen asset at the same time!
User prompt
When the game loads, do not show selectgreen asset yet!
/**** * 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: "#000000" }); 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: "#000000" }); 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 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 ****/ // Add start button to the game var startButton = LK.getAsset('startButton', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 * 0.25 // Align with the center of the red ring }); startButton.interactive = true; startButton.visible = false; // Initially hidden startButton.on('down', function () { console.log("Start button pressed"); // Add logic to start the game }); game.addChild(startButton); // Ensure it's the last child // Function to show start button when conditions are met function checkStartButtonVisibility() { if (gameMode && selectedStone) { startButton.visible = true; } else { 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); // Initialize game mode variable var gameMode = null; // 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; 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; 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 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 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 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 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 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 () { stone.y = stone.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stone; checkStartButtonVisibility(); }); var stoneRed = game.addChild(new RedStone()); stoneRed.x = startX + stoneSpacing; stoneRed.y = 2732 * 0.75 + 500 - 350; stoneRed.interactive = true; stoneRed.on('down', function () { stoneRed.y = stoneRed.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneRed; 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 () { stoneYellow.y = stoneYellow.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneYellow; 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 () { stoneGreen.y = stoneGreen.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneGreen; 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 () { stoneOrange.y = stoneOrange.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneOrange; 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 () { stonePink.y = stonePink.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stonePink; 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 () { stonePurple.y = stonePurple.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stonePurple; 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 () { stoneNeon.y = stoneNeon.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500; selectedStone = stoneNeon; checkStartButtonVisibility(); }); // Initialize the game state var throwing = false; var throwStart = null; // Handle touch events game.down = function (x, y, obj) { 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 };
/****
* 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: "#000000"
});
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: "#000000"
});
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 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
****/
// Add start button to the game
var startButton = LK.getAsset('startButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 * 0.25 // Align with the center of the red ring
});
startButton.interactive = true;
startButton.visible = false; // Initially hidden
startButton.on('down', function () {
console.log("Start button pressed");
// Add logic to start the game
});
game.addChild(startButton); // Ensure it's the last child
// Function to show start button when conditions are met
function checkStartButtonVisibility() {
if (gameMode && selectedStone) {
startButton.visible = true;
} else {
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);
// Initialize game mode variable
var gameMode = null;
// 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;
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;
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 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 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 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 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 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 () {
stone.y = stone.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stone;
checkStartButtonVisibility();
});
var stoneRed = game.addChild(new RedStone());
stoneRed.x = startX + stoneSpacing;
stoneRed.y = 2732 * 0.75 + 500 - 350;
stoneRed.interactive = true;
stoneRed.on('down', function () {
stoneRed.y = stoneRed.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stoneRed;
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 () {
stoneYellow.y = stoneYellow.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stoneYellow;
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 () {
stoneGreen.y = stoneGreen.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stoneGreen;
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 () {
stoneOrange.y = stoneOrange.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stoneOrange;
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 () {
stonePink.y = stonePink.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stonePink;
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 () {
stonePurple.y = stonePurple.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stonePurple;
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 () {
stoneNeon.y = stoneNeon.y === 2732 * 0.75 + 500 ? 2732 * 0.75 + 500 - 350 : 2732 * 0.75 + 500;
selectedStone = stoneNeon;
checkStartButtonVisibility();
});
// Initialize the game state
var throwing = false;
var throwStart = null;
// Handle touch events
game.down = function (x, y, obj) {
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
};
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.