Class: Moon::Tilemap

Inherits:
RenderContext show all
Defined in:
lib/moon/packages/render_primitives/tilemap.rb

Overview

This may need to be rewritten in C/++

Instance Attribute Summary collapse

Attributes inherited from RenderContext

#id

Attributes included from RenderPrimitive::DataAttributes

#data_attrs

Attributes included from RenderPrimitive::Rectangular

#h, #position, #w

Attributes included from RenderPrimitive::Containable

#parent

Instance Method Summary collapse

Methods inherited from RenderContext

#apply_position_modifier, #initialize, #post_initialize, #pre_initialize, #render?, #render_abs, #render_content, #screen_bounds, #screen_position, #update

Methods included from RenderPrimitive::DataAttributes

#initialize_data_attrs

Methods included from RenderPrimitive::Rectangular

#align!, #bounds, #contains?, #cx, #cx=, #cy, #cy=, #move, #on_resize, #resize, #to_rect, #x, #x2, #x2=, #x=, #y, #y2, #y2=, #y=, #z, #z=

Methods included from RenderPrimitive::Containable

#containerize, #disown

Methods included from RenderPrimitive::Visibility

#hide, #invisible?, #show, #visible?

Methods included from RenderPrimitive::Renderable

#render, #render?

Methods included from RenderPrimitive::ScreenElement

#contains_pos?, #relative_contains_pos?, #relative_to_screen, #screen_to_relative

Methods included from Eventable

#allow_event?, #clear_events, #each_listener, #each_typed_listener, filter_from_options, #has_events?, #initialize_eventable, #off, #on, #ppd_ev, #trigger, #typing

Methods included from Transitionable

#key_transition, #remove_transitions, #transition

Methods included from TransitionHost

#add_transition, #finish_transitions, #remove_transition, #remove_transitions, #update_transitions

Constructor Details

This class inherits a constructor from Moon::RenderContext

Instance Attribute Details

#dataMoon::DataMatrix

Returns:


9
10
11
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 9

def data
  @data
end

#data_zmapMoon::DataMatrix

Returns:


11
12
13
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 11

def data_zmap
  @data_zmap
end

#datasizeVector2 (readonly)

Returns:


25
26
27
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 25

def datasize
  @datasize
end

#layer_opacityArray<Float>

Returns:


13
14
15
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 13

def layer_opacity
  @layer_opacity
end

#repeat_mapBoolean

Returns:


15
16
17
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 15

def repeat_map
  @repeat_map
end

#selectionMoon::Cuboid

selects a section of the map_data to render

Returns:


21
22
23
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 21

def selection
  @selection
end

#tilesetMoon::Spritesheet

Returns:

  • (Moon::Spritesheet)

7
8
9
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 7

def tileset
  @tileset
end

#tilesizeVector2 (readonly)

Returns:


23
24
25
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 23

def tilesize
  @tilesize
end

#viewMoon::Rect

restricts rendering inside view

Returns:


18
19
20
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 18

def view
  @view
end

Instance Method Details

#refresh_dataObject


46
47
48
49
50
51
52
53
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 46

def refresh_data
  if @data
    @datasize = Vector2.new(@data.xsize, @data.ysize)
  else
    @datasize = Vector2.new
  end
  refresh_size
end

#refresh_sizeObject


42
43
44
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 42

def refresh_size
  resize @datasize.x * @tilesize.x, @datasize.y * @tilesize.y
end

#refresh_tilesetObject


55
56
57
58
59
60
61
62
# File 'lib/moon/packages/render_primitives/tilemap.rb', line 55

def refresh_tileset
  if @tileset
    @tilesize = Vector2.new(@tileset.cell_w, @tileset.cell_h)
  else
    @tilesize = Vector2.new
  end
  refresh_size
end