class Rubots::Graphics::Robot

Constants

Z_AXIS

Public Class Methods

new(window, robot) click to toggle source
# File lib/rubots/graphics/robot.rb, line 6
def initialize(window, robot)
  @robot = robot
  @image      = Gosu::Image.new(window, Assets::ROBOT_IMG, false)
  @gun_image  = Gosu::Image.new(window, Assets::GUN_IMG, false)
  @dead_image = Gosu::Image.new(window, Assets::DEAD_IMG, false)
  @font       = Gosu::Font.new(window, Gosu::default_font_name, 14)
end

Public Instance Methods

draw() click to toggle source
# File lib/rubots/graphics/robot.rb, line 14
def draw
  if @robot.destroyed?
    @dead_image.draw_rot(@robot.x, @robot.y, Z_AXIS, 0)
  else
    @image.draw_rot(@robot.x, @robot.y, Z_AXIS, @robot.angle)
    @gun_image.draw_rot(@robot.x, @robot.y, Z_AXIS + 1, @robot.angle + @robot.gun_angle)
  end
  @font.draw_rel(@robot.name, @robot.x, @robot.y + 20, Z_AXIS + 2, 0.5, 1.0, 1.0, 1.0, 0xffffff00)
end