Fifteen pieces of a games night: Dice, DiceTray, PlayingCard, CardHand, Deck, Chessboard, GoBoard, MahjongTile, Domino, Roulette, CoinFlip, BingoCard, TicTacToe, ScoreTrack and Meeple. Component number 500 is a meeple, which seems right. Dice tumble, coins turn and wheels spin on a cue, a frame at a time, and land at once under Reduce Motion. Hands lift the card you point at and play the one drawn on top; pieces and stones pick the lighter of Lit and Ink for White, so they read in every palette; the computer plays a fair O; FREE is a star in every language. New 12x12 icons: Spade, Club, Diamond, Meeple, King, Queen, Rook, Bishop, Knight and Pawn.
40 lines
933 B
Go
40 lines
933 B
Go
package tabletop
|
||
|
||
import (
|
||
"fmt"
|
||
|
||
"github.com/egoist/mygo/ui"
|
||
|
||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||
)
|
||
|
||
type DominoOptions struct {
|
||
// Vertical stands the tile on end.
|
||
Vertical bool
|
||
}
|
||
|
||
// Domino is a tile of two halves of 0–6 pips.
|
||
func Domino(c *ui.Context, a, b int, o DominoOptions) *ui.Element {
|
||
k := pixel.K(c)
|
||
if a < 0 || a > 6 || b < 0 || b > 6 {
|
||
panic(fmt.Sprintf("tabletop: Domino %d|%d", a, b))
|
||
}
|
||
w, h := 39, 20
|
||
if o.Vertical {
|
||
w, h = h, w
|
||
}
|
||
return ui.Box(c).Size(k.D(w), k.D(h)).Role(ui.RoleImage).Label(fmt.Sprintf("%d | %d", a, b)).Draw(func(p *ui.Painter, r ui.Rect) {
|
||
g := k.Canvas(p, r)
|
||
g.Frame(0, 0, w, h, pixel.Raised, pixel.Lit)
|
||
if o.Vertical {
|
||
g.HLine(3, 19, 14, pixel.Edge)
|
||
pips(g, 1, 1, 18, a, pixel.Ink)
|
||
pips(g, 1, 20, 18, b, pixel.Ink)
|
||
return
|
||
}
|
||
g.VLine(19, 3, 14, pixel.Edge)
|
||
pips(g, 1, 1, 18, a, pixel.Ink)
|
||
pips(g, 20, 1, 18, b, pixel.Ink)
|
||
})
|
||
}
|