Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Outline Text Help

well.. im using CCOA UMS and Yeyinde FONT EFFECTS script but they doesnt seem to work pretty well together because FONT EFFECT SCRIPT causes THE UMS to LAG ( Drop frame to 4-8 fps everytime a message is display ) so I decided not to use the FONT EFFECTS SCRIPT.

now the problem is:

1. HOW can make MENU and BATTLE TEXT ( i.e. actor.name, Hp, Mp, commands, etc) OUTLINED? ':| the font effect script could actually do this but it causes the ums to lag so I cant use this script..

*I need this so that the TEXT is still visible on LIGHT background
eventhough the font color is LIGHT..


.. Help is greatly appreciated.. thanks in advance. :thumb:

and here is the FONT EFFECT SCRIPT by YEyinde.. IDK how he/she make the fonts outlined..

http://www.rmxp.org/forums/showthread.php?t=10696&highlight=font+effect
 
Code:
class Bitmap
  def draw_outline_text(x, y, wid, hei, text, outlinecolor, insidecolor,  align=0)
    self.font.color = outlinecolor
	  draw_text(x + 1,y + 1,wid,hei,text, align)
	  draw_text(x + 1,y - 1,wid,hei,text, align)
	  draw_text(x - 1,y - 1,wid,hei,text, align)
	  draw_text(x - 1,y + 1,wid,hei,text, align)
    self.font.color = insidecolor
	  draw_text(x,y,wid,hei,text, align)
  end
end
I think it's pretty self-explanatory, just replace all the normal draw_text commands you want to be outlined with draw_outline_text, and add the 2 colors you want the text to be with Color.new(red, green, blue, opacity) o_ob
 
Jaberwoky: Thanks bro.. thats exactly what im looking for and workz great..

Trickster: heres the DEMO.. http://download.yousendit.com/61BC3E755EF8149B

Digital Watch: I know how that works bro.. thankz anyway..

Bump.....

This is for trickster or other scripter there that is interested..

Well I found out that this little command " \shk[0] " that is supposed to stop the shaking window is the one causing the UMS TO LAG if you are also using the FONT EFFECT SCRIPT.. but if your not using the Yeyinde script then the LAG would not occur.. but that little command is the culprit..

IDK whats wrong with this command "\shk[0]". I cant seem to use that command when Im using Yeyinde font effects because it causes lag.

on the demo try removing all \shk[0] command to remove the lag but the message will also not stop shaking.. to bad for the shaking window feature for me..
 
