Skip to content

Commit

Permalink
Updated plugins; added Fancy Text.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kulcsar committed Jun 22, 2024
1 parent eba0cec commit 8384b71
Show file tree
Hide file tree
Showing 9 changed files with 259 additions and 4 deletions.
Binary file modified .github/makecode/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/makecode/blocksdiff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions images.g.jres
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"K;^TvaJi59[St1XP4=p)": {
"data": "hwQgACAAAAAzMzMzMzMzMzMzMzMzMzMzMxMRERERERERERERERExMzMxMzMzMzMzMzMzMzMzEzMTMzMzMzMzMzMzMzMzMzMxEzMzMzMzERERETEzMzMzMRMzMzMzETMzMzMTMTMzMzETMzMzEzMzMzMzMxMzMzMxEzMzMzEzMzMzMzMzMTMzMRMzMxMzMxMREREzMxMzMzETMzMxMxMxMzMzETMzMTMxEzMzMTMxMzMzMzMxMzEzMRMzEzMzMTMzMzMzMTMTMzETMxMzEzMzERExMxMzEzMxEzMTMxMzEyIiEjMTMxMzMRMzEzMTMxMiIhIzEzMTMzETMxMzEzMTIiISMxMzEzMxEzMTMxMzEyIiEjMTMxMzMRMzEzMTMxMiIhIzEzMTMzETMxMzEzMzERExMxMzEzMxEzMTMzMxMzMzMzMxMxMzMRMzMzEzMTMzMzMzMTMxMzETMzMxMxMxMzMzETMzMTMxEzMzEzMzExERETMzEzMzMRMzMzMxMzMzMzMzMzEzMzETMzMzEzMzMzMzMxMzMzMxEzMzMzMRMzMzMxMxMzMzMRMzMzMzMxERERExMzMzMzETMzMzMzMzMzMzMzMzMzMxMzEzMzMzMzMzMzMzMzMTMzMTERERERERERERERERMTMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMw==",
"mimeType": "image/x-mkcd-f4",
"displayName": "cardback"
},
"*": {
"mimeType": "image/x-mkcd-f4",
"dataEncoding": "base64",
"namespace": "myImages"
}
}
60 changes: 60 additions & 0 deletions images.g.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Auto-generated code. Do not edit.
namespace myImages {

helpers._registerFactory("image", function(name: string) {
switch(helpers.stringTrim(name)) {
case "K;^TvaJi59[St1XP4=p)":
case "cardback":return img`
33333333333333333333333333333333
33311111111111111111111111113333
33133333333333333333333333331333
31333333333333333333333333333133
31333333333333333333333333333133
31333333333111111111333333333133
31333333311333333333113333333133
31333333133333333333331333333133
31333331333333333333333133333133
31333313333311111113333313333133
31333133331133333331133331333133
31333133313333333333313331333133
31331333313333333333313333133133
31331333133331111133331333133133
31331333133312222213331333133133
31331333133312222213331333133133
31331333133312222213331333133133
31331333133312222213331333133133
31331333133312222213331333133133
31331333133331111133331333133133
31331333313333333333313333133133
31333133313333333333313331333133
31333133331133333331133331333133
31333313333311111113333313333133
31333331333333333333333133333133
31333333133333333333331333333133
31333333311333333333113333333133
31333333333111111111333333333133
31333333333333333333333333333133
33133333333333333333333333331333
33311111111111111111111111113333
33333333333333333333333333333333
`;
}
return null;
})

helpers._registerFactory("animation", function(name: string) {
switch(helpers.stringTrim(name)) {

}
return null;
})

helpers._registerFactory("song", function(name: string) {
switch(helpers.stringTrim(name)) {

}
return null;
})

}
// Auto-generated code. Do not edit.
53 changes: 52 additions & 1 deletion main.blocks

Large diffs are not rendered by default.

102 changes: 101 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
@@ -1 +1,101 @@

