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.

Shadowed Text

Hello there.

I'm was wondering if anyone has/ can script me something that puts a shadow on the text in the DMS.

I've been looking for something like this, but have had no luck.

I'd really appreciate some help.

Thanks,
Mr. Ishbuu
 
I have a little script-ette that adds a few drawing styles into the RGSS system. It's old-school but should work nicely.

First, try adding this little script. I ripped it from one of my scripts. Also, the basics of this were originally created by Tsunokiette I think (don't quote me on that one), but expanded upon.

Code:
#------------------------------------------------------------------------------
#
# *  TEXT EFFECTS  *
#-------------------------------------------------------------------------------
# Draw Text with the newer text formats: Outlined, Raised and Shadowed, and any 
#                                        combination of the three.
#-------------------------------------------------------------------------------
#
# This class redefines the draw_text system to include outlined, raised and sha-
# dowed text styles.  
#
# Revised Syntax for draw_text:
#
#   Normal Text Call:
#     draw_text(x, y, wd, ht, text, align, style, outline, raised, shadow)
#     
#   Rectangle Text Call:
#     draw_text(rect, text, align, style)
#     - Can only use default colors using rect style drawing technique. -
#
# x & y   = coordinates to draw
#         
# wd & ht = size of drawing area
#
# rect    = rectangle to draw text (predefined x, y, wd, ht)
#         
# style   = how text should be shown. Default = 0 (normal text)
#           0 = Normal
#           1 = Outline Effect
#           2 = Raised Effect
#           3 = Shadowed Effect
#           4 = Raised Effect and Outlined
#           5 = Shadowed Effect and Outlined
#           6 = Raised Effect and Shadowed
#           7 = Raised, Shadowed and Outlined
#         
# The Colors:...
# outline = (default = black)        Color of outline drawn around text
# raised  = (default = medium gray)  Color of shadow right behind text
# shadow  = (default = dark gray)    Color of shadow spaced behind the text
#

#==============================================================================
# ** Bitmap (Default System/Script Edit)
#------------------------------------------------------------------------------
#  This class controls what is displayed on the screen
#==============================================================================
class Bitmap
  
  #--------------------------------------------------------------------------
  # * Alias Draw_Text (Use original "Draw_Text" command by calling as "Text"
  #--------------------------------------------------------------------------
  alias :text :draw_text
  
  #--------------------------------------------------------------------------
  # * Draw_Text
  #--------------------------------------------------------------------------
  def draw_text(x, y=nil, wd=0, ht=0, text=nil, align=0, style=0, 
      outline = Color.new(0, 0, 0, 255), raised = Color.new(96, 96, 96, 255),
      shadow = Color.new(0, 0, 0, 128))
  
    # If drawing with a rectangle command
    if x.is_a?(Rect)
      @x = x.x
      @y = x.y
      @wd = x.width
      @ht = x.height
      @text = y
      @align = wd
      @style = ht
      
    # If drawing with regular command  
    else
      @x = x
      @y = y
      @wd = wd
      @ht = ht
      @text = text
      @align = align
      @style =  style
    end
      
    # Perform drawing style
    case @style
    
    #--------------------------------------------------------------------------
    # * Normal Text
    #--------------------------------------------------------------------------
    when 0
      text(@x, @y, @wd, @ht, @text, @align)
           
    #--------------------------------------------------------------------------
    # * Outlined Effect
    #--------------------------------------------------------------------------
    when 1
      base_clr = font.color.dup
      font.color = outline
      text(@x+1, @y, @wd, @ht, @text, @align)
      text(@x-1, @y, @wd, @ht, @text, @align)
      text(@x, @y+1, @wd, @ht, @text, @align)
      text(@x, @y-1, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)

    #--------------------------------------------------------------------------
    # * Raised Effect
    #--------------------------------------------------------------------------
    when 2
      base_clr = font.color.dup
      font.color = raised
      text(@x+2, @y+2, @wd, @ht, @text, @align)
      text(@x+1, @y+1, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)

    #--------------------------------------------------------------------------
    # * Shadowed Effect
    #--------------------------------------------------------------------------
    when 3
      base_clr = font.color.dup
      font.color = shadow
      text(@x+4, @y+4, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)

    #--------------------------------------------------------------------------
    # * Raised Effect and Outlined
    #--------------------------------------------------------------------------
    when 4
      base_clr = font.color.dup
      font.color = raised
      text(@x+2, @y+2, @wd, @ht, @text, @align)
      text(@x+1, @y+1, @wd, @ht, @text, @align)
      font.color = outline
      text(@x+1, @y, @wd, @ht, @text, @align)
      text(@x-1, @y, @wd, @ht, @text, @align)
      text(@x, @y+1, @wd, @ht, @text, @align)
      text(@x, @y-1, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)
      
    #--------------------------------------------------------------------------
    # * Shadowed Effect and Outlined
    #--------------------------------------------------------------------------
    when 5
      base_clr = font.color.dup
      font.color = shadow
      text(@x+4, @y+4, @wd, @ht, @text, @align)
      font.color = outline
      text(@x+1, @y, @wd, @ht, @text, @align)
      text(@x-1, @y, @wd, @ht, @text, @align)
      text(@x, @y+1, @wd, @ht, @text, @align)
      text(@x, @y-1, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)
            
    #--------------------------------------------------------------------------
    # * Raised Effect and Shadowed
    #--------------------------------------------------------------------------
    when 6
      base_clr = font.color.dup
      font.color = shadow
      text(@x+4, @y+4, @wd, @ht, @text, @align)
      font.color = raised
      text(@x+2, @y+2, @wd, @ht, @text, @align)
      text(@x+1, @y+1, @wd, @ht, @text, @align)
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)      

    #--------------------------------------------------------------------------
    # * Raised, Shadowed and Outlined
    #--------------------------------------------------------------------------
    when 7
      base_clr = font.color.dup
      font.color = shadow
      text(@x+4, @y+4, @wd, @ht, @text, @align)
      font.color = raised
      text(@x+2, @y+2, @wd, @ht, @text, @align)
      text(@x+1, @y+1, @wd, @ht, @text, @align)
      font.color = outline
      text(@x+1, @y, @wd, @ht, @text, @align)
      text(@x-1, @y, @wd, @ht, @text, @align)
      text(@x, @y+1, @wd, @ht, @text, @align)
      text(@x, @y-1, @wd, @ht, @text, @align)      
      font.color = base_clr
      text(@x, @y, @wd, @ht, @text, @align)      
    end
  end

  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end
