Method: MiniGL::Map#initialize

Defined in:
lib/minigl/map.rb

#initialize(t_w, t_h, t_x_count, t_y_count, scr_w = 800, scr_h = 600, isometric = false, limit_cam = true) ⇒ Map

Creates a new map.

Parameters:

t_w

The width of the tiles.

t_h

The height of the tiles.

t_x_count

The horizontal count of tiles in the map.

t_y_count

The vertical count of tiles in the map.

scr_w

Width of the viewport for the map.

scr_h

Height of the viewport for the map.

isometric

Whether to use a isometric map. By default, an ortogonal map is used.

limit_cam

Whether the camera should respect the bounds of the map (i.e., when given coordinates that would imply regions outside the map to appear in the screen, the camera would move to the nearest position where only the map shows up in the screen).



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/minigl/map.rb', line 42

def initialize(t_w, t_h, t_x_count, t_y_count, scr_w = 800, scr_h = 600, isometric = false, limit_cam = true)
  @tile_size = Vector.new t_w, t_h
  @size = Vector.new t_x_count, t_y_count
  @cam = Rectangle.new 0, 0, scr_w, scr_h
  @limit_cam = limit_cam
  @isometric = isometric
  if isometric
    initialize_isometric
  elsif limit_cam
    @max_x = t_x_count * t_w - scr_w
    @max_y = t_y_count * t_h - scr_h
  end
  set_camera 0, 0
end