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.

[VX] SephirothSpawn's Slanted Bars 1.1

SephirothSpawn's Slanted Bars in VX 1.1
by Kylock (Based on SephirothSpawn's Original Slanted Bars)

Inspired by Syvkal (http://rmvxpuniverse.com) who ported Cogwheel Style bars to VX, I realized how much I missed Seph's Slanted Bars.  So here they are.  Just add this script and it'll automagically transform your HP and MP bars.  Installation instructions are in the header of the script.

If you wanna know what it looks like, its pretty much like this:
http://i218.photobucket.com/albums/cc30 ... ntbars.png[/img]

Code:
#==============================================================================
# â–  SephirothSpawn's Slanted bars in VX
#     25.4.2008
#------------------------------------------------------------------------------
#  Script by: Kylock (Based on SephirothSpawn's Original Slanted Bars)
#==============================================================================
#    Inspired by Syvkal (http://rmvxpuniverse.com) who ported Cogwheel Style
#  bars to VX, I realized how much I missed Seph's Slanted Bars.  So here they
#  are.  Just add this script and it'll automagically transform your HP and MP
#  bars.  Bar colors are easily customized in the following module.
#==============================================================================
#  Change Log
#  1.0 - Original Release.
#  1.1 - Added option to use default window skin colors.
#==============================================================================

module SLANT_BARS
  USE_WINDOWSKIN = false  # If set to true, the colors will be taken from the
                          #  current system skin and the following settings
                          #  will be ignored.
  
  DEFAULT_HP_BAR_COLOR = Color.new(150,0,0,255)   # Beginning color of HP bar
  DEFAULT_HP_END_COLOR = Color.new(255,192,0,255) # Ending color of HP bar
  
  DEFAULT_MP_BAR_COLOR = Color.new(0,0,150,255)   # Begenning color of MP bar
  DEFAULT_MP_END_COLOR = Color.new(0,150,200,255) # Ending color of MP bar
end

class Window_Base < Window
  #==========================================================================
  # * Draw Slant Bar(by SephirothSpawn)
  #==========================================================================
  def draw_slant_bar(x, y, min, max, width = 152, height = 6, 
    bar_color = Color.new(150, 0, 0, 255), 
    end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, 
        Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1,
        Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1,
          Color.new(r, g, b, a))
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw HP gauge
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : Width
  #--------------------------------------------------------------------------
  def draw_actor_hp_gauge(actor, x, y, width = 131)
    if SLANT_BARS::USE_WINDOWSKIN
      draw_slant_bar(x-3,y+13,actor.hp,actor.maxhp,width,8,
        hp_gauge_color1,hp_gauge_color2)
    else
      draw_slant_bar(x-3,y+13,actor.hp,actor.maxhp,width,8,
        SLANT_BARS::DEFAULT_HP_BAR_COLOR,SLANT_BARS::DEFAULT_HP_END_COLOR)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw MP Gauge
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : Width
  #--------------------------------------------------------------------------
  def draw_actor_mp_gauge(actor, x, y, width = 131)
    if SLANT_BARS::USE_WINDOWSKIN
      draw_slant_bar(x-3,y+13,actor.mp,actor.maxmp,width,8,
        mp_gauge_color1,mp_gauge_color2)
    else
      draw_slant_bar(x-3,y+13,actor.mp,actor.maxmp,width,8,
        SLANT_BARS::DEFAULT_MP_BAR_COLOR,SLANT_BARS::DEFAULT_MP_END_COLOR)
    end
  end
end

If you have problems let me know, while I admit that I don't have all the free time in the world to help you out, I'll do what I can.  As far as distribution goes, post this everywhere you want, just make sure everyone gets their fair share of credit.  See the script header for credits - as a matter of fact, since it's all in the header, you should be safe.  If you profit commercially from this script, good for you!

Enjoy!
Kylock
 
Yeyinde":3tz02fyt said:
Why define the bar colours when you can just read them from the window skin, like the default ones?

Call it force of habit, but I enjoy keeping things as customizable as possible.  But since you bring it up, its a quick hack to make ANOTHER option  :thumb:

I suppose the not-so-easy answer:  I wrote it originally for myself, then released it.

Option added to use windowskin colors.  Updated version to 1.1

Enjoy.
 
I found a glitch in this script...
When you recover HP the SP bar fills up even though you didn't recover any SP.
 
I've never experienced this problem.  The script only replaces the methods that actually draw the bars.  The code has nothing to do with recovery...  When you recover HP, the game only redraws the bar...
 
Hmmm... I don't get that glitch when I'm not using this script... but I get your point...
maybe another script I have in my project is the problem...

EDIT* Nope... just finished using it in a new project with no custom scripts... the problem still persists >.>
 
Xemnas13":3vyolu8h said:
Hmmm... I don't get that glitch when I'm not using this script... but I get your point...
maybe another script I have in my project is the problem...

EDIT* Nope... just finished using it in a new project with no custom scripts... the problem still persists >.>

I found a type-o, its fixed now *facepalm*

Anyone whos using this in their game should reinstall the script from the top post.  What a silly bug...  thanks to Xemnas13 for catching it.
 
NP...  :smile:
I usually test scripts like crazy before I actually use em... sometimes I discover some unusual bugs that everyone else miss.
Thanks for fixing it... I'll definitely use it now.  :thumb:
 
Yes, I recognize the post above me's date, and this does not fall as a necro.

I noticed when using a HUD based on the bars, it appears in the slanted way as shown in this script, but causes a MASSIVE amount of lag - from 60 FPS all the way down to 1. Any way to fix this?
 

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