Class: Rubots::Graphics::Robot
- Inherits:
-
Object
- Object
- Rubots::Graphics::Robot
- Defined in:
- lib/rubots/graphics/robot.rb
Constant Summary collapse
- Z_AXIS =
10
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(window, robot) ⇒ Robot
constructor
A new instance of Robot.
Constructor Details
#initialize(window, robot) ⇒ Robot
Returns a new instance of Robot.
6 7 8 9 10 11 12 |
# 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 |
Instance Method Details
#draw ⇒ Object
14 15 16 17 18 19 20 21 22 |
# 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 |