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 = 800864, hcan = 600700, hlog = 100)
win = GtkWindow("Uno Card Game", w, hcan + hlog) |> (GtkFrame() |> (vbox = GtkBox(:v)))
swin = GtkScrolledWindow()
set_gtk_property!(vbox, :expand, true)
can = GtkCanvas(w, hcan)
pushset_gtk_property!(vboxcan, can:expand, true)
push!(swin, can)
push!(vbox, swin)
push!(vbox, logwindow) # from log section
set_gtk_property!(logwindow, :expand, true)
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 + 3085 * (row - 1)
for (i, card) in enumerate(cards)
idx, x0 = (row - 1) * 16 + i, startx + 50 * (i - 1)
4,102

edits