Sha256: 9a71ff06fb61824a64be72976ad4571d5109fb17ebd11ee666c584dc33a47113

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

ActorView.define :graphical_actor_view do

  draw do |target, x_off, y_off, z|
    img = actor.do_or_do_not(:image)
    return if img.nil?

    x = actor.x
    y = actor.y

    offset_x = x+x_off
    offset_y = y+y_off

    alpha = actor.do_or_do_not(:alpha) || 0xFF
    color = Color.new(alpha,0xFF,0xFF,0xFF)

    x_scale = actor.do_or_do_not(:x_scale) || 1
    y_scale = actor.do_or_do_not(:y_scale) || 1

    # TODO add ? ableness to actor attributes
    if actor.do_or_do_not(:tiled)
      x_tiles = actor.num_x_tiles
      y_tiles = actor.num_y_tiles
      img_w = img.width
      img_h = img.height
      x_tiles.times do |col|
        y_tiles.times do |row|
          # TODO why is there a nasty black line between these that jitters?
          img.draw_rot offset_x+col*img_w, offset_y+row*img_h, z, actor.rotation, x_scale, y_scale
        end
      end
    else
      if actor.respond_to? :rotation
        rot = actor.rotation || 0.0
        img.draw_rot offset_x, offset_y, z, rot, 0.5, 0.5, x_scale, y_scale, color
      else
        img.draw offset_x, offset_y, z, x_scale, y_scale, color
      end
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gamebox-0.4.0.rc5 lib/gamebox/views/graphical_actor_view.rb
gamebox-0.4.0.rc4 lib/gamebox/views/graphical_actor_view.rb
gamebox-0.4.0.rc3 lib/gamebox/views/graphical_actor_view.rb
gamebox-0.4.0.rc2 lib/gamebox/views/graphical_actor_view.rb
gamebox-0.4.0.rc1 lib/gamebox/views/graphical_actor_view.rb