Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (23 sloc) 0.776 kb
require 'gosu'
class Tile
attr_reader :width, :height, :animated, :frames
def initialize(game, filename, tile_width, tile_height)
@width = tile_width
@height = tile_height
puts "Loading #{filename}"
image = Gosu::Image.new(game, filename, false)
tiles_wide = image.width / tile_width
tiles_high = image.height / tile_height
tiles = Gosu::Image.load_tiles(game, filename,
tile_width, tile_height, false)
@image = Array.new(tiles_high) { Array.new(tiles_wide) }
tiles.each_index do |i|
@image[i / tiles_wide][i % tiles_wide] = tiles[i]
end
@frames = tiles_wide
@animated = (@frames > 1)
end
def draw(x, y, version, frame = 0)
@image[version][frame].draw(x, y, 0)
end
end
Jump to Line
Something went wrong with that request. Please try again.