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.

[A] Simple Menu (easy) - Crepusculum

CERU

Member

Hi guys. I've been making Crepusculum, and I think the game could really benefit from a simplified menu. It's pretty, well, simple. Not that complicated. I DO have SDK, but I deleted the menu portion. My menu is now an edit of the original. If you would like to see the script for it, ask and I'll post it.

I've created an image to show what I want:

http://i109.photobucket.com/albums/n45/ ... PUMENU.png[/IMG]

1. The most important thing, is disabling a 2nd character from appearing in the menu. If someone could show me how to do this, that would be great (whether it be from adding it on, or modifying a previous part of the script.

2. Now, see those two pictures that simulate health and battery power? If someone would help me do this, I need it so that it will allow me to display images based on the HP or SP the character has (or a variable thats based on HP or SP). I'll be using four images each.

3. And I'll really love you if you can find a way to make the background transparent, so it shows what was going on when the game was paused.

You can do 1,2, or 3, but I need 1 the most. One way that I was thinking that this could be done would be by creating a new status window, that would only have Alexis and would be able to display the health images that I wanted.

If you can help me I'd greatly appreciate it!
 

CERU

Member

hima;135487 said:
Sorry for the late reply :'( I'll finish it tomorrow. The new trimester just started and I have so many documents to turn in so it pretty much took all my time @_@;

It's okay. I have a lot of schoolwork as well. I've been procrastinating. Hopefully I won't have as much homework when AP English goes away, but Japanese 4 might be a lot of work. >.<

Are you Japanese, Hima?
 
Replace this in Scene_Map

Code:
  #--------------------------------------------------------------------------
  # - Call of menu
  #--------------------------------------------------------------------------
  def call_menu
    $opacity = []
    for i in 1..50
    $opacity[i] = $game_screen.pictures[i].opacity
    $game_screen.pictures[i].move(0*2, $game_screen.pictures[i].origin, $game_screen.pictures[i].x, $game_screen.pictures[i].y, $game_screen.pictures[i].zoom_x, $game_screen.pictures[i].zoom_y, 0, $game_screen.pictures[i].blend_type)
    end
    tone = Tone.new(100,100,100,0)
    $game_screen.start_tone_change(tone,0 * 2)
    # Clearing the menu call flag
    $game_temp.menu_calling = false
    # When the menu SE performance flag is set
    if $game_temp.menu_beep
      # Performing decision SE
      $game_system.se_play($data_system.decision_se)
      # Clearing the menu SE performance flag
      $game_temp.menu_beep = false
    end
    # Reforming the attitude of the prayer
    $game_player.straighten
    # Change to menu screen
    $scene = Scene_Menu.new
  end

Replace the Game_Picture by this
Code:
  #--------------------------------------------------------------------------
  # - Movement of picture
  #     duration     : Time
  #     origin       : Starting point
  #     x            : X coordinate
  #     y            : Y coordinate
  #     zoom_x       : X direction enlargement ratio
  #     zoom_y       : Y direction enlargement ratio
  #     opacity      : Opacity
  #     blend_type   : Blend method
  #--------------------------------------------------------------------------
  def move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    @duration = duration
    @origin = origin
    @target_x = x.to_f
    @target_y = y.to_f
    @target_zoom_x = zoom_x.to_f
    @target_zoom_y = zoom_y.to_f
    @target_opacity = opacity.to_f
    @blend_type = blend_type
    if @duration == 0
      @x = @target_x
      @y = @target_y
      @zoom_x = @target_zoom_x
      @zoom_y = @target_zoom_y
      @opacity = @target_opacity
    end
  end

And finally, replace this in Scene_Menu

Code:
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
    tone = Tone.new(0,0,0,0)
    $game_screen.start_tone_change(tone,5 * 2)
    for i in 1..50
      $game_screen.pictures[i].move(5*2, $game_screen.pictures[i].origin, $game_screen.pictures[i].x, $game_screen.pictures[i].y, $game_screen.pictures[i].zoom_x, $game_screen.pictures[i].zoom_y, $opacity[i], $game_screen.pictures[i].blend_type)
    end

No, I'm not Japanese. I'm Thai :) But I studied Japanese many years ago. My Japanese is rusty now :(
 

CERU

Member

When I replace the frame update when command window is active portion, it says there is an error on the line where the last "end" is. However, if I use the old menu like the following code, it seems to work, so far.

Code:
#--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    $game_screen.update
    @command_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
    tone = Tone.new(0,0,0,0)
    $game_screen.start_tone_change(tone,5 * 2)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
end

Also, I've noticed that the health bar increases and decreases, but the battery bar in the menu does not.
 
Code:
   for i in 1..50
      $game_screen.pictures[i].move(5*2, $game_screen.pictures[i].origin, $game_screen.pictures[i].x, $game_screen.pictures[i].y, $game_screen.pictures[i].zoom_x, $game_screen.pictures[i].zoom_y, $opacity[i], $game_screen.pictures[i].blend_type)
    end

Add only these lines under the $game_screen.start_tone_change(tone,5 * 2)
and try again if it works or not :)

For the batter bar, you have to change the variable in Scene_Menu, which I think I wrote a comment in green letters. Change it into the variable you store the battery value :)
 

CERU

Member

