Namespace
Methods
- C
- E
- N
- T
- U
Constants
| BACK_GROUND_COLOR | = | "DarkGreen" |
| HILIT_BG_COLOR | = | "green" |
| BORDER_COLOR | = | "black" |
| BLACK_COLOR | = | "black" |
| WHITE_COLOR | = | "white" |
| STOP_COLOR | = | "red" |
Attributes
| [R] | bottom | |
| [R] | left | |
| [R] | right | |
| [R] | top |
Class Public methods
new(othello, board)
Link
# File ext/tk/sample/tcltklib/sample2.rb, line 232 def initialize(othello, board) super($ip, $root, $canvas) @othello = othello @board = board @board.add_observer(self) @squares = Array.new(8) for i in 0 .. 7 @squares[i] = Array.new(8) end @left = 1 @top = 0.5 @right = @left + 8 @bottom = @top + 8 i = self.e("create rectangle", *tk_rect(@left, @top, @right, @bottom)) self.e("itemconfigure", i, "-width 1m -outline #{BORDER_COLOR} -fill #{BACK_GROUND_COLOR}") for row in 0 .. 7 for col in 0 .. 7 @squares[row][col] = Square.new(self, row, col) end end update end
Instance Public methods
clear()
Link
click_square(square)
Link
# File ext/tk/sample/tcltklib/sample2.rb, line 324 def click_square(square) if @othello.in_com_turn || @othello.game_over || @board.count_point(square.row, square.col, @board.man_disk) == 0 square.blink(STOP_COLOR) return end @board.put_disk(square.row, square.col, @board.man_disk) @othello.com_turn end
each_square()
Link
tk_rect(left, top, right, bottom)
Link
update(row = nil, col = nil)
Link
# File ext/tk/sample/tcltklib/sample2.rb, line 304 def update(row = nil, col = nil) if row && col draw_disk(row, col, @board.get_disk(row, col)) else each_square do |square| draw_disk(square.row, square.col, @board.get_disk(square.row, square.col)) end end @othello.show_point end