Class: BgUtils::TiledImage

Inherits:
Object
  • Object
show all
Defined in:
lib/bg_utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gosu_image, width, height, scale_x = 1.0, scale_y = 1.0, color = 0xff_ffffff, mode = :default, options = {:retro => true}) ⇒ TiledImage

Returns a new instance of TiledImage.



132
133
134
135
136
137
138
139
140
141
142
# File 'lib/bg_utils.rb', line 132

def initialize(gosu_image, width, height, scale_x = 1.0, scale_y = 1.0, color = 0xff_ffffff, mode = :default, options = {:retro => true})
	options[:tileable] = true
	if gosu_image.is_a?(Gosu::Image) or gosu_image.is_a?(String)
		@image = (gosu_image.is_a?(Gosu::Image)) ? gosu_image : Gosu::Image.new(gosu_image, options)
	else
		raise("Wrong parameter 0 for 'Image' : \ngiven : #{gosu_image}\nshould be either a Gosu::Image instance or a string that contains path and filename")
	end

	@width, @height, @scale_x, @scale_y = width, height, scale_x, scale_y
	@color, @mode = color, mode
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



131
132
133
# File 'lib/bg_utils.rb', line 131

def height
  @height
end

#scale_xObject (readonly)

Returns the value of attribute scale_x.



131
132
133
# File 'lib/bg_utils.rb', line 131

def scale_x
  @scale_x
end

#scale_yObject (readonly)

Returns the value of attribute scale_y.



131
132
133
# File 'lib/bg_utils.rb', line 131

def scale_y
  @scale_y
end

#widthObject (readonly)

Returns the value of attribute width.



131
132
133
# File 'lib/bg_utils.rb', line 131

def width
  @width
end

Instance Method Details

#draw(x, y, z, scale_x = 1, scale_y = 1) ⇒ Object



144
145
146
147
# File 'lib/bg_utils.rb', line 144

def draw(x, y, z, scale_x = 1, scale_y = 1)
	@drawing_macro ||= create_macro
	@drawing_macro.draw(x, y, z, scale_x, scale_y)
end

#draw_as_quad(x1, y1, x2, y2, x3, y3, x4, y4, z) ⇒ Object



154
155
156
157
158
# File 'lib/bg_utils.rb', line 154

def draw_as_quad(x1, y1, x2, y2, x3, y3, x4, y4, z)
	@drawing_macro ||= create_macro
	c = Gosu::Color::WHITE
	@drawing_macro.draw_as_quad(x1, y1, c, x2, y2, c, x3, y3, c, x4, y4, c, z)
end

#draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, scale_x = 1, scale_y = 1) ⇒ Object



149
150
151
152
# File 'lib/bg_utils.rb', line 149

def draw_rot(x, y, z, angle, center_x = 0.5, center_y = 0.5, scale_x = 1, scale_y = 1)
	@drawing_macro ||= create_macro
	@drawing_macro.draw_rot(x, y, z, angle, center_x, center_y, scale_x, scale_y)
end