translate(x, y) do
@player.draw
end
draw_proc = proc { @player.draw }
translate(x, y, &draw_proc)
translate
, rotate
and scale
with a block , which is a common pattern in Ruby. If you don't know about blocks, you might want to Google for more information.@image.draw(x, y, z)
. These transformations are applied to everything that's drawn inside of the block.translate
, one might replace code like this:@player.draw @player_x - @scroll_x, @player_y - @scroll_y
@enemy.draw @enemy_x - @scroll_x, @enemy_y - @scroll_y
...
translate(-@scroll_x, -@scroll_y) do
@player.draw @player_x, @player_y, 0
@enemy.draw @enemy_x, @enemy_y, 0
...
end
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill