module RPG
class Sprite < ::Sprite
@@font = Font.new("Arial Black", 16)
@@font.bold = true
def self.font
@@font
end
def self.font=(value)
@@font = value
end
def damage(value, critical, type = 0)
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
bitmap = Bitmap.new(160, 48)
bitmap.font = @@font.clone
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
if value.is_a?(Numeric) and value < 0
if type == 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(176, 144, 255)
end
else
if type == 0
bitmap.font.color.set(255, 255, 255)
else
bitmap.font.color.set(255, 176, 144)
end
end
if type == 2
bitmap.font.color.set(255, 224, 128)
end
bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
if critical
string = "CRITICAL"
bitmap.font.size = 20
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, 160, 20, string, 1)
bitmap.draw_text(+1, -1, 160, 20, string, 1)
bitmap.draw_text(-1, +1, 160, 20, string, 1)
bitmap.draw_text(+1, +1, 160, 20, string, 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, 160, 20, string, 1)
end
num = @_damage.size
if type != 2
@_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
else
@_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
end
@_damage[num][0].bitmap = bitmap
@_damage[num][0].ox = 80 + self.viewport.ox
@_damage[num][0].oy = 20 + self.viewport.oy
if self.battler.is_a?(Game_Actor)
@_damage[num][0].x = self.x
@_damage[num][0].y = self.y - self.oy / 2
else
@_damage[num][0].x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
@_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
self.viewport.rect.y
@_damage[num][0].zoom_x = self.zoom_x
@_damage[num][0].zoom_y = self.zoom_y
@_damage[num][0].z = 3000
end
end
end
end