Class: Checkers::Ruby2D::SquareWithPiece

Inherits:
Square
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/checkers/ruby2d/square_with_piece.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SquareWithPiece

Returns a new instance of SquareWithPiece.



11
12
13
14
15
16
17
18
19
20
# File 'lib/checkers/ruby2d/square_with_piece.rb', line 11

def initialize(opts = {})
  @piece = Piece.new(
    x: opts[:x] + Checkers::GUI::CIRCLE_TRANSLATION,
    y: opts[:y] + Checkers::GUI::CIRCLE_TRANSLATION,
    z: 1,
    radius: Checkers::GUI::RADIUS,
    piece: opts[:piece]
  )
  super(opts.slice(:x, :y, :size, :color))
end

Instance Attribute Details

#pieceObject (readonly)

Returns the value of attribute piece.



9
10
11
# File 'lib/checkers/ruby2d/square_with_piece.rb', line 9

def piece
  @piece
end

Instance Method Details

#removeObject



22
23
24
25
# File 'lib/checkers/ruby2d/square_with_piece.rb', line 22

def remove
  @piece.remove
  super
end