Sha256: 87b74027d785975be03bb476f927883ed60d8267152fae40432b1b5e4228866d

Contents?: true

Size: 820 Bytes

Versions: 4

Compression:

Stored size: 820 Bytes

Contents

require 'gosu'

module RTanque
  module Gui
    class Shell
      attr_reader :shell

      DEBUG = ENV["DEBUG_SHELLS"]

      def initialize(window, shell)
        @window = window
        @shell = shell
        @x0 = shell.position.x
        @y0 = @window.height - shell.position.y
        @shell_image = Gosu::Image.new(@window, Gui.resource_path("images/bullet.png"))
      end

      def draw
        position = [self.shell.position.x, @window.height - self.shell.position.y]
        @shell_image.draw_rot(position[0], position[1], ZOrder::SHELL, 0, 0.5, 0.5)

        if DEBUG then
          white  = Gosu::Color::WHITE
          pos = shell.position
          x1, y1 = pos.x, @window.height - pos.y
          @window.draw_line @x0, @y0, white, x1, y1, white, ZOrder::SHELL
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
rtanque-0.1.3 lib/rtanque/gui/shell.rb
colstrom-rtanque-0.1.4 lib/rtanque/gui/shell.rb
colstrom-rtanque-0.1.3 lib/rtanque/gui/shell.rb
rtanque-0.1.2 lib/rtanque/gui/shell.rb