function setPromptInvisible (isInvisible: boolean) {
for (let value of promptSprites) {
value.setFlag(SpriteFlag.Invisible, isInvisible)
}
playerCardSprite.setFlag(SpriteFlag.Invisible, !(isInvisible))
}
function initTable () {
info.setScore(0)
scene.setBackgroundColor(6)
headerSprite = fancyText.create("Acey Deucey")
fancyText.setFont(headerSprite, fancyText.art_deco_11)
fancyText.setColor(headerSprite, 9)
headerSprite.setPosition(80, 10)
prompts = [
"Will the next card",
"fall in between?",
"Aces are high.",
"A = Yes B = No"
]
y = 35
promptSprites = []
for (let value of prompts) {
promptSprite = fancyText.create(value)
fancyText.setColor(promptSprite, 15)
fancyText.setFont(promptSprite, fancyText.bold_sans_7)
promptSprite.x = 80
promptSprite.y = y
promptSprites.push(promptSprite)
y += 10
}
}
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
if (waitingForPlayer) {
playerChoseBetween = false
reveal()
}
})
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
if (waitingForPlayer) {
playerChoseBetween = true
reveal()
}
})
function reveal () {
setPromptInvisible(true)
isBetween = rightCard.isLessThan(playerCard) && playerCard.isLessThan(leftCard) || leftCard.isLessThan(playerCard) && playerCard.isLessThan(rightCard)
if (playerChoseBetween == isBetween) {
info.changeScoreBy(1)
music.play(music.melodyPlayable(music.baDing), music.PlaybackMode.InBackground)
pause(1000)
startRound()
} else {
pause(1000)
game.gameOver(false)
}
}
function drawCards () {
if (theDeck.numCardsRemain < 3) {
theDeck.shuffle()
}
leftCard = theDeck.nextCard
leftCardSprite.setImage(theDeck.getCardImage(leftCard, CardSpriteSize.Size32x32))
rightCard = theDeck.nextCard
rightCardSprite.setImage(theDeck.getCardImage(rightCard, CardSpriteSize.Size32x32))
playerCard = theDeck.nextCard
playerCardSprite.setImage(theDeck.getCardImage(playerCard, CardSpriteSize.Size32x32))
}
function initCards () {
theDeck = PlayingCards.createPokerDeck()
theDeck.isAceHigh = true
theDeck.shuffle()
leftCardSprite = sprites.create(assets.image`cardback`, SpriteKind.Enemy)
leftCardSprite.setPosition(40, 100)
rightCardSprite = sprites.create(assets.image`cardback`, SpriteKind.Enemy)
rightCardSprite.setPosition(120, 100)
playerCardSprite = sprites.create(assets.image`cardback`, SpriteKind.Enemy)
playerCardSprite.setPosition(80, 60)
}
function startRound () {
setPromptInvisible(false)
drawCards()
waitingForPlayer = true
}
let rightCardSprite: Sprite = null
let leftCardSprite: Sprite = null
let theDeck: Shoe = null
let leftCard: Card = null
let playerCard: Card = null
let rightCard: Card = null
let isBetween = false
let playerChoseBetween = false
let waitingForPlayer = false
let promptSprite: fancyText.TextSprite = null
let y = 0
let prompts: string[] = []
let headerSprite: fancyText.TextSprite = null
let playerCardSprite: Sprite = null
let promptSprites: fancyText.TextSprite[] = []
initCards()
initTable()
startRound()
10 changes: 8 additions & 2 deletions pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
"name": "acey-deucey",
"version": "2.0.0",
"dependencies": {
"device": "*"
"device": "*",
"pxt-arcade-playing-cards": "github:robo-technical-group/pxt-arcade-playing-cards#v2.1.3",
"arcade-fancy-text": "github:riknoll/arcade-fancy-text#v0.1.1"
},
"files": [
"main.blocks",
"main.ts",
"README.md"
"README.md",
"images.g.jres",
"images.g.ts",
"tilemap.g.jres",
"tilemap.g.ts"
],
"testDependencies": {},
"targetVersions": {
Expand Down
12 changes: 12 additions & 0 deletions tilemap.g.jres
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"transparency16": {
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"mimeType": "image/x-mkcd-f4",
"tilemapTile": true
},
"*": {
"mimeType": "image/x-mkcd-f4",
"dataEncoding": "base64",
"namespace": "myTiles"
}
}
14 changes: 14 additions & 0 deletions tilemap.g.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Auto-generated code. Do not edit.
namespace myTiles {
//% fixedInstance jres blockIdentity=images._tile
export const transparency16 = image.ofBuffer(hex``);

helpers._registerFactory("tile", function(name: string) {
switch(helpers.stringTrim(name)) {
case "transparency16":return transparency16;
}
return null;
})

}
// Auto-generated code. Do not edit.

1 comment on commit 8384b71

@alex-kulcsar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.