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] Exp Bar in Window_MenuStatus

teth

Member

Exp bar in Window_MenuStatus
Version: 1.1
By: Teth

Introduction

This script show exp bar in Window_MenuStatus
*There was error made by me ^^ script is now ok*

Information
Version 1.1 - Percentage exp text made :)
Added demo

Screenshots

9c8785c0.bmp


Demo

Argh... take it ^^ http://www.speedyshare.com/300862514.html

Script

Code:
 

  

#==============================================================================

# â–  Window_MenuStatus

# Script made by Teth

#==============================================================================

 

class Window_MenuStatus < Window_Selectable

  #--------------------------------------------------------------------------

  # * Object Initialization

  #     x : window X coordinate

  #     y : window Y coordinate

  #--------------------------------------------------------------------------

  def initialize(x, y)

    super(x, y, 384, 416)

    refresh

    self.active = false

    self.index = -1

  end

  #--------------------------------------------------------------------------

  # ● Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    @item_max = $game_party.members.size

    for actor in $game_party.members

    draw_actor_face(actor, 2, actor.index * 96 + 2, 92)

    x = 104

    y = actor.index * 96 + WLH / 2

    draw_actor_name(actor, x, y)

    draw_actor_class(actor, x + 120, y - 13)

    draw_actor_level(actor, x, y + WLH * 1)

    draw_actor_state(actor, x, y + WLH * 2)

    draw_actor_hp(actor, x + 120, y + WLH * 1 - 13)

    draw_actor_mp(actor, x + 120, y + WLH * 2 - 13)

    draw_actor_expbar(actor, x + 120, y + WLH * 3 - 13)

    end

  end

end

  #--------------------------------------------------------------------------

  # ● Update

  #--------------------------------------------------------------------------

    def update_cursor

    if @index < 0 # カーソルなし

      self.cursor_rect.empty

        elsif @index < @item_max # 通常

          self.cursor_rect.set(0, @index * 96, contents.width, 96)

            elsif @index >= 100 # 自分

              self.cursor_rect.set(0, (@index - 100) * 96, contents.width, 96)

            else # 全体

              self.cursor_rect.set(0, 0, contents.width, @item_max * 96)

  end

end

  #--------------------------------------------------------------------------

  # ● Actor expbar code

  #--------------------------------------------------------------------------

  def draw_actor_expbar(actor, x, y, width = 120)

    draw_actor_exp_gauge(actor, x, y)

    s1 = actor.exp_s - actor.current_lvl_exp

    s2 = actor.next_lvl_exp

    s3 = 100*s1/s2

    self.contents.font.color = system_color

    self.contents.draw_text(x, y, 40, Window_Base::WLH, 'Exp')

    self.contents.font.color = hp_color(actor)

    last_font_size = self.contents.font.size

    xr = x + width

    if width < 120

      self.contents.draw_text(xr - 44, y, 34, Window_Base::WLH, s3, 2)

    else

      self.contents.draw_text(xr - 89, y, 34, Window_Base::WLH, s3, 2)

      self.contents.font.color = normal_color

      self.contents.draw_text(xr - 55, y, 11, Window_Base::WLH, "%", 2)

    end

  end

 

  def draw_actor_exp_gauge(actor, x, y, width = 120)

      color_behind = Color.new(39, 58, 83, 255)

      exp_color = Color.new(0, 200, 0, 255)

      nextexp_color = Color.new(0, 100, 0, 255)

      s1 = actor.exp_s

      s2 = actor.current_lvl_exp

      level = actor.level

    if level != 99 #For avoid Fixnum bug

      s3 = s1-s2

      s4 = actor.next_lvl_exp

      self.contents.fill_rect(x, y + Window_Base::WLH - 8,width,6,color_behind)

      self.contents.gradient_fill_rect(x, y + Window_Base::WLH - 8,(width*s3)/s4,6,exp_color,nextexp_color)

    else

      self.contents.gradient_fill_rect(x, y + Window_Base::WLH - 8,width,6,exp_color,nextexp_color)

    end

  end

 

  #--------------------------------------------------------------------------

  # ● End of expbar code

  #--------------------------------------------------------------------------

 

#==============================================================================

# ** Game_Actor

#------------------------------------------------------------------------------

# This class handles actors. It's used within the Game_Actors class

# ($game_actors) and referenced by the Game_Party class ($game_party).

#==============================================================================

 

class Game_Actor < Game_Battler

 

  #--------------------------------------------------------------------------

  # ● Two needed defs ^^

  #--------------------------------------------------------------------------

  def current_lvl_exp

    return @exp_list[@level]

  end

 

  def next_lvl_exp

    return @exp_list[@level+1]-@exp_list[@level]

    end

  end

Instructions

Just place it above main

Compatibility

This script overwrites Window_MenuStatus

Credits and Thanks

Thanks to Tavoeltav for request
 

teth

Member

Thanks for comments and ye i know that what you said Diedrupo :P
I was trying to make a percents but i get bugged ^^
I'll try to make percents so this will look better (maybe)

@edit
Right 1.1 now ^^ I've made this percentage exp text
 
Okay, I'm going to use this for my project, but I changed the text on the bar to XP rather than Exp, are you okay with that?
 
It's a cool script...

One question... How long did it take you to learn Ruby, and where did you learn it? :blank:

I want to follow in your footsteps...
 

teth

Member

@Mustardy85
Thanks for your com ^^ You've made me smile first time in this week xD
Not long ^^ About 2-3 weeks from start learning to make this script. I have book "Ruby. Programming" wrote by creator of Ruby :)
And you must just need to learn it :) Ruby isn't that hard lang. As Matz said thats something between hard and easy language (btw. before i was learning some langs too cuz you have to know even something to know what do you read in this book xD). And read some scripts on this forum to see how everything works in RGSS and how to use ruby.
@Soupnazi
Don't worry. If you want to change it - just change ^^
@Kaze5115
No demo is needed to this script (but i've added) ^^ Just place this above main. If you don't know how read :
-Press F11 when you have opened your project in rmvx
-Go on down of list of scripts
-Above "main" you'll have "Materials"
-Click under this "Materials" and press insert
-Copy my script then get to your project and paste it in this big white place
-Click "Apply" and "Ok" or only "Ok" ^^
-Save your project and press F12 to test your game then choose "New Game"
-Then press ESC to look result ^^

Sry that i haven't responded for that big time but i was taking rest ^^
 

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