User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'value')' in this line: 'var correctGuess = nextCard && (guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value);' Line Number: 151
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'value')' in this line: 'var correctGuess = guess === 'higher' && nextCard.value >= currentCard.value || guess === 'lower' && nextCard.value <= currentCard.value;' Line Number: 151
User prompt
Fix Bug: 'ReferenceError: startY is not defined' in this line: 'if (startY === null || endY === null) return;' Line Number: 133
User prompt
On game start show a 3 to 1 ready message that also reads: "Higer or lower?" Swipe up if you think next card is higher or down if it will be lower!
User prompt
Move carda left 50 pixeela left
User prompt
Move score and cards left text 50 pixela down
User prompt
Move carda left 40 pixela left
User prompt
Increase the value size displayes in the card by 40 %
User prompt
Make sure carsa left show the cards left in the deck
User prompt
Move card 200 pixels up
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'setText')' in this line: 'cardsLeftTxt.setText('Cards Left: ' + deck.length);' Line Number: 164
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'setText')' in this line: 'cardsLeftTxt.setText('Cards Left: ' + deck.length);' Line Number: 164
User prompt
Cards left should update after every swipe. Should start in nimber 51
User prompt
Move score 50 pixela right
User prompt
Move cards left 100 pixlea right
User prompt
Move cards left 200 pixels to the rigth
User prompt
Make score the same size as cards left
User prompt
Move cards left 400 pixels to the right
User prompt
Show carss left next to score
User prompt
Move score to the top left
User prompt
Show cards left below score
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'var cardsLeftTxt = new Text2('Cards Left: ' + deck.length, {' Line Number: 161
User prompt
Add a new displaye on the top right that shows cards left counter
User prompt
Move score 50 pixels left
User prompt
Reduce score aize 20%
var MessageDisplay = Container.expand(function () { var self = Container.call(this); var messageText = new Text2('', { size: 300, fill: '#ffffff', stroke: '#000000', strokeThickness: 8, anchor: { x: 0.5, y: 0 } }); self.addChild(messageText); messageText.y = 2732 - messageText.height - 200; self.showMessage = function (message) { messageText.setText(message); messageText.x = 2048 / 2 - messageText.width / 2; self.addChild(messageText); LK.setTimeout(function () { messageText.setText(''); }, 2000); }; }); var Card = Container.expand(function () { var self = Container.call(this); self.setSuit = function (suit) { self.suit = suit; var suitAsset = self.createAsset('suit_' + suit, 'Suit Asset', 0.5, 0.5); suitAsset.x = 0; suitAsset.y = 0; self.addChild(suitAsset); }; var cardGraphics = self.createAsset('card', 'Card Graphics', 0.5, 0.5); cardGraphics.anchor.set(0.5, 0.5); var valueText = new Text2('', { size: 120, fill: '#000000', font: 'bold', anchor: { x: 0, y: 0 } }); valueText.anchor.set(0, 0); valueText.x = -cardGraphics.width / 2 + 50; valueText.y = -cardGraphics.height / 2 + 30; var valueText2 = new Text2('', { size: 120, fill: '#000000', font: 'bold', anchor: { x: 1, y: 1 } }); valueText2.anchor.set(0, 0); valueText2.x = cardGraphics.width / 2 - 50; valueText2.y = cardGraphics.height / 2 - 30; valueText2.scale.y = -1; valueText2.scale.x = -1; self.addChild(valueText2); self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); valueText2.setText(value.toString()); }; self.addChild(valueText); self.addChild(valueText2); var suitText = new Text2('', { size: 120, fill: '#000000', anchor: { x: 0.5, y: 1 } }); suitText.y = 0; self.addChild(suitText); self.setValue = function (value) { self.value = value; var displayValue = value; if (value === 11) displayValue = 'J'; else if (value === 12) displayValue = 'Q'; else if (value === 13) displayValue = 'K'; else if (value === 1) displayValue = 'A'; valueText.setText(displayValue.toString()); valueText2.setText(displayValue.toString()); }; self.value = 0; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5); self.score = 0; self.updateScore = function (score) { self.score = score; }; }); var player = new Player(); var Game = Container.expand(function () { var self = Container.call(this); stage.on('up', function (obj) { var endY = obj.event.getLocalPosition(self).y; if (startY === null || endY === null) return; var swipeDirection = startY - endY; var guess = swipeDirection > 0 ? 'higher' : 'lower'; if (deck.length === 0) { LK.showGameOver(); return; } nextCard = deck.pop(); if (!nextCard) return; self.addChild(nextCard); nextCard.x = 2048 / 2; nextCard.y = 2732 / 2; if (self.messageDisplay) { self.messageDisplay.destroy(); } self.messageDisplay = self.addChild(new MessageDisplay()); var correctGuess = guess === 'higher' && nextCard.value >= currentCard.value || guess === 'lower' && nextCard.value <= currentCard.value; if (correctGuess) { player.updateScore(player.score + 1); self.updateScoreDisplay(player.score); LK.setScore(player.score); self.messageDisplay.showMessage('Correct!'); } else { self.messageDisplay.showMessage('Wrong!'); } animateCardMovement(currentCard, swipeDirection); currentCard = nextCard; nextCard = null; startY = null; }); function animateCardMovement(card, direction) { var moveAmount = direction > 0 ? -2732 : 2732; var moveStep = direction > 0 ? -150 : 150; LK.on('tick', function () { if (Math.abs(moveAmount) > 0) { card.y += moveStep; moveAmount -= moveStep; } else { card.destroy(); LK.off('tick'); } }); } var background = self.createAsset('background', 'Background Asset', 0.5, 0.5); background.x = 2048 / 2; background.y = 2732 / 2; self.addChild(background); var scoreTxt = new Text2('0', { size: 100, fill: "#ffffff", stroke: '#000000', strokeThickness: 4, anchor: { x: .5, y: .5 } }); scoreTxt.y = 50; scoreTxt.x = 20; LK.gui.topLeft.addChild(scoreTxt); var deck = []; var cardsLeftTxt = new Text2('Cards Left: ' + deck.length, { size: 100, fill: "#ffffff", stroke: '#000000', strokeThickness: 4, anchor: { x: 0, y: 0.5 } }); cardsLeftTxt.x = 20 + scoreTxt.width + 20 + 700; cardsLeftTxt.y = 50; LK.gui.topLeft.addChild(cardsLeftTxt); self.updateCardsLeftDisplay = function () { cardsLeftTxt.setText('Cards Left: ' + deck.length); }; self.updateCardsLeftDisplay(); self.updateScoreDisplay = function (score) { scoreTxt.setText('Score: ' + score.toString()); }; self.updateScoreDisplay(0); var deck = []; var currentCard = null; var nextCard = null; var suits = ['hearts', 'diamonds', 'clubs', 'spades']; for (var s = 0; s < suits.length; s++) { for (var i = 1; i <= 13; i++) { var card = new Card(); card.setValue(i); card.setSuit(suits[s]); deck.push(card); } } deck.sort(function () { return 0.5 - Math.random(); }); currentCard = deck[Math.floor(Math.random() * deck.length)]; var index = deck.indexOf(currentCard); deck.splice(index, 1); self.addChild(currentCard); currentCard.x = 2048 / 2; currentCard.y = 2732 / 2; var startY = null; stage.on('down', function (obj) { startY = obj.event.getLocalPosition(self).y; }); });
===================================================================
--- original.js
+++ change.js
@@ -168,9 +168,9 @@
x: 0,
y: 0.5
}
});
- cardsLeftTxt.x = 20 + scoreTxt.width + 20 + 600;
+ cardsLeftTxt.x = 20 + scoreTxt.width + 20 + 700;
cardsLeftTxt.y = 50;
LK.gui.topLeft.addChild(cardsLeftTxt);
self.updateCardsLeftDisplay = function () {
cardsLeftTxt.setText('Cards Left: ' + deck.length);
Green casino baize. To be used as background. No shade. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white rectangle flat. rounded corners. no background. no shadow. card shape.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.