Class: RTanque::Gui::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/rtanque/gui/shell.rb

Constant Summary collapse

DEBUG =
ENV["DEBUG_SHELLS"]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(window, shell) ⇒ Shell


10
11
12
13
14
15
16
# File 'lib/rtanque/gui/shell.rb', line 10

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

Instance Attribute Details

#shellObject (readonly)

Returns the value of attribute shell


6
7
8
# File 'lib/rtanque/gui/shell.rb', line 6

def shell
  @shell
end

Instance Method Details

#drawObject


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rtanque/gui/shell.rb', line 18

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