Public feed #888482

Stuff

public ruby v1 · immutable
Raw Edit
·published 2008-02-02 04:13 UTC
rendered paste body
module Sponge	MAP_DIR = 'maps'	class Map		attr_reader :name, :width, :height, :tiles		def initialize(filename)			map_info = File.readlines(File.join(MAP_DIR, filename + '.mapinfo')).map { |line| line.chop }			@name = map_info[0]			@width = map_info[1].to_i			@height = map_info[2].to_i			@tiles = Array.new(@width) { Array.new(@height) }			File.open(File.join(MAP_DIR, filename + '.map'), 'rb') do |f|				x = 0				y = 0				f.each_byte do |b|					# there's probably a much better way to do this...					if x == @width						x = 0						y += 1					end					@tiles[x][y] = b.to_i					x += 1				end			end		end	endendmap = Sponge::Map.new('newtest')require 'pp'pp map