Code edit (1 edits merged)
Please save this source code
User prompt
Move value 400 pixela.up
User prompt
Fix value anchor toe be displayed in the upper lwft corner of the card
User prompt
Move value to the upper left corner of the vard
User prompt
Fix message display anchor to be displayed in the bottom centwr
User prompt
Correcr or wrong should be in the bottom centwr
User prompt
Nextcard should also be in the center
User prompt
Card should be in the center of the screen. Fiz its anchor
User prompt
Set card anchor to .5 .5
User prompt
Card should be in the center of the screen
User prompt
Move card 300 pixels down
User prompt
Center suit asset in the center of the card
User prompt
Use assets to represent suits
User prompt
We are guessing the value of the mext card compared to the current one
User prompt
Instead of showing rhe text of the suit, we will show an asset that represents each auit
User prompt
Value and suit color should be black
User prompt
Value should be displayed in the top left and bottom right of rhe card
User prompt
Suit should be in the center of the card
User prompt
Invert higher or lowe logic
User prompt
Player is guessing if the next card is higher or lower than the current card
User prompt
If player guesses correctly add meesage in the bottom of the screen that says Correct! And Wrong! If the do not guess
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'value')' in this line: 'if (guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value) {' Line Number: 107
User prompt
Fix Bug: 'TypeError: Cannot set properties of null (setting 'x')' in this line: 'nextCard.x = 2048 / 2;' Line Number: 103
User prompt
Every time the player guesses correctly add 1 point to the score
User prompt
Game will not be over if player does not guess correctly
var Card = Container.expand(function () { var self = Container.call(this); var cardGraphics = self.createAsset('card', 'Card Graphics', .5, .5); var valueText = new Text2('', { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0 } }); valueText.y = -cardGraphics.height / 2 + valueText.height / 2; self.addChild(valueText); var suitText = new Text2('', { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 1 } }); suitText.y = cardGraphics.height / 2 - suitText.height / 2; self.addChild(suitText); self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); }; self.setSuit = function (suit) { self.suit = suit; suitText.setText(suit); }; self.value = 0; self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); }; self.setSuit = function (suit) { self.suit = suit; suitText.setText(suit); }; }); 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 Game = Container.expand(function () { var self = Container.call(this); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", anchor: { x: .5, y: 0 } }); scoreTxt.y = 50; LK.gui.topCenter.addChild(scoreTxt); self.updateScoreDisplay = function (score) { scoreTxt.setText(score.toString()); }; self.updateScoreDisplay(0); var deck = []; var player = self.addChild(new Player()); 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 - 200; player.x = 2048 / 2; player.y = 2732 / 2 + 200; var startY = null; stage.on('down', function (obj) { startY = obj.event.getLocalPosition(self).y; }); stage.on('up', function (obj) { var endY = obj.event.getLocalPosition(self).y; var guess = startY - endY > 0 ? 'lower' : 'higher'; if (deck.length === 0) { LK.showGameOver(); } else { nextCard = deck.pop(); } self.addChild(nextCard); nextCard.x = 2048 / 2; nextCard.y = 2732 / 2 - 200; if (guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value) { player.updateScore(player.score + 1); LK.setScore(player.score); } currentCard.destroy(); currentCard = nextCard; nextCard = null; startY = null; }); });
var Card = Container.expand(function () {
var self = Container.call(this);
var cardGraphics = self.createAsset('card', 'Card Graphics', .5, .5);
var valueText = new Text2('', {
size: 100,
fill: '#ffffff',
anchor: {
x: 0.5,
y: 0
}
});
valueText.y = -cardGraphics.height / 2 + valueText.height / 2;
self.addChild(valueText);
var suitText = new Text2('', {
size: 100,
fill: '#ffffff',
anchor: {
x: 0.5,
y: 1
}
});
suitText.y = cardGraphics.height / 2 - suitText.height / 2;
self.addChild(suitText);
self.setValue = function (value) {
self.value = value;
valueText.setText(value.toString());
};
self.setSuit = function (suit) {
self.suit = suit;
suitText.setText(suit);
};
self.value = 0;
self.setValue = function (value) {
self.value = value;
valueText.setText(value.toString());
};
self.setSuit = function (suit) {
self.suit = suit;
suitText.setText(suit);
};
});
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 Game = Container.expand(function () {
var self = Container.call(this);
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
anchor: {
x: .5,
y: 0
}
});
scoreTxt.y = 50;
LK.gui.topCenter.addChild(scoreTxt);
self.updateScoreDisplay = function (score) {
scoreTxt.setText(score.toString());
};
self.updateScoreDisplay(0);
var deck = [];
var player = self.addChild(new Player());
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 - 200;
player.x = 2048 / 2;
player.y = 2732 / 2 + 200;
var startY = null;
stage.on('down', function (obj) {
startY = obj.event.getLocalPosition(self).y;
});
stage.on('up', function (obj) {
var endY = obj.event.getLocalPosition(self).y;
var guess = startY - endY > 0 ? 'lower' : 'higher';
if (deck.length === 0) {
LK.showGameOver();
} else {
nextCard = deck.pop();
}
self.addChild(nextCard);
nextCard.x = 2048 / 2;
nextCard.y = 2732 / 2 - 200;
if (guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value) {
player.updateScore(player.score + 1);
LK.setScore(player.score);
}
currentCard.destroy();
currentCard = nextCard;
nextCard = null;
startY = null;
});
});
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.