irpg Community

Full Version: Shadow Text (ตัวหนังสือมีเงา)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Shadow Text
สคริปต์เขียนโดย : Rise Field
ลิงค์ต้นฉบับ : ยังหาต้นฉบับเดิมไม่ได้เนื่องจากไม่ได้เก็บลิงค์ไว้


รายละเอียด :
ทำให้ตัวหนังสือทุกตัวมีเงาทั้งหมดในเกม
ตัวอย่าง ตัวหนังสือปกติ กับ ตัวหนังสือมีเงา
[Image: untitled-64.jpg]

วิธีการใช้งาน :
สร้าง script ใหม่ เหนือ main ใส่ชื่ออะไรก็ได้ แล้ว copy script ข้างล่างไปแปะให้หมด


โค๊ดสคริปต์
Code:
################################################################################
################################ Rise Field ####################################
################################################################################
=begin
                                 Shadow Text
                        
--------------------------------------------------------------------------------
Script criado pelo site Rise Field.
Created by Rise Field site.
--------------------------------------------------------------------------------

CARACTER??STICAS
Adiciona negrito nos textos.

=end
#-------------------------------------------------------------------------------

class Bitmap
  if !method_defined?("draw_text_original")
    alias draw_text_original draw_text
  end
  def draw_text(x, y, width = 0, height = 0, str = "", align = 0)
    last_color = font.color.dup
    font.color = Color.new( 0, 0, 0,last_color.alpha)
    case x
    when Numeric
      draw_text_original(x+1, y+1, width, height, str, align)
      font.color = last_color
      draw_text_original(x, y, width, height, str, align)
    when Rect
      rect  = x
      str   = y
      align = width
      shadow_rect = x.dup
      shadow_rect.x += 1
      shadow_rect.y += 1
      draw_text_original( shadow_rect, str, align)
      font.color = last_color
      draw_text_original( rect, str, align)
    end
  end
end



module RPG
  class Sprite < ::Sprite
    def damage(value, critical)
      dispose_damage
      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.name = "Georgia"
      bitmap.font.size = 32
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text_original(-1, 12-1, 160, 36, damage_string, 1) # ??
      bitmap.draw_text_original(+1, 12-1, 160, 36, damage_string, 1) # ???
      bitmap.draw_text_original(-1, 12+1, 160, 36, damage_string, 1) # ??
      bitmap.draw_text_original(+1, 12+1, 160, 36, 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_original(0, 12, 160, 36, damage_string, 1) # ??
      if critical
        bitmap.font.size = 20
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text_original(-1, -1, 160, 20, "CRITICAL", 1) # ??
        bitmap.draw_text_original(+1, -1, 160, 20, "CRITICAL", 1) # ??
        bitmap.draw_text_original(-1, +1, 160, 20, "CRITICAL", 1) # ??
        bitmap.draw_text_original(+1, +1, 160, 20, "CRITICAL", 1) # ??
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text_original(0, 0, 160, 20, "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