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.

problem whit Scene_Menu and Scene_Map

WiZ`

Member

Scene_Map

mmm... let's see if i can explain the matter...

i need to make the spriteset_map scroll to the right, wile i creat an image and make it slide to the left, then the menù will be called... i don't know how to say it...

look at the event-command Scroll Map, that allow you to scroll the map in a direction for a distance whit a speed? like this, but simultaneally i wont an image to be created and make the same thing of the map, but to the left, and then to call the menù

the question is... is possible to scroll the map, not whit the event, but whit the script?

Scene_Menu
i've insert in my menù the Hp and Sp bar... but now there's a problem, i need an image to appear over the bars, and i don't know what to do :\

i've 2 bars (hp and sp) and an image, i need to draw these 2 bars and over them the image, help pls XD i don't know what to do X|
 
Well To scrool the maps It's something Like $game_map.scroll_direction(Amount)
Code:
$game_map.scroll_left(3) # scrolls 3X to the left

Now to display a Pictures you need a sprite:
Code:
my_sprite = Sprite.new
my_sprite.bitmap = RPG::Cache.picture("PICNAME") #LOADS form the Pictures folder the image

The Sprite can be used for all your needs, to scrool the image just keep changing the x/y from the sprite
in the Scene_Menu just set the x and y to be on top of your Bars, now don't forget to dispose the Sprite when you are done with it. In case you don't know it's:
Code:
my_sprite.dispose if !my_sprite.disposed? and my_sprite != nil
 

WiZ`

Member

mmm... i've try it... but... the bars are always over the image :\ and for the scroll... i need to put a wait command? becose i've put that code here

maybe you haven't understand, whit "an image over the bar" i'm talking about layer, or level, i need to put the image in an higher level then the bars, so i can use the image to cover the bars
Code:
    if Input.trigger?(Input::A)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_map.scroll_left(580)
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
but the map is scrolling all in a second, how can i set the time of the scroll? or the speed
could you explain yourself better... becose i'm not good at all whit the rgss : |
thanks ^^
 
I think it's because you are calling the menu in the same instante, try making the wait command as you said.

if you need further help just tell and I can probably throw some code at you.

Also to put the picture have the bars set their z coordinate to bigger number

Code:
dummy_sprite.z = 100 # changes the z coordinate
 

WiZ`

Member

mmm... for the map i don't know the command wait ^^ sorry... and for the image, i've tried to put the bars .z at 99 and the image .z at 100 but it doesn't work, the image is always under the bars, it's always covered bye them :\

EDIT: whit a big mess, don't esc me to discribe it... i really can't, to hard XD
i've set the image over the bars... but... there's still one problem... i need to set better the scroll, the distance is to the right, for (580) but it's to fast, i need it to be slower... how can i do?
 

WiZ`

Member

Code:
#==============================================================================
# ** COGWHEEL Plug 'n' Play Menu Bars (based on Syvkal's revisions)
#-------------------------------------------------------------------------------
# by DerVVulfman
# Version 1.1
# 06-28-06
#------------------------------------------------------------------------------
# This is a revision of Cogwheel's famous bargraph system, now set as an inser-
# table script to display bargraphs behind values in the menus.
#
# To prevent conflict with Cogwheel's RTAB system, two key definitions have been
# renamed: "gauge_rect" to "cw_gauge" & "gradation_rect" to "cw_grad_rect."
#
# 
# Affected Systems:  Main Menu
#                    Skill Menu
#                    Status Menu
#                    Hero Select Menu (for Items & Skills)
#                    Equipment Menu
#                    BattleStatus Menu
#                    
# The system uses a series of CONSTANTS that can be edited here.  They control
# the basic gauge colors and the manner the gauge is filled:

  # Gauge Border Colors
    COG_COLOR1 = Color.new(0, 0, 0, 0)         # Outer Border
    COG_COLOR2 = Color.new(255, 255, 192, 0)   # Inner Border
  # Gauge Empty filler
    COG_COLOR3 = Color.new(0, 0, 0, 255)         # Half of Inner Shading
    COG_COLOR4 = Color.new(0, 0, 0, 255)        # Half of Inner Shading
  # Alignment
    COG_ALIGN1 = 1    # Type 1: (0: Left / 1: Center / 2: Right Justify)
    COG_ALIGN2 = 2    # Type 2: (0: Upper / 1: Central / 2: Lower)
    COG_ALIGN3 = 0    # FILL ALIGNMENT (0: Left Justify / 1: Right Justify)
  # Gauge Settings
    COG_GRADE1 = 1    # EMPTY  gauge (0: Side / 1: Vertical / 2: Slanted)
    COG_GRADE2 = 0    # FILLER gauge (0: Side / 1: Vertical / 2: Slanted)


#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
#  This class handles the actor. It's used within the Game_Actors class
#  ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Get EXP - numeric for calculations
  #--------------------------------------------------------------------------  
  def now_exp
   return @exp - @exp_list[@level]
  end
  #--------------------------------------------------------------------------
  # * Get Next Level EXP - numeric for calculations
  #-------------------------------------------------------------------------- 
  def next_exp
   return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  end
  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end


