Code edit (1 edits merged)
Please save this source code
User prompt
cards that spawn from swipe should keep the same speed around all the game
Code edit (4 edits merged)
Please save this source code
User prompt
spawning of cards speed should not increase its speed
User prompt
when current card is destroyed, delete it logically, but keep the asset in place.
Code edit (8 edits merged)
Please save this source code
User prompt
when bot current card and nextccard are bot in the screen and not moving. then add a hold event for .5 seconds and then continue
User prompt
cards speed should not increase
User prompt
current card should move move left and leave the screen before being destroyed.
User prompt
before destroying current card is shoud move to the left of the screen until it disappears
User prompt
Fix Bug: 'Timeout.tick error: game.resume is not a function' in this line: '}' Line Number: 183
User prompt
Fix Bug: 'TypeError: game.pause is not a function' in this line: '});' Line Number: 185
User prompt
when the next card stops moving, pause the game for half a second, while current and next cards are both in the screen
User prompt
when new card spawns, pause for half a second before moving again.
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'y')' in this line: 'LK.on('tick', function moveCardLeft() {' Line Number: 152
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'y')' in this line: 'LK.on('tick', function moveCardLeft() {' Line Number: 152
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'y')' in this line: 'LK.on('tick', function moveCardLeft() {' Line Number: 152
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'y')' in this line: '} else if (swipeDirection < 0 && nextCard.y < 2732 / 2) {' Line Number: 145
User prompt
after current card takes the value of the next card, move current card 1000 pixels to the left
User prompt
any type of card should move 1000 pixels left after it stops moving.
User prompt
if the card was moving and stops, then move it 1000 pixels to the left
User prompt
after the new card spawns and stops moving, move the card 1000 pixels to the left
User prompt
after stop moving, next card should move 1000 pixels to the left
User prompt
nextcard shoudl spawn 500 pixels to the right from the current psoiton
/**** * Classes ****/ 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; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var player = new Player(); var background = game.createAsset('background', 'Background Asset', 0.5, 0.5); background.x = 2048 / 2; background.y = 2732 / 2; game.addChild(background); game.on('up', function (obj) { var endY = obj.event.getLocalPosition(game).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); game.addChild(nextCard); nextCard.x = 2048 / 2 + 500; nextCard.y = swipeDirection > 0 ? 2732 + nextCard.height : -nextCard.height; LK.on('tick', function () { if (swipeDirection > 0 && nextCard.y > 2732 / 2) { nextCard.y -= 40; } else if (swipeDirection < 0 && nextCard.y < 2732 / 2) { nextCard.y += 40; } if (Math.abs(nextCard.y - 2732 / 2) <= 20) { nextCard.y = 2732 / 2; LK.on('tick', function moveCardLeft() { if (nextCard.x > 2048 / 2 - 1000) { nextCard.x -= 40; } else { LK.off('tick', moveCardLeft); } }); } }); if (game.messageDisplay) { game.messageDisplay.destroy(); } game.messageDisplay = game.addChild(new MessageDisplay()); var correctGuess = guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value; if (correctGuess) { player.updateScore(player.score + 1); game.updateScoreDisplay(player.score); LK.setScore(player.score); game.messageDisplay.showMessage('Correct!'); } else { game.messageDisplay.showMessage('Wrong!'); } console.log('Current Card:', 'Value:', currentCard.value, 'Suit:', currentCard.suit); LK.on('tick', function () { if (Math.abs(nextCard.y - 2732 / 2) <= 20) { currentCard.destroy(); currentCard = nextCard; nextCard = null; startY = null; LK.off('tick'); } }); }); 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); game.updateScoreDisplay = function (score) { scoreTxt.setText('Score: ' + score.toString()); }; game.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); game.addChild(currentCard); currentCard.x = 2048 / 2 - 500; currentCard.y = 2732 / 2; var startY = null; game.on('down', function (obj) { startY = obj.event.getLocalPosition(game).y; });
===================================================================
--- original.js
+++ change.js
@@ -146,9 +146,15 @@
nextCard.y += 40;
}
if (Math.abs(nextCard.y - 2732 / 2) <= 20) {
nextCard.y = 2732 / 2;
- LK.off('tick');
+ LK.on('tick', function moveCardLeft() {
+ if (nextCard.x > 2048 / 2 - 1000) {
+ nextCard.x -= 40;
+ } else {
+ LK.off('tick', moveCardLeft);
+ }
+ });
}
});
if (game.messageDisplay) {
game.messageDisplay.destroy();
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.