Description.
Now, let's create a function that gets the deck of cards setup for our game.
Don't forget to call the function in on start
!
// @hide
function setupSprites () {
}
function setupDeck () {
}
setupSprites()
// @highlight
setupDeck()
Add a deck of cards to the game.
function setupDeck () {
let theDeck: Shoe = PlayingCards.createPokerDeck()
}
The deck is in new-deck order. Let's give it a shuffle!
function setupDeck () {
let theDeck: Shoe = PlayingCards.createPokerDeck()
// @highlight
theDeck.shuffle()
}
Congratulations! You've added a deck of cards to the game!
But it doesn't do much right now.
In the next part, we will hook up the deck of cards to the sprites!
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
reveal()
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
reveal()
})
function reveal () {
playerSprite.setFlag(SpriteFlag.Invisible, false)
}
function setupSprites () {
leftSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
leftSprite.setPosition(40, 30)
playerSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
playerSprite.setPosition(80, 60)
rightSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
rightSprite.setPosition(120, 90)
playerSprite.setFlag(SpriteFlag.Invisible, true)
}
let rightSprite: Sprite = null
let leftSprite: Sprite = null
let playerSprite: Sprite = null
setupSprites()
function setupDeck () {
theDeck = PlayingCards.createPokerDeck()
theDeck.shuffle()
}
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
reveal()
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
reveal()
})
function reveal () {
playerSprite.setFlag(SpriteFlag.Invisible, false)
}
function setupSprites () {
leftSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
leftSprite.setPosition(40, 30)
playerSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
playerSprite.setPosition(80, 60)
rightSprite = sprites.create(playing_card_skillmap_assets.cardBack32x32, SpriteKind.Player)
rightSprite.setPosition(120, 90)
playerSprite.setFlag(SpriteFlag.Invisible, true)
}
let rightSprite: Sprite = null
let leftSprite: Sprite = null
let playerSprite: Sprite = null
let theDeck: Shoe = null
setupSprites()
setupDeck()
playing_card_skillmap_assets=github:robo-technical-group/playing_card_skillmap_assets.git
PlayingCards=github:robo-technical-group/pxt-arcade-playing-cards.git
textsprite=github:microsoft/arcade-text.git