Class: Core::Game::Combat::BattleObject

Inherits:
Object
  • Object
show all
Defined in:
lib/game/combat/battle.rb

Overview

Superclass for enemies and actors

Direct Known Subclasses

Actor, BattleEnemy

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#targetObject (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

#drawObject



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

#nameObject



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