The script adds a few more options to the RGSS command 'draw_text', which now allows for different STYLES of text (outlines, shadows and etc), as well as how shadows and effects are colored (and there are default values too).

Styles
Code:
0 = Normal              4 = Raised Effect and Outlined
1 = Outline Effect      5 = Shadowed Effect and Outlined
2 = Raised Effect       6 = Raised Effect and Shadowed
3 = Shadowed Effect     7 = Raised, Shadowed and Outlined[/FONT]


The second part will require you to go into the system and begin to change values in your draw_text commands in sections like draw_actor_name, so you can apply the STYLES (or colors) you wanna use.

Example:
Code:
  def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, actor.name, [COLOR=RoyalBlue]0[/COLOR], [COLOR=RoyalBlue]5[/COLOR])
  end
The '0' after actor.name shows that the text is being drawn left-justified (as normal), and the '5' tells the system that the text will be drawn with Outlines AND Shadows. If I added some more to this statement, I could affect the colors of the outlines and shadows... didn't feel like it in this example.
 
Thanks :)
This works great but I came across a small problem.
When I select a hero after choosing one of the menu options, a small selection highlight bar appears, instead of one the highlights the entire hero.

Edit:
Even worse now.
I can't make all of the text have the same effect.
When I try, I keep getting errors where it says 'end' in the script.

I hate being a noob at scripting
 
Um Weird... I'm not getting any problems like that. The system is only editing the draw_text command and shouldn't interfere with any of the draw_rectangle_cursor calls in any way.

Just in case, I've prepared this little demo that changes a few of the texts around in the default menu with some of the features. It won't stay up here forever... as I already have this routine built into one of my posted scripts (if anyone cares to... try it out...? O_o ).

Cheapo demo.
 

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