Class: TankGraphics
- Defined in:
- lib/entities/components/tank_graphics.rb
Instance Attribute Summary
Attributes inherited from Component
Instance Method Summary collapse
- #draw(viewport) ⇒ Object
- #height ⇒ Object
-
#initialize(game_object) ⇒ TankGraphics
constructor
A new instance of TankGraphics.
- #update ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(game_object) ⇒ TankGraphics
Returns a new instance of TankGraphics.
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/entities/components/tank_graphics.rb', line 2 def initialize(game_object) super(game_object) @body_normal = units.frame('tank1_body.png') @shadow_normal = units.frame('tank1_body_shadow.png') @gun_normal = units.frame('tank1_dualgun.png') @body_dead = units.frame('tank1_body_destroyed.png') @shadow_dead = units.frame('tank1_body_destroyed_shadow.png') @gun_dead = nil update end |
Instance Method Details
#draw(viewport) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/entities/components/tank_graphics.rb', line 25 def draw() @shadow.draw_rot(x - 1, y - 1, 0, object.direction) @body.draw_rot(x, y, 1, object.direction) @gun.draw_rot(x, y, 2, object.gun_angle) if @gun Utils.mark_corners(object.box) if $debug end |
#height ⇒ Object
36 37 38 |
# File 'lib/entities/components/tank_graphics.rb', line 36 def height @body.height end |
#update ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/entities/components/tank_graphics.rb', line 13 def update if object && object.health.dead? @body = @body_dead @gun = @gun_dead @shadow = @shadow_dead else @body = @body_normal @gun = @gun_normal @shadow = @shadow_normal end end |
#width ⇒ Object
32 33 34 |
# File 'lib/entities/components/tank_graphics.rb', line 32 def width @body.width end |