Class: RedBird::TileMap
Overview
A TileMap is a grid of Sprites; it works as a scenario. It has scrolling functionalities to control which portion of it is on the screen.
Instance Attribute Summary collapse
-
#hor_offset ⇒ Integer
How much the tilemap scrolled from the left corner.
-
#tile_set ⇒ RedBird::TileSet
readonly
Tile set in use by this class.
-
#tiles ⇒ Array<Integer>
readonly
Tiles indexes.
-
#total_height ⇒ Integer
readonly
Height of the entire tilemap (not only what is displayed in the screen).
-
#total_width ⇒ Integer
readonly
Width of the entire tilemap (not only what is displayed in the screen).
-
#ver_offset ⇒ Integer
How much the tilemap scrolled from the top.
Attributes inherited from Entity
#height, #pos_x, #pos_y, #priority, #width
Class Method Summary collapse
-
.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) ⇒ RedBird::TileMap
Load information from a yaml file and uses it create an instance of this class.
Instance Method Summary collapse
-
#initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) ⇒ TileMap
constructor
A new instance of TileMap.
-
#render ⇒ Object
Renders this tilemap to the screen.
-
#tile_xy(x, y) ⇒ Object
Gets the Sprite at position x, y.
Methods inherited from Entity
#cursor_down, #cursor_hover, #cursor_up, #tick
Constructor Details
#initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) ⇒ TileMap
Returns a new instance of TileMap.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/red_bird/tile_map.rb', line 37 def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end |
Instance Attribute Details
#hor_offset ⇒ Integer
Returns how much the tilemap scrolled from the left corner.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
#tile_set ⇒ RedBird::TileSet (readonly)
Returns tile set in use by this class.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
#tiles ⇒ Array<Integer> (readonly)
Returns tiles indexes.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
#total_height ⇒ Integer (readonly)
Returns height of the entire tilemap (not only what is displayed in the screen).
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
#total_width ⇒ Integer (readonly)
Returns width of the entire tilemap (not only what is displayed in the screen).
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
#ver_offset ⇒ Integer
Returns how much the tilemap scrolled from the top.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/red_bird/tile_map.rb', line 23 class TileMap < Entity attr_accessor :hor_offset, :ver_offset attr_reader :tiles, :tile_set, :total_width, :total_height # @param tile_set [RedBird::TileSet] # @param pos_x [Integer] horizontal position of this map in the screen. # @param pos_y [Integer] vertical position of this map in the screen. # @param width [Integer] width of the region displayed in the screen. # @param height [Integer] height of the region displayed in the screen. # @param num_hor_tiles [Integer] total width in number of tiles. # @param num_ver_tiles [Integer] total height in number of tiles. # @param tiles [Array<Integer>] code of every tile to display, must be an # one dimension array. # @author Frederico Linhares def initialize(tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) @tile_set = tile_set @pos_x = pos_x @pos_y = pos_y @width = width @height = height @ver_offset = 0 @hor_offset = 0 @priority = -1 @tiles = tiles # Number of tiles that are going to be rendered to screen. @render_hor_tiles = @width / @tile_set.tile_width + 1 @render_ver_tiles = @height / @tile_set.tile_height + 1 @total_hor_tiles = num_hor_tiles @total_ver_tiles = num_ver_tiles @total_width = @total_hor_tiles * @tile_set.tile_width @total_height = @total_ver_tiles * @tile_set.tile_height end # Load information from a yaml file and uses it create an instance of this # class. # # @param data_dir [String] path to the directory containing the yaml and # other files referenced in the yaml. # @param map_file [String] path to the yaml file. # @return [RedBird::TileMap] # @author Frederico Linhares def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end # Gets the {RedBird::Sprite} at position x, y. # # @param x [Integer] # @param y [Integer] # @author Frederico Linhares def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end # Renders this tilemap to the screen. # # @author Frederico Linhares def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end private def y_to_tile(y) return y * @total_hor_tiles end end |
Class Method Details
.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) ⇒ RedBird::TileMap
Load information from a yaml file and uses it create an instance of this class.
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/red_bird/tile_map.rb', line 72 def self.from_yml(data_dir, map_file, tile_set, pos_x, pos_y, width, height) yaml_file = data_dir + map_file data = YAML.load_file(yaml_file) num_hor_tiles = data["num_hor_tiles"] num_ver_tiles = data["num_ver_tiles"] tiles = data["tiles"].unpack("S*") return self.new( tile_set, pos_x, pos_y, width, height, num_hor_tiles, num_ver_tiles, tiles) end |
Instance Method Details
#render ⇒ Object
Renders this tilemap to the screen.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/red_bird/tile_map.rb', line 98 def render first_hor_tile = @hor_offset / @tile_set.tile_width first_ver_tile = @ver_offset / @tile_set.tile_height (first_ver_tile..(first_ver_tile + @render_ver_tiles)).each do |y| (first_hor_tile..(first_hor_tile + @render_hor_tiles)).each do |x| unless @tiles[y_to_tile(y) + x].nil? then @tile_set.tiles[@tiles[y_to_tile(y) + x]].render_to_screen( x * @tile_set.tile_width - @hor_offset + @pos_x, y * @tile_set.tile_height - @ver_offset + @pos_y) end end end end |
#tile_xy(x, y) ⇒ Object
Gets the Sprite at position x, y.
91 92 93 |
# File 'lib/red_bird/tile_map.rb', line 91 def tile_xy(x, y) return @tile_set.tiles[@tiles[y_to_tile(y) + x]][:type] end |