Hello Team,
I am planning to write a Sudoku program just for the learning
experience.
I’m first trying to draw the board using green shoes (which I am also
learning) as my GUI toolkit.
As most people know, the most common Sudoku board is a 9x9 array. The
9x9
array is subdivided on 3x3 square. I don’t want to go into details as I
know that Sudoku is already a very well know game.
To make the game easier to follow it is customary to have some kind of
division between each 3x3 square. It could be a heavy line or some
space.
My problem is that I can’t find a way to do this with green shoes. I
am
convinced that it is doable as this appears to be something simple, but
I
can’t find the way. I already experimented with many version of my code.
Here are the last two versions.
The first version correctly draws the board but with no apparent
division
between the 3x3 squares.
The second version stacks all the buttons one after the other. I thought
that the if else end stmt that I added could do the trick. But it did
not.
Any help will be appreciated as usual.
*FIRST VERSION
require “green_shoes”
require ‘rubygems’
Shoes.app :height => 666, :width => 811, :resizable => false do
background magenta
title (strong(“Sudoku”)), :size => 26, :align=>‘center’
para " "
para " "
@btn = Array.new(9) {Array.new(9) {123456789}}
(0…8).each do |r|
stack :margin => 3 do
flow :width => 866 do
(0…8).each do |c|
@btn[r][c] = button “123456789”, :width => 86, :height =>
50
end # End do c
end # flow
end # End stack
end # End do r
end # app
*
*SECOND VERSION
require “green_shoes”
require ‘rubygems’
Shoes.app :height => 666, :width => 811, :resizable => false do
background magenta
title (strong(“Sudoku”)), :size => 26, :align=>‘center’
para " "
para " "
@btn = Array.new(9) {Array.new(9) {123456789}}
(0…8).each do |r|
stack :margin => 3 do
(0…8).each do |c|
if c == 3 or c == 6
flow :width => 866, :margin => 3 do
@btn[r][c] = button “123456789”, :width => 86, :height
=>
50
end
else
flow :width => 866 do
@btn[r][c] = button “123456789”, :width => 86, :height
=>
50
end
end # if
end # End do c
end # End stack
end # End do r
end # app
Thank you