examples/rmagick_integration.rb
def try_walk(dir)
    @show_walk_anim = true
    @dir = dir
    # First, magically move up (so soldiers can run up hills)
    2.times { @y -= 1 unless @window.map.solid?(x, y - HEIGHT - 1) }
    # Now move into the desired direction.
    @x += dir unless @window.map.solid?(x + dir, y) or
                     @window.map.solid?(x + dir, y - HEIGHT) 
    # To make up for unnecessary movement upwards, sink downward again.
    2.times { @y += 1 unless @window.map.solid?(x, y + 1) }
  end
# Magic numbers considered harmful! This is the height of the
# player as used for collision detection.
Magic numbers considered harmful. This is the height of the
player as used for collision detection.
Magic numbers considered harmful . This is the height of the player as used for collision detection .
def try_walk(dir)
    @show_walk_anim = true
    @dir = dir
    2.times { @y -= 1 unless @window.map.solid?(x, y - HEIGHT - 1) }
    @x += dir unless @window.map.solid?(x + dir, y) or
                     @window.map.solid?(x + dir, y - HEIGHT) 
    2.times { @y += 1 unless @window.map.solid?(x, y + 1) }
  end
def try_walk ( dir ) @show_walk_anim = true @dir = dir 2 . times { @y -= 1 unless @window . map . solid? ( x , y - HEIGHT - 1 ) } @x += dir unless @window . map . solid? ( x + dir , y ) or @window . map . solid? ( x + dir , y - HEIGHT ) 2 . times { @y += 1 unless @window . map . solid? ( x , y + 1 ) } end
Magic numbers considered harmful!
Magic numbers considered harmful!
# First, magically move up (so soldiers can run up hills) # Now move into the desired direction. # To make up for unnecessary movement upwards, sink downward again.
dir