module RPG
class Sprite
def damage(value, critical)
####################
fontsize=50
criticalfontsize=30
####################
dispose_damage
if value.is_a?(Numeric)
damage_string = value.abs.to_s
else
damage_string = value.to_s
end
dummy=Bitmap.new(1,1)
dummy.font.name = "Arial Black"
dummy.font.size = fontsize
dmgstrsize=dummy.text_size(damage_string)
dummy.font.size = criticalfontsize
criticalsize=dummy.text_size("CRITICAL")
dummy.dispose
bitmap = Bitmap.new(
[dmgstrsize.width,criticalsize.width,160].max+8,
[dmgstrsize.height,criticalsize.height,40].max+8
)
bitmap.font.name = "Arial Black"
bitmap.font.size = fontsize
bitmap.font.color.set(0, 0, 0)
w=dmgstrsize.width
h=dmgstrsize.height
bitmap.draw_text(-1, 12-1, bitmap.width,h, damage_string, 1)
bitmap.draw_text(+1, 12-1, bitmap.width,h, damage_string, 1)
bitmap.draw_text(-1, 12+1, bitmap.width,h, damage_string, 1)
bitmap.draw_text(+1, 12+1, bitmap.width,h, damage_string, 1)
if value.is_a?(Numeric) and value < 0
bitmap.font.color.set(176, 255, 144)
else
bitmap.font.color.set(255, 255, 255)
end
bitmap.draw_text(0, 12, bitmap.width,h, damage_string, 1)
if critical
w=criticalsize.width
h=criticalsize.height
bitmap.font.size = criticalfontsize
bitmap.font.color.set(0, 0, 0)
bitmap.draw_text(-1, -1, bitmap.width,h, "CRITICAL", 1)
bitmap.draw_text(+1, -1, bitmap.width,h, "CRITICAL", 1)
bitmap.draw_text(-1, +1, bitmap.width,h, "CRITICAL", 1)
bitmap.draw_text(+1, +1, bitmap.width,h, "CRITICAL", 1)
bitmap.font.color.set(255, 255, 255)
bitmap.draw_text(0, 0, bitmap.width,h, "CRITICAL", 1)
end
@_damage_sprite = ::Sprite.new(self.viewport)
@_damage_sprite.bitmap = bitmap
@_damage_sprite.ox = 80
@_damage_sprite.oy = 20
@_damage_sprite.x = self.x
@_damage_sprite.y = self.y - self.oy / 2
@_damage_sprite.z = 3000
@_damage_duration = 40
end
end
end