Class: Pixiurge::Display::TmxMap

Inherits:
Pixiurge::Displayable show all
Defined in:
lib/pixiurge/displayable/tmx_map.rb

Overview

A TmxMap uses a Demiurge item's TMX entry as its source of data and behavior.

Since:

  • 0.1.0

Instance Attribute Summary

Attributes inherited from Pixiurge::Displayable

#block_height, #block_width, #displayable_type, #location_displayable, #location_name, #name, #position, #x, #y

Instance Method Summary collapse

Methods inherited from Pixiurge::Displayable

#destroy_for_player, #move_for_player, #show_to_player

Constructor Details

#initialize(tile_cache_entry, name:, engine_connector:) ⇒ TmxMap

Constructor. Assume we read the TMX cache information from the Demiurge item and display it.

Since:

  • 0.1.0



11
12
13
14
15
16
17
# File 'lib/pixiurge/displayable/tmx_map.rb', line 11

def initialize(tile_cache_entry, name:, engine_connector:)
  super(name: name, engine_connector: engine_connector)
  @displayable_type = "tmx"
  @entry = tile_cache_entry
  @block_width = @entry["tilewidth"]
  @block_height = @entry["tileheight"]
end

Instance Method Details

#messages_to_show_player(player) ⇒ Array

Messages to display the TMX object.

Parameters:

Returns:

  • (Array)

    Message to send to player

Since:

  • 0.1.0



24
25
26
27
28
29
# File 'lib/pixiurge/displayable/tmx_map.rb', line 24

def messages_to_show_player(player)
  # Currently TMX maps do not deign to send mere transforms. That
  # may change if we need to put several of them together into a
  # single layer.
  [ { "type" => @displayable_type, "url" => File.join("/", @entry["filename"]) } ]
end