#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
#  This class is for all in-game windows.
#==============================================================================

class Window_Base < Window
  
  
  #--------------------------------------------------------------------------
  # * Draw EXP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #--------------------------------------------------------------------------
  def draw_actor_expBar(actor, x, y, width = 204)
    if actor.next_exp != 0
      rate = actor.now_exp.to_f / actor.next_exp
    else
      rate = 1
    end
    # Calculate Bar Gradiation
    if actor.next_exp != 0
      rate = actor.now_exp.to_f / actor.next_exp
    else
      rate = 1
    end
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(80 * rate, 80 - 80 * rate ** 2, 80 - 80 * rate, 255)
    color2 = Color.new(240 * rate, 240 - 240 * rate ** 2, 240 - 240 * rate, 255)
    # Calculate Bar Width
    if actor.next_exp != 0
      exp = width * actor.now_exp / actor.next_exp
    else
      exp = width 
    end
    # Draw Bar Graph
    cw_gauge(x, y + 25, width, 11, exp, color1, color2)
  end  
  
  #--------------------------------------------------------------------------
  # * Draw HP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hpBar(actor, x, y, width = 140)
    # Calculate Bar Gradiation
    if actor.maxhp != 0
      rate = actor.hp.to_f / actor.maxhp
    else
      rate = 0
    end
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(186 - 24 * rate, 5 * rate, 0, 255)
    color2 = Color.new(317 - 72 * rate, 108 * rate, 88 * rate, 255)
    # Calculate Bar Width
    if actor.maxhp != 0
      hp = width * actor.hp / actor.maxhp
    else
      hp = 0
    end
    # Draw Bar Graph
    cw_gauge(x, y + 25, width, 10, hp, color1, color2)
  end 
  
  #--------------------------------------------------------------------------
  # * Draw HP Battle w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hpBar_battle(actor, x, y, width = 60)
    # Calculate Bar Gradiation
    if actor.maxhp != 0
      rate = actor.hp.to_f / actor.maxhp
    else
      rate = 0
    end
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 255)
    color2 = Color.new(327 - 72 * rate, 224 * rate, 77 * rate, 255)
    # Calculate Bar Width
    if actor.maxhp != 0
      hp = width * actor.hp / actor.maxhp
    else
      hp = 0
    end
    # Draw Bar Graph
    cw_gauge(x, y + 25, width, 10, hp, color1, color2)
  end

  #--------------------------------------------------------------------------
  # * Draw SP w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_spBar(actor, x, y, width = 140)
    # Calculate Bar Gradiation
    if actor.maxsp != 0
      rate = actor.sp.to_f / actor.maxsp
    else
      rate = 1
    end  
    # Adjust Bar Color based on Gradiation
    color1 = Color.new(136 - 24 * rate, 72 * rate, 14 * rate, 255)
    color2 = Color.new(327 - 72 * rate, 224 * rate, 77 * rate, 255)
    # Calculate Bar Width
    if actor.maxsp != 0
      sp = width * actor.sp / actor.maxsp
    else
      sp = width  
    end
    # Draw Bar Graph
    cw_gauge(x + width * 0 / 100, y + 25, width, 10, sp, color1, color2)
  end

  #--------------------------------------------------------------------------
  # * Draw Parameter w/ Bars
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6) 
  #--------------------------------------------------------------------------
  def draw_actor_parameterBar(actor, x, y, type)
    # Choose Color & Parameter Type
    case type
    when 0
      e1 = actor.atk
      c6 = Color.new(253, 53, 56, 192)
      c5 = Color.new(242, 2, 6, 192)
    when 1
      e1 = actor.pdef
      c6 = Color.new(238, 254, 124, 192)
      c5 = Color.new(228, 253, 48, 192)
    when 2
      e1 = actor.mdef
      c6 = Color.new(150, 37, 184, 192)
      c5 = Color.new(170, 57, 204, 192)
    when 3
      e1 = actor.str
      c6 = Color.new(253, 163, 33, 192)
      c5 = Color.new(254, 209, 154, 192)
    when 4
      e1 = actor.dex
      c6 = Color.new(255, 255, 255, 192)
      c5 = Color.new(222, 222, 222, 192)
    when 5
      e1 = actor.agi
      c6 = Color.new(124, 254, 155, 192)
      c5 = Color.new(33, 253, 86, 192)
    when 6
      e1 = actor.int
      c6 = Color.new(119, 203, 254, 192)
      c5 = Color.new(8, 160, 253, 192)
    end 
    # Calculate Bar Gradiation
    e2 = 999
    if e1.to_f != 0
      rate = e1.to_f / e2.to_f
    else
      rate = 1
    end
    # Adjust Bar Color based on Gradiation & Parameter Type
    for i in 0..7
      r = c6.red * rate
      g = (c6.green - 10) * rate
      b = c6.blue  * rate
      a = c6.alpha
    end
    # Calculate Bar Width
    width = 168
    if e1.to_f != 0
      par = width * e1.to_f / e2.to_f
    else
      par = width
    end
    # Equipment Calc Fix    
    case type
    when 0
      if e1 == 0
        par = 0
      end
    when 1
      if e1 == 0
        par = 0
      end
    when 2
      if e1 == 0
        par = 0
      end
    end
    # Draw Bar Graph
    cw_gauge(x , y + 25, width, 7, par, c5, Color.new(r, g, b, a))
  end

  #--------------------------------------------------------------------------
  # * Gauge Rectangle (New to Class)
  #--------------------------------------------------------------------------
  def cw_gauge(x, y, width, height, gauge, color1, color2)

    # Use Cogwheel PRESETS
    color3 = COG_COLOR1
    color4 = COG_COLOR2
    color5 = COG_COLOR3
    color6 = COG_COLOR4
    align1 = COG_ALIGN1
    align2 = COG_ALIGN2
    align3 = COG_ALIGN3
    grade1 = COG_GRADE1
    grade2 = COG_GRADE2
    
    # Create Rectangle Width based on gauge max.
    rect_width = width
    
    case align1
    when 1
      x += (rect_width - width) / 2
    when 2
      x += rect_width - width
    end
    case align2
    when 1
      y -= height / 2
    when 2
      y -= height
    end
    bitmap = RPG::Cache.windowskin("011-Menu[Sts].PNG")
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.fill_rect(x, y, width, height, color3)
    self.contents.fill_rect(x + 1, y + 1, width - 2, height - 2, color4)
    if align3 == 0
      if grade1 == 2
        grade1 = 3
      end
      if grade2 == 2
        grade2 = 3
      end
    end
    if (align3 == 1 and grade1 == 0) or grade1 > 0
      color = color5
      color5 = color6
      color6 = color
    end
    if (align3 == 1 and grade2 == 0) or grade2 > 0
      color = color1
      color1 = color2
      color2 = color
    end
    self.contents.cw_grad_rect(x + 2, y + 2, width - 4, height - 4, color5, color6, grade1)
    if align3 == 1
      x += width - gauge
    end
    self.contents.cw_grad_rect(x + 2, y + 2, gauge - 4, height - 4, color1, color2, grade2)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 140, 10))
  end
  
  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end


