Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Jragyn on September 02, 2008, 11:54:42 pm

Title: [RESOLVED, yo!] Vertical Bars!
Post by: Jragyn on September 02, 2008, 11:54:42 pm
Not really a major request in regards to what I need for game creation, but is there a vertical bar script out there? I figured due to the way I've rearranged things on my status screen, I could slap bars on the parameters and it wouldn't look have bad if they were -vertical-.
I can't figure it out.
Anyone have some spare time to help me with this?

--Jer
Title: Re: Bars left, bars right...bars up?
Post by: Ryex on September 08, 2008, 11:30:35 pm
sure thing I'll post tomorrow its a bit late now
Title: Re: Bars left, bars right...bars up?
Post by: Jragyn on September 11, 2008, 02:19:18 am
By no means am I a scripter of sorts, however, I have been able to figure out a few basic things, like window moving, font changing, colorizing, and so on to messing with what shows on the status screen, but those bars intimidate me beyond comprehension. I just don't get it.
If also possible, care to do a throw in a few steps as to how you did what you did? :D? Maybe someday I'll be answering requests, and others will be having questions...


--JeR
Title: Re: Bars left, bars right...bars up?
Post by: Ryex on September 11, 2008, 08:26:59 pm
ok here gose

this is a horizontal bar I pulled it from my Pokemon Script and added comments


class Window_Base < Window
  #----------------------------------------------------------------------------
  # x: x
  # y: y
  # m: max width
  # a: actor
  #----------------------------------------------------------------------------
  def draw_actor_hp_bar_ryex(x, y, m, actor)
    #seting things up
    gray = Color.new(100, 100, 100)
    h = 10
    p = actor.hp.to_f / actor.maxhp
    #draws the bar that is under the color bar that actually shows hp%
    self.contents.fill_rect(x, y, m, h, Color.new(0, 0, 0))
    for i in 0...(h - 2)
      ty = y + (h - 2) - i
      gr = gray.red * i / (h - 2)
      gg = gray.green * i / (h - 2)
      gb = gray.blue * i / (h - 2)
      #draws the bar for hp%
      self.contents.fill_rect(x + 1, ty, m - 2, 1, Color.new(gr, gg, gb, 192))
    end
    #this changes the color based on the hp% don't bother with it unless you want to it is not important
    if p > 0.5
      c = Color.new(0, 255, 0)
    elsif p < 0.1
      c = Color.new(255, 0, 0)
    elsif p < 0.5
      c = Color.new(255, 100, 0)
    end
    for i in 0...(h - 2)
      r = c.red * i / (h - 2)
      g = c.green * i / (h - 2)
      b = c.blue * i / (h - 2)
      self.contents.fill_rect(x + 1, y + i, p * (m - 2), 1, Color.new(r, g, b))
    end
  end
end



this is the difference for a vertical bar


class Window_Base < Window
  #----------------------------------------------------------------------------
  # x: x
  # y: y
  # m: max height
  # actor: actor
  #----------------------------------------------------------------------------
  def draw_actor_hp_bar_ryex(x, y, m, actor)
    #seting things up
    gray = Color.new(100, 100, 100)
    #width instead of height
    w = 10
    p = actor.hp.to_f / actor.maxhp
    #draws the bar that is under the color bar that actually shows hp% up and down
    self.contents.fill_rect(x, y, w, m, Color.new(0, 0, 0))
    #makes the gradient
    for i in 0...(w - 2)
      ty = y + (w - 2) - i
      gr = gray.red * i / (w - 2)
      gg = gray.green * i / (w - 2)
      gb = gray.blue * i / (w - 2)
      #draws the bar for hp% up and down
      self.contents.fill_rect(x + 1, ty, 1, m - 2, Color.new(gr, gg, gb, 192))
    end
    #this changes the color based on the hp% don't bother with it unless you want to it is not important
    if p > 0.5
      c = Color.new(0, 255, 0)
    elsif p < 0.1
      c = Color.new(255, 0, 0)
    elsif p < 0.5
      c = Color.new(255, 100, 0)
    end
    for i in 0...(h - 2)
      r = c.red * i / (h - 2)
      g = c.green * i / (h - 2)
      b = c.blue * i / (h - 2)
      self.contents.fill_rect(x + 1, y + i, 1, p * (m - 2), Color.new(r, g, b))
    end
  end
end


