Class: TCOD::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/libtcod/map.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ Map

Returns a new instance of Map


5
6
7
8
9
10
11
# File 'lib/libtcod/map.rb', line 5

def initialize(width, height)
  @width = width
  @height = height
  @ptr = TCOD.map_new(width, height)

  ObjectSpace.define_finalizer(self, self.class.finalize(ptr))
end

Instance Attribute Details

#ptrObject (readonly)

Returns the value of attribute ptr


3
4
5
# File 'lib/libtcod/map.rb', line 3

def ptr
  @ptr
end

Class Method Details

.finalize(ptr) ⇒ Object


31
32
33
# File 'lib/libtcod/map.rb', line 31

def self.finalize(ptr)
  proc { TCOD.map_delete(ptr) }
end

Instance Method Details

#cloneObject


25
26
27
28
29
# File 'lib/libtcod/map.rb', line 25

def clone
  map = Map.new(@width, @height)
  TCOD.map_copy(@ptr, map.ptr)
  map
end

#compute_fov(x, y, max_radius, light_walls, algo) ⇒ Object


17
18
19
# File 'lib/libtcod/map.rb', line 17

def compute_fov(x, y, max_radius, light_walls, algo)
  TCOD.map_compute_fov(@ptr, x, y, max_radius, light_walls, algo)
end

#in_fov?(x, y) ⇒ Boolean

Returns:

  • (Boolean)

21
22
23
# File 'lib/libtcod/map.rb', line 21

def in_fov?(x, y)
  TCOD.map_is_in_fov(@ptr, x, y)
end

#set_properties(x, y, is_transparent, is_walkable) ⇒ Object


13
14
15
# File 'lib/libtcod/map.rb', line 13

def set_properties(x, y, is_transparent, is_walkable)
  TCOD.map_set_properties(@ptr, x, y, is_transparent, is_walkable)
end