Class: Yuki::Tilemap::MapData

Inherits:
Object
  • Object
show all
Defined in:
docs/4_Systems_003_Map_Engine.rb

Overview

Class containing the map Data and its resources

Defined Under Namespace

Classes: AnimatedTileCounter

Constant Summary collapse

POSITION_LOADERS =

List of method that help to load the position

Returns:

  • (Hash{Symbol => Symbol})
{north: :load_position_north, south: :load_position_south, east: :load_position_east, west: :load_position_west, self: :load_position_self}

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map, map_id) ⇒ MapData

Create a new MapData

Parameters:



1593
1594
# File 'docs/4_Systems_003_Map_Engine.rb', line 1593

def initialize(map, map_id)
end

Class Attribute Details

.tileset_chunks ⇒ Hash{filename => Array<Texture>} (readonly)

Get tileset chunks

Returns:

  • (Hash{filename => Array<Texture>})


1679
1680
1681
# File 'docs/4_Systems_003_Map_Engine.rb', line 1679

def tileset_chunks
  @tileset_chunks
end

Instance Attribute Details

#map ⇒ RPG::Map (readonly)

Get access to the original map data

Returns:



1567
1568
1569
# File 'docs/4_Systems_003_Map_Engine.rb', line 1567

def map
  @map
end

#map_id ⇒ Integer (readonly)

Get the map id

Returns:

  • (Integer)


1570
1571
1572
# File 'docs/4_Systems_003_Map_Engine.rb', line 1570

def map_id
  @map_id
end

#offset_x ⇒ Integer (readonly)

Get the map offset_x

Returns:

  • (Integer)


1579
1580
1581
# File 'docs/4_Systems_003_Map_Engine.rb', line 1579

def offset_x
  @offset_x
end

#offset_y ⇒ Integer (readonly)

Get the map offset_y

Returns:

  • (Integer)


1582
1583
1584
# File 'docs/4_Systems_003_Map_Engine.rb', line 1582

def offset_y
  @offset_y
end

#side ⇒ Symbol (readonly)

Get the side of the map

Returns:

  • (Symbol)


1588
1589
1590
# File 'docs/4_Systems_003_Map_Engine.rb', line 1588

def side
  @side
end

#tileset_name ⇒ String (readonly)

Get the tileset filename (to prevent unwanted dispose in the future)

Returns:



1585
1586
1587
# File 'docs/4_Systems_003_Map_Engine.rb', line 1585

def tileset_name
  @tileset_name
end

#x_range ⇒ Range (readonly)

Get the map X coordinate range

Returns:

  • (Range)


1573
1574
1575
# File 'docs/4_Systems_003_Map_Engine.rb', line 1573

def x_range
  @x_range
end

#y_range ⇒ Range (readonly)

Get the map Y coordinate range

Returns:

  • (Range)


1576
1577
1578
# File 'docs/4_Systems_003_Map_Engine.rb', line 1576

def y_range
  @y_range
end

Instance Method Details

#[](x, y, z)

Get a tile from the map

Parameters:

  • x (Integer) —

    real world x position

  • y (Integer) —

    real world y position

  • z (Integer) —

    z



1605
1606
# File 'docs/4_Systems_003_Map_Engine.rb', line 1605

def [](x, y, z)
end

#assign_tile_to_sprite(sprite, tile_id)

Set tile sprite to sprite

Parameters:

  • sprite (Sprite)
  • tile_id (Integer) —

    ID of the tile the sprite wants



1610
1611
# File 'docs/4_Systems_003_Map_Engine.rb', line 1610

def assign_tile_to_sprite(sprite, tile_id)
end

#draw(x, y, tx, ty, tz, layer)

Draw the tile on the right layer

Parameters:

  • x (Integer) —

    real world x of the top left tile

  • y (Integer) —

    real world y of the top left tile

  • tx (Integer) —

    x index of the tile to draw from top left tile (0)

  • ty (Integer) —

    y index of the tile to draw from top left tile (0)

  • tz (Integer) —

    z index of the tile to draw

  • layer (Array<Array<SpriteMap>>) —

    layers of the tilemap .dig(priority, ty)



1619
1620
# File 'docs/4_Systems_003_Map_Engine.rb', line 1619

def draw(x, y, tx, ty, tz, layer)
end

#draw_map(x, y, rx, ry, layers)

Draw the visible part of the map

Parameters:

  • x (Integer) —

    real world x of the top left tile

  • y (Integer) —

    real world y of the top left tile

  • rx (Integer) —

    real world x of the bottom right tile

  • ry (Integer) —

    real world y of the bottom right tile

  • layers (Array<Array<Array<SpriteMap>>>) —

    layers of the tilemap .dig(tz, priority, ty)



1627
1628
# File 'docs/4_Systems_003_Map_Engine.rb', line 1627

def draw_map(x, y, rx, ry, layers)
end

#load_position(map, side, offset)

Sets the position of the map in the 2D Space

Parameters:

  • map (RPG::Map) —

    current map

  • side (Symbol) —

    which side the map is (:north, :south, :east, :west)

  • offset (Integer) —

    offset relative to the side of the map in the positive perpendicular position



1599
1600
# File 'docs/4_Systems_003_Map_Engine.rb', line 1599

def load_position(map, side, offset)
end

#load_tileset

Load the tileset



1630
1631
# File 'docs/4_Systems_003_Map_Engine.rb', line 1630

def load_tileset
end

#update_counters

Update the autotiles counter (for tilemap)



1633
1634
# File 'docs/4_Systems_003_Map_Engine.rb', line 1633

def update_counters
end