Uno (Card Game)/Julia: Difference between revisions
m
→Gtk based graphical version.: change display of large hands
(Created page with "=== Gtk based graphical version. === <lang julia>using Random, Colors, Gtk, Cairo #=========== Channel section ===================# """ channel, communicates player's mouse...") |
m (→Gtk based graphical version.: change display of large hands) |
||
Line 328:
Uno card game Gtk app. Draws game on a canvas, logs play on box below canvas.
"""
function UnoCardGameApp(w =
win = GtkWindow("Uno Card Game", w, hcan + hlog) |> (GtkFrame() |> (vbox = GtkBox(:v)))
swin = GtkScrolledWindow()
can = GtkCanvas(w, hcan)
push!(swin, can)
push!(vbox, swin)
push!(vbox, logwindow) # from log section
fontpointsize = w / 50
cardpositions = Dict{Int, Vector{Int}}()
Line 376 ⟶ 377:
isempty(hand) && return
nrow = (length(hand) + 15) ÷ 16
for row in 1:nrow
cards = hand[(row - 1) * 16 + 1 : min(length(hand), row * 16 - 1)]
startx, starty = 40 + (16 - length(cards)) * 20, 500 +
for (i, card) in enumerate(cards)
idx, x0 = (row - 1) * 16 + i, startx + 50 * (i - 1)
|