Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Shaded Text Script, VX-style... but better
Feedback (minimalized)
Good, bad, or ugly? (In terms of scripting)
Good [ 2 ] ** [100.00%]
Bad [ 0 ] ** [0.00%]
Ugly [ 0 ] ** [0.00%]
Would you use this in your project?
Sure! [ 1 ] ** [50.00%]
Some of them... [ 0 ] ** [0.00%]
No, thanks. [ 1 ] ** [50.00%]
Total Votes: 4
  
TheBen
post Sep 2 2011, 09:31 AM
Post #1


Intolerable Noob
Group Icon

Group: Revolutionary
Posts: 344
Type: Developer
RM Skill: Beginner




TheBen's Shaded Text Script
Version 1.0


Description
A rather subtle edit that adds a drop shadow to any text in the game. Unlike VX, however, you can control the color, offset, and relative opacity of the shadow itself.

Screenshot


The Script

CODE
#-------------------------------------------------------------------------------
#Shadowed Text Edit
#  TheBen | V1.0
#-------------------------------------------------------------------------------
#  ABSTRACT
#Edits the draw_text command to add VX-esque shadows to your game's text.
#Be forewarned that this does require the system to draw twice as much
#text as usual (drawing text is said to be a CPU-intensive method).
#-------------------------------------------------------------------------------
#  COMPATABILITY
#  Will seriously mess up any scripts of this nature (or of the outlined-text
#  nature).  Otherwise, it's pretty much good to go.
#-------------------------------------------------------------------------------
#  CUSTOMIZATION
module SHADOWTEXT
  #                 r, g, b
  COLOR = Color.new(0, 0, 0) #The color used for shadows. (0-255 each)
  OPAC_PERCENT = 50 #Percentage of opacity based on current font opac. (0-100)

  #Shadow Offset
  XOFFSET = 2 #X offset of the shadow, in pixels. (Right -> positive)
  YOFFSET = 2 #Y offset of the shadow, in pixels. (Down -> positive)
end
#-------------------------------------------------------------------------------
#Bitmap Edit - adds shaded text
class Bitmap
  #Aliased method - shaded text for pretty much everything
  alias ben_shaded_draw_text draw_text unless $@
  def draw_text(*args)
    return if self.font.color.alpha == 0
    #Color Memorization
    memo_color = self.font.color.dup #Memorized for frontal text
    self.font.color = SHADOWTEXT::COLOR
    self.font.color.alpha = memo_color.alpha*(SHADOWTEXT::OPAC_PERCENT.to_f/100)
    
    #Drawing Shadow
    if args[0].class == Rect #Rect Arguments
      pos = args[0].dup
      pos.x += SHADOWTEXT::XOFFSET
      pos.y += SHADOWTEXT::YOFFSET
      ben_shaded_draw_text(pos, *args[1...args.length])
    else #X-Y-Width-Height arguments
      pos = args[0..1]
      pos[0] += SHADOWTEXT::XOFFSET
      pos[1] += SHADOWTEXT::YOFFSET
      ben_shaded_draw_text(pos[0], pos[1], *args[2...args.length])
    end
    #Drawing regular text
    self.font.color = memo_color
    ben_shaded_draw_text(*args)
  end
  
  #New method - drawing text without shadows
  def draw_text_reg(*args)
    ben_shaded_draw_text(*args)
  end
  
end


Compatibility
This will probably work with all scripts, but just to be safe, you might want to put this below any other text-altering scripts you have (e.g. text outline).

Credit and Redistribution
Credit is not necessary for this script, but it is highly appreciated. If you wish to distribute this script outside of RPGRevolution.com, PM me and I'll try and work it out with you.

Please rate, comment and provide criticism as you wish.


__________________________
QUOTE
Great people talk about IDEAS
Average people talk about THINGS
Small people talk about OTHER PEOPLE

- A plaque on a BBQ restaurant in VA
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 09:01 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker