Class: GamesAndRpgParadise::GUI::Gtk::Blocks

Inherits:
Array
  • Object
show all
Defined in:
lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb

Constant Summary collapse

N_TIMES =
#

N_TIMES

#
10

Instance Method Summary collapse

Constructor Details

#initializeBlocks

#

initialize

#


29
30
31
32
33
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 29

def initialize
  define_the_main_colours
  reset
  add_all_blocks
end

Instance Method Details

#add_all_blocks(use_these_colours = @colours) ⇒ Object

#

add_all_blocks

#


49
50
51
52
53
54
55
56
57
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 49

def add_all_blocks(
    use_these_colours = @colours
  )
  use_these_colours.length.times { |y|
    N_TIMES.times { |x|
      self << Block.new(21 + 60 * x , 21 + 20 * y, use_these_colours[y])
    }
  }
end

#define_the_main_coloursObject

#

define_the_main_colours

#


62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 62

def define_the_main_colours
  # ======================================================================= #
  # Define 5 different colours for the blocks:
  # ======================================================================= #
  @colours = [
    hexvalue_of?(:deepskyblue),
    hexvalue_of?(:royalblue),
    hexvalue_of?(:yellow),
    hexvalue_of?(:white),
    hexvalue_of?(:lightgreen)
  ]
end

#drawObject

#

draw

#


89
90
91
92
93
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 89

def draw
  each { |block|
    block.draw
  }
end

#hexvalue_of?(i = :slateblue) ⇒ Boolean

#

hexvalue_of?

#

Returns:

  • (Boolean)


78
79
80
81
82
83
84
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 78

def hexvalue_of?(i = :slateblue)
  if Object.const_defined? :Colours
    "##{::Colours.return_hexvalue_of_this_colour(i)}"
  else
    i
  end
end

#resetObject

#

reset

#


38
39
40
41
42
43
44
# File 'lib/games_and_rpg_paradise/gui/gtk3/block/blocks.rb', line 38

def reset
  # reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, inspect]
end