Class: Ruby2d::Tiled::World

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2d/tiled/world.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, levels) ⇒ World

Returns a new instance of World.



8
9
10
11
12
13
14
15
16
# File 'lib/ruby2d/tiled/world.rb', line 8

def initialize(data, levels)
  @data = data
  @levels = levels
  @current_level = 0
  @scale = 1
  @x_offset = 0
  @y_offset = 0
  @angle = 0
end

Instance Attribute Details

#levelsObject (readonly)

Returns the value of attribute levels.



6
7
8
# File 'lib/ruby2d/tiled/world.rb', line 6

def levels
  @levels
end

#scaleObject

Returns the value of attribute scale.



6
7
8
# File 'lib/ruby2d/tiled/world.rb', line 6

def scale
  @scale
end

#x_offsetObject

Returns the value of attribute x_offset.



6
7
8
# File 'lib/ruby2d/tiled/world.rb', line 6

def x_offset
  @x_offset
end

#y_offsetObject

Returns the value of attribute y_offset.



6
7
8
# File 'lib/ruby2d/tiled/world.rb', line 6

def y_offset
  @y_offset
end

Instance Method Details

#clearObject



26
27
28
# File 'lib/ruby2d/tiled/world.rb', line 26

def clear
  @levels[@current_level].clear
end

#next_levelObject



30
31
32
33
34
35
36
# File 'lib/ruby2d/tiled/world.rb', line 30

def next_level
  if @levels.size > @current_level + 1
    clear
    @current_level += 1
    show
  end
end

#prev_levelObject



38
39
40
41
42
43
44
# File 'lib/ruby2d/tiled/world.rb', line 38

def prev_level
  if @current_level > 0
    clear
    @current_level -= 1
    show
  end
end

#showObject



18
19
20
21
22
23
24
# File 'lib/ruby2d/tiled/world.rb', line 18

def show
  clear
  @levels[@current_level].scale = @scale
  @levels[@current_level].x_offset = @x_offset
  @levels[@current_level].y_offset = @y_offset
  @levels[@current_level].show
end