Class: Budgie::DrawPickerMap

Inherits:
Object
  • Object
show all
Includes:
Index, GL
Defined in:
lib/budgie/draw_picker_map.rb

Direct Known Subclasses

DrawMap

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Index

#from_index, #to_index

Constructor Details

#initialize(map) ⇒ DrawPickerMap

Returns a new instance of DrawPickerMap.



13
14
15
16
17
18
19
# File 'lib/budgie/draw_picker_map.rb', line 13

def initialize(map)
  @map = map
  @partial_size = 16
  @partials = Map.new 1 + @map.max / @partial_size

  compile
end

Instance Attribute Details

#mapObject (readonly)

Returns the value of attribute map.



11
12
13
# File 'lib/budgie/draw_picker_map.rb', line 11

def map
  @map
end

#partial_sizeObject (readonly)

Returns the value of attribute partial_size.



11
12
13
# File 'lib/budgie/draw_picker_map.rb', line 11

def partial_size
  @partial_size
end

Instance Method Details

#compileObject



34
35
36
37
38
# File 'lib/budgie/draw_picker_map.rb', line 34

def compile
  @partials.each do |x, y, z|
    compile_partial x, y, z
  end
end

#cube_color(x, y, z, index) ⇒ Object



46
47
48
49
50
51
# File 'lib/budgie/draw_picker_map.rb', line 46

def cube_color(x, y, z, index)
  x = 1 + to_index(x)
  y = 1 + to_index(y)
  z = 1 + to_index(z)
  glColor3ub x, y, z
end

#drawObject



40
41
42
43
44
# File 'lib/budgie/draw_picker_map.rb', line 40

def draw
  @partials.each do |x, y, z|
    draw_partial x, y, z
  end
end

#update_partial(x, y, z) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/budgie/draw_picker_map.rb', line 21

def update_partial(x, y, z)
  x /= @partial_size
  y /= @partial_size
  z /= @partial_size
  compile_partial x, y, z
  # compile_partial x - 1, y, z
  # compile_partial x + 1, y, z
  # compile_partial x, y - 1, z
  # compile_partial x, y + 1, z
  # compile_partial x, y, z - 1
  # compile_partial x, y, z + 1
end