Class: Tile

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/user_interface/tile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x, y, loaded_symbol, infopane) ⇒ Tile

Returns a new instance of Tile.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/lib/user_interface/tile.rb', line 10

def initialize(x, y, loaded_symbol, infopane)
  dir_path = File.dirname(__FILE__)

  @x = x
  @y = y
  @infopane = infopane

  case(loaded_symbol)
  when SYMBOL_SEA then
    @terrain = TILE_SEA
    @image = Gosu::Image.new(dir_path + '/../../media/sea.png')
  when SYMBOL_GROUND then
    @terrain = TILE_GROUND
    @image = Gosu::Image.new(dir_path + '/../../media/ground.png')
  else
    abort("tile.initialize(): Unknown terrain symbol (#{loaded_symbol})")
  end
end

Instance Attribute Details

#infopaneObject

Returns the value of attribute infopane.



8
9
10
# File 'lib/lib/user_interface/tile.rb', line 8

def infopane
  @infopane
end

#terrainObject

Returns the value of attribute terrain.



8
9
10
# File 'lib/lib/user_interface/tile.rb', line 8

def terrain
  @terrain
end

#unitObject

Returns the value of attribute unit.



8
9
10
# File 'lib/lib/user_interface/tile.rb', line 8

def unit
  @unit
end

Instance Method Details

#drawObject



29
30
31
32
33
34
35
# File 'lib/lib/user_interface/tile.rb', line 29

def draw
  @image.draw(@x * TILESIZE, (@y + 1) * TILESIZE, ZTILE)

  if @unit
    @unit.draw
  end
end