Class: Budgie::ChangeMap
- Inherits:
-
Object
- Object
- Budgie::ChangeMap
- Defined in:
- lib/budgie/change_map.rb
Instance Method Summary collapse
-
#initialize(scene) ⇒ ChangeMap
constructor
A new instance of ChangeMap.
-
#place ⇒ Object
Places a new block next to the selected one.
-
#remove ⇒ Object
Remove selected block from the map.
-
#replace ⇒ Object
Replaces selected block’s color.
Constructor Details
#initialize(scene) ⇒ ChangeMap
Returns a new instance of ChangeMap.
3 4 5 6 7 8 9 |
# File 'lib/budgie/change_map.rb', line 3 def initialize(scene) @map = scene.map @palette = scene.palette @draw_map = scene.draw_map @selection = scene.selection @draw_picker_map = scene.draw_picker_map end |
Instance Method Details
#place ⇒ Object
Places a new block next to the selected one
12 13 14 15 16 17 18 19 |
# File 'lib/budgie/change_map.rb', line 12 def place s = @selection return unless s.selected @map[s.new_x, s.new_y, s.new_z] = @palette.index(s.r, s.g, s.b) @draw_map.update_partial s.new_x, s.new_y, s.new_z @draw_picker_map.update_partial s.new_x, s.new_y, s.new_z end |
#remove ⇒ Object
Remove selected block from the map
32 33 34 35 36 37 38 39 |
# File 'lib/budgie/change_map.rb', line 32 def remove s = @selection return unless s.selected @map[s.x, s.y, s.z] = nil @draw_map.update_partial s.x, s.y, s.z @draw_picker_map.update_partial s.x, s.y, s.z end |
#replace ⇒ Object
Replaces selected block’s color
22 23 24 25 26 27 28 29 |
# File 'lib/budgie/change_map.rb', line 22 def replace s = @selection return unless s.selected @map[s.x, s.y, s.z] = @palette.index(s.r, s.g, s.b) @draw_map.update_partial s.x, s.y, s.z @draw_picker_map.update_partial s.x, s.y, s.z end |