Class: Core::Game::Combat::BattleObject
- Defined in:
- lib/game/combat/battle.rb
Overview
Superclass for enemies and actors
Direct Known Subclasses
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #attacked(hit) ⇒ Object
- #draw ⇒ Object
-
#initialize(graphic, x, y, z = Core::MAPOBJECT_Z, color = Gosu::Color::WHITE) ⇒ BattleObject
constructor
A new instance of BattleObject.
- #name ⇒ Object
- #update(pause) ⇒ Object
Constructor Details
#initialize(graphic, x, y, z = Core::MAPOBJECT_Z, color = Gosu::Color::WHITE) ⇒ BattleObject
Returns a new instance of BattleObject.
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/game/combat/battle.rb', line 112 def initialize(graphic, x, y, z=Core::MAPOBJECT_Z, color=Gosu::Color::WHITE) @frame = 0 @x, @y, @z = x, y, z @color = color if File.exists?("graphics/combat/#{graphic}.png") @graphics = Gosu::Image.load_tiles(Core.window, "graphics/combat/#{graphic}.png", -4, -4, false) @frame = 4 else @graphics = [Core.sprite("missing")] end @target = nil end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
111 112 113 |
# File 'lib/game/combat/battle.rb', line 111 def target @target end |
Instance Method Details
#attacked(hit) ⇒ Object
136 137 138 |
# File 'lib/game/combat/battle.rb', line 136 def attacked(hit) @target = nil end |
#draw ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/game/combat/battle.rb', line 128 def draw if @graphics[@frame] @graphics[@frame].draw(@x, @y, @z, 1, 1, @color) else @graphics.first.draw(@x, @y, @z, 1, 1, @color) end end |
#name ⇒ Object
140 141 142 |
# File 'lib/game/combat/battle.rb', line 140 def name return "" end |
#update(pause) ⇒ Object
125 126 |
# File 'lib/game/combat/battle.rb', line 125 def update(pause) end |