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.

Experience Bar

Experience BAR
Title: Experience BAR
RMXP:
Description:
I want to add a experience bar on map windows. Actually I'm using an HP/SP bar and want too add a third bar (experience bar).
imagen1wr0.jpg
HP/SP script i'm using:
#Script Creado por UliK
#-----------------------------------------------------------------
class Scene_Map
#-----------------------------------------------------------------
alias sk_bar_main main
def main
@bars = Window_Sk_Bars.new
sk_bar_main
@bars.dispose if @bars != nil
end
#-----------------------------------------------------------------
alias sk_bar_update update
def update
@bars.update
sk_bar_update
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
def sk_initialize(font=0,size=15)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#-----------------------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Sk_Bars < Window_Base
#-----------------------------------------------------------------
def initialize
super(444,-8,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#-----------------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
draw_text_outline(5,-6,64,26,"HP")
draw_actor_hp(actor,30,0)
end
#-----------------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.hp / actor.maxhp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 5, white)

# Black back
self.contents.fill_rect(x+2, y, width-4, 3, black)

# Generating the color
val = 255 * ((actor.hp*100)/actor.maxhp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(255,green+32,96,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 3, w_color)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------

#-----------------------------------------------------------------
class Scene_Map
#-----------------------------------------------------------------
alias sk_bar_main2 main
def main
@bars2 = Window_mk_Bars.new
sk_bar_main2
@bars2.dispose if @bars2 != nil
end
#-----------------------------------------------------------------
alias sk_bar_update2 update
def update
@bars2.update
sk_bar_update2
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
def sk_initialize2(font=0,size=22)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#-----------------------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
class Window_mk_Bars < Window_Base
#-----------------------------------------------------------------
def initialize
super(444,5,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#-----------------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
draw_text_outline(5,-6,64,26,"SP")
draw_actor_hp(actor,30,0)
end
#-----------------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.sp / actor.maxsp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 5, white)

# Black back
self.contents.fill_rect(x+2, y, width-4, 3, black)

# Generating the color
val = 255 * ((actor.sp*100)/actor.maxsp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(150,green-32,255,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 3, w_color)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------

Ty for your time,
 
VarietyVidsnet":x2ecja13 said:
I am no genius scripter but why don't you edit the variables and the color so that it shows EXP right under SP?

I tried but with no results:

Code:
w = width * actor.hp / actor.maxhp

# White border

self.contents.fill_rect(x+1, y-1, width-2, 5, white)

I supose that changing actor.hp/Actor.maxhp --> actor.xp/actor.maxxp is the trick, but both actor.xp and actormaxxp don´t exist. I'm searching the code to find actor.xp variable or similar with not success.
 
HP/SP/XP bars code
#Script Creado por UliK
#Experiencia modificada por Dwellercoc
class Scene_Map
#-------------------------------------------------
alias sk_bar_main main
def main
@bars = Window_Sk_Bars.new
sk_bar_main
@bars.dispose if @bars != nil
end
#------------------------------------------------
alias sk_bar_update update
def update
@bars.update
sk_bar_update
end
#------------------------------------------------
end
#-------------------------------------------------
class Window_Base < Window
#------------------------------------------------------
def sk_initialize(font=0,size=15)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#---------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#-------------------------------------------------------
end
#--------------------------------------------------------
class Window_Sk_Bars < Window_Base
#-------------------------------------------------------
def initialize
super(40,-8,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#--------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
draw_text_outline(5,-6,64,26,"HP")
draw_actor_hp(actor,30,0)
end
#--------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.hp / actor.maxhp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 5, white)

# Black back
self.contents.fill_rect(x+2, y, width-4, 3, black)

# Generating the color
val = 255 * ((actor.hp*100)/actor.maxhp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(255,green+32,96,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 3, w_color)
end
#-------------------------------------------------
end
#---------------------------------------------------

#----------------------------------------------------
class Scene_Map
#----------------------------------------------------
alias sk_bar_main2 main
def main
@bars2 = Window_mk_Bars.new
sk_bar_main2
@bars2.dispose if @bars2 != nil
end
#--------------------------------------------------------
alias sk_bar_update2 update
def update
@bars2.update
sk_bar_update2
end
#------------------------------------------------
end
#-------------------------------------------------------
class Window_Base < Window
#--------------------------------------------------------
def sk_initialize2(font=0,size=22)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#---------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+1,w,h,str,a)
self.contents.draw_text(x,y-1,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#------------------------------------------------------
end
#----------------------------------------------------
class Window_mk_Bars < Window_Base
#---------------------------------------------------------
def initialize
super(40,5,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
draw_text_outline(5,-6,64,26,"SP")
draw_actor_hp(actor,30,0)
end
#--------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.sp / actor.maxsp
# White border
self.contents.fill_rect(x+1, y-1, width-2, 5, white)

# Black back
self.contents.fill_rect(x+2, y, width-4, 3, black)

# Generating the color
val = 255 * ((actor.sp*100)/actor.maxsp)
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(150,green-32,255,255)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 3, w_color)
end
#-----------------------------------------------------
end
#-----------------------------------------------------
#Barra de EXPERIENCIA
#----------------------------------------------------
class Scene_Map
#----------------------------------------------------
alias sk_bar_main3 main
def main
@bars3 = Window_xk_Bars.new
sk_bar_main3
@bars3.dispose if @bars3 != nil
end
#--------------------------------------------------------
alias sk_bar_update3 update
def update
@bars3.update
sk_bar_update3
end
#------------------------------------------------
end
#-------------------------------------------------------
class Window_Base < Window
#--------------------------------------------------------
def sk_initialize3(font=0,size=22)
font = "Tahoma" if font == 0
self.contents = Bitmap.new(self.width-32,self.height-32)
self.contents.font.name = font
self.contents.font.size = size
end
#---------------------------------------------------
def draw_text_outline(x,y,w,h,str,c=normal_color,a=0)
self.contents.font.color = Color.new(0,0,0,255)
self.contents.draw_text(x-1,y,w,h,str,a)
self.contents.draw_text(x+1,y,w,h,str,a)
self.contents.draw_text(x,y+2,w,h,str,a)
self.contents.draw_text(x,y-2,w,h,str,a)
self.contents.font.color = c
self.contents.draw_text(x,y,w,h,str,a)
end
#------------------------------------------------------
end
#----------------------------------------------------
class Window_xk_Bars < Window_Base
#---------------------------------------------------------
def initialize
super(40,18,206,96)
sk_initialize("Arial")
self.opacity = 0
end
#------------------------------------------------------
def update
self.contents.clear
actor = $game_party.actors[0]
draw_text_outline(5,-6,64,26,"XP")
draw_text_outline(35,6,64,26,actor.exp_s + "/" + actor.next_exp_s )
draw_actor_hp(actor,30,0)
end
#--------------------------------------------------------
def draw_actor_hp(actor,x,y)
width = 128
y += 4
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
w = width * actor.exp / actor.next_exp_s.to_f
# White border
self.contents.fill_rect(x+1, y-1, width-2, 5, white)

# Black back
self.contents.fill_rect(x+2, y, width-4, 3, black)

# Generating the color
val = 255 * ((actor.exp/100))
green = 255 - val/100
color = Color.new(224,green,0,255)
w_color = Color.new(150,green-32,5,74)
if green > 64 then green -= 32
elsif green > 128 then green -= 64 end
# Making the bar
self.contents.fill_rect(x+2, y, w-4, 3, w_color)
end
#-----------------------------------------------------
end
#-----------------------------------------------------
Image
322274-Sinttulo-1.jpeg
 

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