I have not actually tested the vertical code But I'm sure it works
Title: Re: Bars left, bars right...bars up?
Post by: Jragyn on September 12, 2008, 02:47:14 am
Stand alone, I could not get the code to work at all.  Either nothing happened, or it popped up with a message box that had no writing in it, and only allowed the pressing of 'ok'.
So I downloaded your entire pokemon script to use within that!
After a few additional edits of h --> w, I...err...succeeded in getting a viewable result.
Though the bar does in fact go...vertical...it doesn't seem to function...quite like...
the horizontal bars.
You should try it.
Maybe I just messed it up in my transition to:
Spoiler: ShowHide
def draw_actor_hp_bar_ryex(x, y, m, actor)
    #seting things up
    gray = Color.new(100, 100, 100)
    #width instead of height
    w = 10
    p = actor.hp.to_f / actor.maxhp
    #draws the bar that is under the color bar that actually shows hp% up and down
    self.contents.fill_rect(x, y, w, m, Color.new(0, 0, 0))
    #makes the gradient
    for i in 0...(w - 2)
      ty = y + (w - 2) - i
      gr = gray.red * i / (w - 2)
      gg = gray.green * i / (w - 2)
      gb = gray.blue * i / (w - 2)
      #draws the bar for hp% up and down
      self.contents.fill_rect(x + 1, ty, 1, m - 2, Color.new(gr, gg, gb, 192))
    end
    #this changes the color based on the hp% don't bother with it unless you want to it is not important
    if p > 0.5
      c = Color.new(0, 255, 0)
    elsif p < 0.1
      c = Color.new(255, 0, 0)
    elsif p < 0.5
      c = Color.new(255, 100, 0)
    end
    for i in 0...(w - 2)
      r = c.red * i / (w - 2)
      g = c.green * i / (w - 2)
      b = c.blue * i / (w - 2)
      self.contents.fill_rect(x + 1, y + i, 1, p * (m - 2), Color.new(r, g, b))
    end
  end
end

Unless you really have the time to spare, or are curious enough, you don't have to pursue this any further. This was just a curiousity I had, and was hoping it would be easy as cake.
Thanks though, mister ryex   :haha:
Title: Re: Bars left, bars right...bars up?
Post by: Ryex on September 15, 2008, 06:52:47 pm
well stand alone it dose nothing just adds the method to window base to use it you have to call it...

oh and I know why it dose not work right I for got to change some things...

here this should modify the default status screen to use them.

Spoiler: ShowHide

class Window_Base < Window
  #----------------------------------------------------------------------------
  # x: x
  # y: y
  # m: max height
  # actor: actor
  #----------------------------------------------------------------------------
  def draw_actor_hp_bar_ryex_v(x, y, m, actor)
    #seting things up
    gray = Color.new(100, 100, 100)
    #width instead of height
    w = 10
    p = actor.hp.to_f / actor.maxhp
    #draws the bar that is under the color bar that actually shows hp% up and down
    self.contents.fill_rect(x, y, w, m, Color.new(0, 0, 0))
    #makes the first under gradient
    for i in 0...(w - 2)
      gr = gray.red * i / (w - 2)
      gg = gray.green * i / (w - 2)
      gb = gray.blue * i / (w - 2)
      #draws the bar under the hp% up and down
      self.contents.fill_rect(x + 1 + i, y + 1, 1, m - 2, Color.new(gr, gg, gb, 192))
    end
    #this changes the color based on the hp% don't bother with it unless you want to it is not important
    if p > 0.5
      c = Color.new(0, 255, 0)
    elsif p < 0.1
      c = Color.new(255, 0, 0)
    elsif p < 0.5
      c = Color.new(255, 100, 0)
    end
    for i in 0...(w - 2)
      r = c.red * i / (w - 2)
      g = c.green * i / (w - 2)
      b = c.blue * i / (w - 2)
      self.contents.fill_rect(x + 1 + i, y + 1, 1, p * (m - 2), Color.new(r, g, b))
    end
  end
end

class Window_Status < Window_Base

def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 112)
    draw_actor_name(@actor, 4, 0)
    draw_actor_class(@actor, 4 + 144, 0)
    draw_actor_level(@actor, 96, 32)
    draw_actor_state(@actor, 96, 64)
    draw_actor_hp_bar_ryex_v(50, 112, 120, @actor)
    draw_actor_hp(@actor, 96, 112, 172)
    draw_actor_sp(@actor, 96, 144, 172)
    draw_actor_parameter(@actor, 96, 192, 0)
    draw_actor_parameter(@actor, 96, 224, 1)
    draw_actor_parameter(@actor, 96, 256, 2)
    draw_actor_parameter(@actor, 96, 304, 3)
    draw_actor_parameter(@actor, 96, 336, 4)
    draw_actor_parameter(@actor, 96, 368, 5)
    draw_actor_parameter(@actor, 96, 400, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 48, 80, 32, "EXP")
    self.contents.draw_text(320, 80, 80, 32, "NEXT")
    self.contents.font.color = normal_color
    self.contents.draw_text(320 + 80, 48, 84, 32, @actor.exp_s, 2)
    self.contents.draw_text(320 + 80, 80, 84, 32, @actor.next_rest_exp_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 160, 96, 32, "equipment")
    draw_item_name($data_weapons[@actor.weapon_id], 320 + 16, 208)
    draw_item_name($data_armors[@actor.armor1_id], 320 + 16, 256)
    draw_item_name($data_armors[@actor.armor2_id], 320 + 16, 304)
    draw_item_name($data_armors[@actor.armor3_id], 320 + 16, 352)
    draw_item_name($data_armors[@actor.armor4_id], 320 + 16, 400)
  end
end



I know the code works now I refined it, the bars fill from the top if you want I can make them fill from the bottom thought that is more complex. all I did to Window_Status is add one line to call the bar method.

enjoy!
Title: Re: Bars left, bars right...bars up?
Post by: Jragyn on September 16, 2008, 11:46:25 am
Ahha!
This is it!
This is Vertical Bars!
From here I can make the wimpy modifications that will make it look unique.
Thank you, Ryex!

[RESOLVED, yo!]


--JeR