Code edit (2 edits merged)
Please save this source code
User prompt
move score and left 300 pixels left
User prompt
show cardslefttxt next to score
User prompt
move left message 500 pixels left
User prompt
add a message on the top right that reads ''Left:'' and next to it the count of cards remaining in the deck. should startwith 51
User prompt
double next card speed entering
User prompt
next card should come into screen and move on top of current card. if swipe was up, next card should spawn from the bottom and stop on top of current card. if swip wasa down, it should come from thetop and move and stop on top of current card.
User prompt
Fix Bug: 'Timeout.tick error: Cannot set properties of null (setting 'y')' in this line: 'nextCard.y = currentCard.y;' Line Number: 120
User prompt
Fix Bug: 'Timeout.tick error: Cannot set properties of null (setting 'x')' in this line: 'nextCard.x = currentCard.x;' Line Number: 117
User prompt
when next card spawns it should move to the position of the current card after 2 seconds. this will not happen on the first card displayed on game start
User prompt
move cards 250 pixels left
User prompt
move both cards 300 pixels left
User prompt
next card should show on the right of the current card. in the first hand it should show empty.
Code edit (1 edits merged)
Please save this source code
User prompt
move current card to the right 400 pixels
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'currentCard.anchor.set(0.5, 0.5);' Line Number: 177
User prompt
venter both card on the center of the screen
User prompt
show current card on the right and next card on the left of it
User prompt
on game start console log the firstcard
User prompt
console log value and suit of curent and next ccard
User prompt
on swipe up or down the next card should come either from the top or bottom respective and land next to the current card.
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of null (setting 'x')' in this line: 'nextCard.x = currentCard.x + currentCard.width + 20;' Line Number: 173
User prompt
add a card spot to show next card on the right o the currencard
User prompt
after the first hand happens, only show previous card on the left before next swipe
User prompt
create a new class for previous card
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); var background = self.createAsset('background', 'Background Asset', 0.5, 0.5); background.x = 2048 / 2; background.y = 2732 / 2; self.addChild(background); 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; console.log('Next Card:', 'Value:', nextCard.value, 'Suit:', nextCard.suit); self.addChild(nextCard); nextCard.x = currentCard.x + currentCard.width + 20; nextCard.y = currentCard.y; 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!'); } console.log('Current Card:', 'Value:', currentCard.value, 'Suit:', currentCard.suit); currentCard.destroy(); currentCard = nextCard; nextCard = null; startY = null; }); var scoreTxt = new Text2('0', { size: 112, fill: "#ffffff", stroke: '#000000', strokeThickness: 8, anchor: { x: .5, y: .5 } }); scoreTxt.y = 50; scoreTxt.x = -340; LK.gui.topCenter.addChild(scoreTxt); 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)]; console.log('First Card:', 'Value:', currentCard.value, 'Suit:', currentCard.suit); var index = deck.indexOf(currentCard); deck.splice(index, 1); self.addChild(currentCard); currentCard.x = 2048 / 2; currentCard.y = 2732 / 2; nextCard = new Card(); nextCard.x = currentCard.x + currentCard.width + 20; nextCard.y = currentCard.y; self.addChild(nextCard); var startY = null; stage.on('down', function (obj) { startY = obj.event.getLocalPosition(self).y; }); });
===================================================================
--- original.js
+++ change.js
@@ -112,10 +112,10 @@
nextCard = deck.pop();
if (!nextCard) return;
console.log('Next Card:', 'Value:', nextCard.value, 'Suit:', nextCard.suit);
self.addChild(nextCard);
- nextCard.x = 2048 / 2;
- nextCard.y = 2732 / 2;
+ nextCard.x = currentCard.x + currentCard.width + 20;
+ nextCard.y = currentCard.y;
if (self.messageDisplay) {
self.messageDisplay.destroy();
}
self.messageDisplay = self.addChild(new MessageDisplay());
@@ -170,10 +170,14 @@
console.log('First Card:', 'Value:', currentCard.value, 'Suit:', currentCard.suit);
var index = deck.indexOf(currentCard);
deck.splice(index, 1);
self.addChild(currentCard);
- currentCard.x = 2048 / 2 - 400;
+ currentCard.x = 2048 / 2;
currentCard.y = 2732 / 2;
+ nextCard = new Card();
+ nextCard.x = currentCard.x + currentCard.width + 20;
+ nextCard.y = currentCard.y;
+ self.addChild(nextCard);
var startY = null;
stage.on('down', function (obj) {
startY = obj.event.getLocalPosition(self).y;
});
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.