Class: GamesParadise::TicTacToe::Square
- Inherits:
-
Object
- Object
- GamesParadise::TicTacToe::Square
- Defined in:
- lib/games_paradise/gui/gosu/tic_tac_toe/square.rb
Instance Attribute Summary collapse
-
#board_coordinates ⇒ Object
readonly
Returns the value of attribute board_coordinates.
-
#letter ⇒ Object
readonly
Returns the value of attribute letter.
-
#window_coordinates ⇒ Object
readonly
Returns the value of attribute window_coordinates.
Instance Method Summary collapse
-
#center_point ⇒ Object
# === center_point ========================================================================= #.
-
#draw ⇒ Object
# === draw ========================================================================= #.
-
#initialize(board_coordinates, window_coordinates, size) ⇒ Square
constructor
# === initialize ========================================================================= #.
-
#mark_letter(i) ⇒ Object
# === mark_letter ========================================================================= #.
-
#occupied? ⇒ Boolean
# === occupied? ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#set_size(i) ⇒ Object
# === set_size ========================================================================= #.
-
#set_window_coordinates(i) ⇒ Object
# === set_window_coordinates ========================================================================= #.
-
#size? ⇒ Boolean
(also: #size)
# === size? ========================================================================= #.
Constructor Details
#initialize(board_coordinates, window_coordinates, size) ⇒ Square
#
initialize
#
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 20 def initialize( board_coordinates, window_coordinates, size ) @board_coordinates = board_coordinates set_window_coordinates( window_coordinates ) set_size(size) reset end |
Instance Attribute Details
#board_coordinates ⇒ Object (readonly)
Returns the value of attribute board_coordinates.
14 15 16 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 14 def board_coordinates @board_coordinates end |
#letter ⇒ Object (readonly)
Returns the value of attribute letter.
13 14 15 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 13 def letter @letter end |
#window_coordinates ⇒ Object (readonly)
Returns the value of attribute window_coordinates.
15 16 17 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 15 def window_coordinates @window_coordinates end |
Instance Method Details
#center_point ⇒ Object
#
center_point
#
67 68 69 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 67 def center_point @center_point ||= window_coordinates.map {|c| c + size/2} end |
#draw ⇒ Object
#
draw
#
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 81 def draw if letter @font.draw_text_rel( letter, center_point[0], center_point[1], 0, 0.5, 0.5, 1, 1, Gosu::Color::RED ) end end |
#mark_letter(i) ⇒ Object
#
mark_letter
#
60 61 62 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 60 def mark_letter(i) @letter = i end |
#occupied? ⇒ Boolean
#
occupied?
#
74 75 76 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 74 def occupied? !letter.nil? end |
#reset ⇒ Object
#
reset
#
36 37 38 39 40 41 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 36 def reset # ======================================================================= # # === @font # ======================================================================= # @font = Gosu::Font.new(100) end |
#set_size(i) ⇒ Object
#
set_size
#
53 54 55 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 53 def set_size(i) @size = i end |
#set_window_coordinates(i) ⇒ Object
#
set_window_coordinates
#
46 47 48 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 46 def set_window_coordinates(i) @window_coordinates = i end |
#size? ⇒ Boolean Also known as: size
#
size?
#
100 101 102 |
# File 'lib/games_paradise/gui/gosu/tic_tac_toe/square.rb', line 100 def size? @size end |