I had this problem *and* I was also using text sound along with the outline. Frankly, after trying to fix it myself (and asking Trickster, a big meanie who DIDN'T HELP ME when I asked this very same question a month ago ;) STOP LYING maybe if you provided a demo maybe I would have been more helpful see my post below :p) I got sick of trying to get it to work with ccoa's UMS.

It seems that the UMS and text outline (and sound) do not mesh well at all. I tried Wachunga's Multiple Message System, and despite having text outline AND text sound (which I had to code in myself cause he didn't ':|), my game ran with a lot less lag (the frame rate would drop, but to 11-15fps which is manageable, unlike the 3-4fps observed with the UMS).

Wachunga's message script is missing some features that are in ccoa's (I was missing the shortcut feature which is really brilliant and it didn't have text sound), but on the bright side it contains some very interesting things that ccoa's UMS doesn't have. Also if you can script a little, it's not that hard to add in features that you want.

However, while Wachunga released a SDK and non-SDK version, the SDK version is the only one I see floating around.
 
what Raiju said and when you set the font to be outlined it is being called a multiple of multiple of times so like if you call it say five times and the font is outlined it will be called 40 times since Yeyinde draws it 8 times to get a good outline.

You can though edit her script so that it uses Yeyinde's font addons instead of her way of doing shadowed/outline text, and that would decrease the lag
 
No you misunderstood me what I meant by setting the font to outlined I mean by Yeyinde's script :p not the other one that was posted

Yeyinde's outline calls it 8 times

But yeah I pretty much agree with your separate font idea calling that method many times is not good. especially since the text is being drawn character by character :-/

EDIT well the only solution I have for you at this time (until Yeyinde get back from his trip so I can yell at him) is to reduce the number of times draw text is called here I have included my version of his font addons (For MACL 2.0)

Code:
#============================================================================== 
# ** Module     
#-----------------------------------------------------------------------------
#  Superclass of the Class class      
#==============================================================================

class Module
  #-------------------------------------------------------------------------
  # * Name:      Class Attribute
  #   Info:      Calls class_reader/writer for a symbol
  #   Author:    Yeyinde
  #   Call Info: symbol, writable
  #              symbol:   A Symbol
  #              writable: Boolean telling is symbol is writable
  #-------------------------------------------------------------------------
  private
  def class_attr(symbol, writable = false)
    raise(TypeError, "#{symbol} must be a Symbol.") unless symbol.is_a?(Symbol)
    class_reader(symbol)
    class_writer(symbol) if writable
    return nil
  end
  #-------------------------------------------------------------------------
  # * Name:      Class Accessor
  #   Info:      Creates reader and writer methods for one or more class variables
  #   Author:    Yeyinde
  #   Call Info: One or more Symbols
  #-------------------------------------------------------------------------
  private
  def class_accessor(*symbols)
    class_writer(*symbols)
    class_reader(*symbols)
  end
  #-------------------------------------------------------------------------
  # * Name:      Class Writer
  #   Info:      Creates writer method for one or more class variables
  #   Author:    Yeyinde
  #   Call Info: One or more Symbols
  #-------------------------------------------------------------------------
  private
  def class_writer(*symbols)
    symbols.each do |symbol|
      raise(TypeError, "#{symbol} must be a Symbol.") unless symbol.is_a?(Symbol)
      method = symbol.id2name
      eval("def self.#{method}=(var); @@#{method} = var; end")
    end
    return nil
  end
  #-------------------------------------------------------------------------
  # * Name:      Class Reader
  #   Info:      Creates reader method for one or more class variables
  #   Author:    Yeyinde
  #   Call Info: One or more Symbols 
  #-------------------------------------------------------------------------
  private
  def class_reader(*symbols)
    symbols.each do |symbol|
      raise(TypeError, "#{symbol} must be a Symbol.") unless symbol.is_a?(Symbol)
      method = symbol.id2name
      eval("def self.#{method}; return @@#{method}; end")
    end
    return nil
  end
end
#============================================================================== 
# ** Font
#-----------------------------------------------------------------------------
# The Font class
#==============================================================================
class Font
  #--------------------------------------------------------------------------
  # * Class Variable Declarations
  #--------------------------------------------------------------------------
  @@default_underline = false
  @@default_underline_full = false 
  @@default_strikethrough = false
  @@default_strikethrough_full = false
  @@default_shadow = false
  @@default_shadow_color = Color.new(0, 0, 0, 100)
  @@default_outline = true
  @@default_outline_color = Color.new(0, 0, 0)
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :underline, :underline_full
  attr_accessor :strikethrough, :strikethrough_full
  attr_accessor :shadow_color, :outline_color
  attr_reader :shadow, :outline 
  #--------------------------------------------------------------------------
  # * Class Variables
  #--------------------------------------------------------------------------
  class_accessor :default_underline, :default_underline_full
  class_accessor :default_strikethrough, :default_strickthrough_full
  class_accessor :default_shadow, :default_shadow_color
  class_accessor :default_outline, :default_outline_color
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  if @yeyinde_font_alias.nil?
    alias_method :yeyinde_font_addons_initialize, :initialize
    @yeyinde_font_alias = true
  end
  #-------------------------------------------------------------------------
  # * Name:      Object Initialization
  #   Info:      Sets New Properties of Font
  #   Author:    Yeyinde
  #   Call Info: Zero - Two Arguments
  #              String name - name of the font
  #              Integer size - size of the font
  #-------------------------------------------------------------------------
  def initialize(*args)
    yeyinde_font_addons_initialize(*args)
    # Set Properties
    @underline = @@default_underline
    @underline_full = @@default_underline_full
    @strikethrough = @@default_strikethrough
    @strikethrough_full = @@default_strikethrough_full
    @shadow = @@default_shadow
    @shadow_color = @@default_shadow_color
    @outline = @@default_outline
    @outline_color = @@default_outline_color
  end
  #-------------------------------------------------------------------------
  # * Name:      Set Shadow
  #   Info:      Sets Shadow Flag
  #   Author:    Yeyinde
  #   Call Info: One Argument Boolean bool flag
  #-------------------------------------------------------------------------
  def shadow=(bool)
    @outline = false unless bool == false
    @shadow = bool
  end
  #-------------------------------------------------------------------------
  # * Name:      Set Outline
  #   Info:      Sets Outline Flag
  #   Author:    Yeyinde
  #   Call Info: One Argument Boolean bool flag
  #-------------------------------------------------------------------------
  def outline=(bool)
    @shadow = false unless bool == false
    @outline = bool
  end
  #-------------------------------------------------------------------------
  #   Name:      == (Comparision Equals)
  #   Info:      Compares two Fonts
  #   Author:    Trickster
  #   Call Info: One Argument Font other, Font to Check
  #   Returns:   True if all attributes are equal
  #-------------------------------------------------------------------------
  def ==(other)
    attr = %w( name size color bold italic underline underline_full strikethrough
    strikethrough_full shadow_color outline_color shadow outline )
    attr.each {|var| return false if eval("self.#{var} != other.#{var}")}
    return true
  end
end

class Bitmap
  #--------------------------------------------------------------------------
  # * Object Aliasing
  #--------------------------------------------------------------------------
  if @yeyinde_us_alias.nil?
    alias yeyinde_us_draw_text draw_text
    @yeyinde_us_alias = true
  end
  #-------------------------------------------------------------------------
  # * Name:      Draw Text (Underline and Strike Through)
  #   Info:      Draws Text (Underline and Strike Through)
  #   Author:    Yeyinde
  #   Call Info: Two,Three,Five or Siz Arguments
  #              Two Arguments: rect, str
  #                Rect rect for the text to be drawn
  #                String str text to be drawn
  #              Three Arguments: rect, str, align 
  #                Rect rect for the text to be drawn
  #                String str text to be drawn
  #                Integer align 0: left 1: center 2:right
  #              Five Arguments: x,y,width,height,str 
  #                Integer X and Y, Defines Position
  #                Width and Height, Defines Width and Hieght of the text drawn
  #                String str text to be drawn
  #              Six Arguments: x,y,width,height,str,align
  #                Integer X and Y, Defines Position
  #                Width and Height, Defines Width and Hieght of the text drawn
  #                String str text to be drawn
  #                Integer align 0: left 1: center 2:right
  #-------------------------------------------------------------------------
  def draw_text(*args)
    yeyinde_us_draw_text(*args)    
    if self.font.underline
      u_color = self.font.color.dup
      if args[0].is_a?(Rect)
        u_x = args[0].x
        u_y = args[0].y + args[0].height / 2 + self.font.size / 3
        if self.font.underline_full
          u_width = args[0].width
        else
          u_width = self.text_size(args[1]).width
          case args[2]
          when 1
            u_x += args[0].width / 2 - u_width / 2
          when 2
            u_x += args[0].width - u_width
          end
        end
      else
        u_x = args[0]
        u_y = args[1] + args[3] / 2 + self.font.size / 3
        if self.font.underline_full
          u_width = args[2]
        else
          u_width = self.text_size(args[4]).width
          case args[5]
          when 1
            u_x += args[2] / 2 - u_width / 2
          when 2
            u_x += args[2] - u_width
          end
        end
      end
      self.fill_rect(u_x, u_y, u_width, 1, u_color)
    end
    if self.font.strikethrough
      s_color = self.font.color.dup
      if args[0].is_a?(Rect)
        s_x = args[0].x
        s_y = args[0].y + args[0].height / 2
        if self.font.strikethrough_full
          s_width = args[0].width
        else
          s_width = self.text_size(args[1]).width
          case args[2]
          when 1
            s_x += args[0].width / 2 - s_width / 2
          when 2
            s_x += args[0].width - s_width
          end
        end
      else
        s_x = args[0]
        s_y = args[1] + args[3] / 2
        if self.font.strikethrough_full
          s_width = args[0].width
        else
          s_width = self.text_size(args[4]).width
          case args[5]
          when 1
            s_x += args[2] / 2 - s_width / 2
          when 2
            s_x += args[2] - s_width
          end
        end
      end
      self.fill_rect(s_x, s_y, s_width, 1, s_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Object Aliasing
  #--------------------------------------------------------------------------
  if @yeyinde_so_alias.nil?
    alias yeyinde_so_draw_text draw_text
    @yeyinde_so_alias = true
  end
  #-------------------------------------------------------------------------
  # * Name:      Draw Text (Shadow and Outline)
  #   Info:      Draws Text (Shadow and Outline)
  #   Author:    Yeyinde
  #   Call Info: Two,Three,Five or Siz Arguments
  #              Two Arguments: rect, str
  #                Rect rect for the text to be drawn
  #                String str text to be drawn
  #              Three Arguments: rect, str, align 
  #                Rect rect for the text to be drawn
  #                String str text to be drawn
  #                Integer align 0: left 1: center 2:right
  #              Five Arguments: x,y,width,height,str 
  #                Integer X and Y, Defines Position
  #                Width and Height, Defines Width and Hieght of the text drawn
  #                String str text to be drawn
  #              Six Arguments: x,y,width,height,str,align
  #                Integer X and Y, Defines Position
  #                Width and Height, Defines Width and Hieght of the text drawn
  #                String str text to be drawn
  #                Integer align 0: left 1: center 2:right
  #-------------------------------------------------------------------------
  def draw_text(*args)
    if self.font.shadow
      orig_color = self.font.color.dup
      self.font.color = self.font.shadow_color
      if args[0].is_a?(Rect)
        s_x = args[0].x + 2
        s_y = args[0].y + 2
        s_w = args[0].width
        s_h = args[0].height
        s_t = args[1]
        s_a = args[2]
      else
        s_x = args[0] + 2
        s_y = args[1] + 2
        s_w = args[2]
        s_h = args[3]
        s_t = args[4]
        s_a = args[5]
      end
      s_a = 0 if s_a.nil?
      self.yeyinde_so_draw_text(s_x, s_y, s_w, s_h, s_t, s_a)
      self.font.color = orig_color
    end
    if self.font.outline
      orig_color = self.font.color.dup
      self.font.color = self.font.outline_color
      if args[0].is_a?(Rect)
        o_x = args[0].x
        o_y = args[0].y
        o_w = args[0].width
        o_h = args[0].height
        o_t = args[1]
        o_a = args[2]
      else
        o_x = args[0]
        o_y = args[1]
        o_w = args[2]
        o_h = args[3]
        o_t = args[4]
        o_a = args[5]
      end
      o_a = 0 if o_a.nil?
      self.yeyinde_so_draw_text(o_x + 1, o_y, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x, o_y + 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x + 1, o_y + 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x + 1, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y + 1, o_w, o_h, o_t, o_a)
      self.font.color = orig_color
    end
    self.yeyinde_so_draw_text(*args)
  end
end

The part you'd want to edit is right here
Code:
      self.yeyinde_so_draw_text(o_x + 1, o_y, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x, o_y + 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x + 1, o_y + 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x + 1, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y - 1, o_w, o_h, o_t, o_a)
      self.yeyinde_so_draw_text(o_x - 1, o_y + 1, o_w, o_h, o_t, o_a)

Again the combination of the draw_text method being called every frame to draw every single character (which isn't good since draw_text is a time expensive method already) and then it calling it 8 times to draw the character is a contributing factor
 
Raiju;187592 said:
Your problem is you're drawing every character in a message 5 times in order to outline it - of course that's going to lag. It would be better to edit the font to make an outlined version and then switch to that font.

hmm.. I really cant understand.. or this message is not ment for me..?
Im not a scripter so I cant really understand the "youre drawing.. "

And BTW.. the lag problem occurs everytime I use \shk[0] << command on my messages.. Im using that to stop the shaking feature but since it cause lag I tried to stay away from window shaking feature of the UMS..

..Note: For me the \shk[0] only causes LAG when im using The UMS and Yiyende font effects together..
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top