Okay. What I haven't told you is that I made two tweaks when encountering errors to make the game run previously. I also was using a little of scene_menu and a new category, new_menu which probably caused problems.

I've pushed the two together now under the old scene_menu by redoing all the steps I've done so far.

Here is my scene_menu code:

Code:
#==============================================================================
# ** Window_ChaStat
#------------------------------------------------------------------------------
#  This class is to show character stat in Scene_Menu. We discard the old one.
#==============================================================================

class Window_ChaStat < Window_Base
  def initialize
    super(6, 138, 217, 142)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    refresh
  end
  
  def refresh
    self.contents.clear
    actor = $game_party.actors[0]
    x = 0
    y = 0
    draw_actor_graphic(actor, x+16, y+80)
    draw_actor_name(actor, x, y-10)
    draw_energy(actor,x+40,y+40)
    draw_battery($game_variables[1],x+40,y+80) #<== change $game_variables[1] into the variable that you hold the battery value.
    #Forexample, if the battery is hero's sp, then just replace it by "actor.sp" with no ""
  end
  #--------------------------------------------------------------------------
  # * Draw battery
  #     battery : variable that you hold the battery in.
  #--------------------------------------------------------------------------
   
  def draw_battery(battery,x,y)
    # Drawing battery bg
    bitmap = RPG::Cache.picture("battery_bg")
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+16, y, bitmap, src_rect)
    # Drawing battery according to the battery you have
    bitmap = RPG::Cache.picture("battery")
    cw = 25*battery
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+16, y, bitmap, src_rect)
  end
  #--------------------------------------------------------------------------
  # * Draw energy
  #     actor : The hero that you wanna show his/her energy. It will draw the
  #     health bar in percentage though :)
  #--------------------------------------------------------------------------
   
  def draw_energy(actor,x,y)
    # Drawing energy bg
    bitmap = RPG::Cache.picture("energy_bg")
    cw = bitmap.width
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+16, y, bitmap, src_rect)
    # Drawing energy
    bitmap = RPG::Cache.picture("energy")
    max = actor.maxhp
    hp = actor.hp
    percent = (hp.to_f/max.to_f) * 100.0
    cw = percent
    ch = bitmap.height
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x+16, y, bitmap, src_rect)
  end
end
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs menu screen processing.
#==============================================================================

class Scene_Menu
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     menu_index : command cursor's initial position
  #--------------------------------------------------------------------------
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @spriteset = Spriteset_Map.new
    # Make command window
    s1 = $data_system.words.item
    s2 = "End Game"
    @command_window = Window_Command.new(640, [s1, s2])
    @command_window.index = @menu_index
    # Make status window
    @status_window = Window_ChaStat.new
    @status_window.back_opacity = 250
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @command_window.dispose
    @status_window.dispose
    @spriteset.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    $game_screen.update
    @command_window.update
    @status_window.update
    # If command window is active: call update_command
    if @command_window.active
      update_command
      return
    end
    # If status window is active: call update_status
    if @status_window.active
      update_status
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when command window is active)
  #--------------------------------------------------------------------------
  def update_command
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to map screen
      $scene = Scene_Map.new
    tone = Tone.new(0,0,0,0)
    $game_screen.start_tone_change(tone,5 * 2)
       for i in 1..50
      $game_screen.pictures[i].move(5*2, $game_screen.pictures[i].origin, $game_screen.pictures[i].x, $game_screen.pictures[i].y, $game_screen.pictures[i].zoom_x, $game_screen.pictures[i].zoom_y, $opacity[i], $game_screen.pictures[i].blend_type)
    end
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If command other than save or end game, and party members = 0
      if $game_party.actors.size == 0 and @command_window.index < 4
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Branch by command window cursor position
      case @command_window.index
      when 0  # item
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to item screen
        $scene = Scene_Item.new
      when 1  # end game
        # Play decision SE
        $game_system.se_play($data_system.decision_se)
        # Switch to end game screen
        $scene = Scene_End.new
      end
      return
    end
  end
end

As you can see, the $fontsize line was deleted, in order to make it run and I also added another end .. at the end lol. It runs now, but the battery will NOT run properly.

If I switch it to the variable, it will only deplete boxes AFTER the entire thing is gone.

Code:
$game_variables[005]

If I am to change it to actor.sp, then how should this line look:

Code:
    draw_battery($game_variables[005],x+40,y+80)
 

CERU

Member

hima;144456 said:
Code:
draw_battery(actor.sp,x+40,y+80)
if you use sp as a battery

Code:
draw_battery($game_variables[5],x+40,y+80)
if you use game variables number 0005 as a battery :)

It IS tracking the SP depletion, but its doing it really strangely. Because it doesn't indicate that ANY of the battery power is gone until it is ALL gone. So the bar is either full, or empty.

Maybe we can change it to a percentage, like the health bar if this doesn't work?
 
It depends on how do you design the battery to be. If it's SP, you have to set it so that the MAX SP is 4 and everytime you use the weapon, the battery is decreased by one.

But if you want your battery to be something flexible, like 100 and it decreased 10 everytime you use it, and the guage show the percentage of the battery, then replace
Code:
    cw = 25*battery

by this
Code:
    cw = (battery.to_f/$game_party.actors[0].maxsp.to_f) * 100.0

Hope this help :D
 

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