E
Ed Redman
I am writing a card game in ruby/tk.
I have a Tk_button(shuffle) that shuffles the cards and places them on a
canvas.The shuffle works fine but I would like to have a slight delay
between between each card being displayed on the canvas. Below is the
shuffle buttons command. I would like to delay the loop each time so
their is a slight delay. I have tried putting Tk.after(time)
{ part around the loop} but it just delays the shuffle and is not
visible. Not each card being displayed. I need a little direction
on implementing such a loop
thanks
shuffle.command do
52.times do
|i|
nr = rand(56)
nm = rand(56)
io = newhash[nr]
im = newhash[nm]
# Tk.after(100) {
place[nr].image io
newhash[nm] = io
place[nr].image im
newhash[nr] = im
# }
end
end
I have a Tk_button(shuffle) that shuffles the cards and places them on a
canvas.The shuffle works fine but I would like to have a slight delay
between between each card being displayed on the canvas. Below is the
shuffle buttons command. I would like to delay the loop each time so
their is a slight delay. I have tried putting Tk.after(time)
{ part around the loop} but it just delays the shuffle and is not
visible. Not each card being displayed. I need a little direction
on implementing such a loop
thanks
shuffle.command do
52.times do
|i|
nr = rand(56)
nm = rand(56)
io = newhash[nr]
im = newhash[nm]
# Tk.after(100) {
place[nr].image io
newhash[nm] = io
place[nr].image im
newhash[nr] = im
# }
end
end