#==============================================================================
# ** Bitmap
#==============================================================================
class Bitmap

  #--------------------------------------------------------------------------
  # * Gradation Rectangle
  #--------------------------------------------------------------------------
  def cw_grad_rect(x, y, width, height, color3, color4, align = 0)
   if align == 0
     for i in x...x + width
       red   = color3.red + (color4.red - color3.red) * (i - x) / (width - 1)
       green = color3.green +
               (color4.green - color3.green) * (i - x) / (width - 1)
       blue  = color3.blue +
               (color4.blue - color3.blue) * (i - x) / (width - 1)
       alpha = color3.alpha +
               (color4.alpha - color3.alpha) * (i - x) / (width - 1)
       color = Color.new(red, green, blue, alpha)
       fill_rect(i, y, 1, height, color)
     end
   elsif align == 1
     for i in y...y + height
       red   = color3.red +
               (color4.red - color3.red) * (i - y) / (height - 1)
       green = color3.green +
               (color4.green - color3.green) * (i - y) / (height - 1)
       blue  = color3.blue +
               (color4.blue - color3.blue) * (i - y) / (height - 1)
       alpha = color3.alpha +
               (color4.alpha - color3.alpha) * (i - y) / (height - 1)
       color = Color.new(red, green, blue, alpha)
       fill_rect(x, i, width, 1, color)
     end
   elsif align == 2
     for i in x...x + width
       for j in y...y + height
         red   = color3.red + (color4.red - color3.red) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         green = color3.green + (color4.green - color3.green) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         blue  = color3.blue + (color4.blue - color3.blue) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         alpha = color3.alpha + (color4.alpha - color3.alpha) *
                 ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         color = Color.new(red, green, blue, alpha)
         set_pixel(i, j, color)
       end
     end
   elsif align == 3
     for i in x...x + width
       for j in y...y + height
         red   = color3.red + (color4.red - color3.red) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         green = color3.green + (color4.green - color3.green) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         blue  = color3.blue + (color4.blue - color3.blue) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         alpha = color3.alpha + (color4.alpha - color3.alpha) *
               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
         color = Color.new(red, green, blue, alpha)
         set_pixel(i, j, color)
       end
     end
   end
 end
 
  #--------------------------------------------------------------------------
  # * End of Class
  #--------------------------------------------------------------------------
end
the image over the bars are at line 297 - 298 - 324 i think.... but... look... i've use the same command for the icon in the item section of the menù ^^ and it'd work :) nice isn't it? ^^ now... for the second problem XD the speed of the scroll
 

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