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.

LMS Menu

LMS Menu Request

Hey. For those of you who don't know, for some time I have been working on a zombie game called Last Man's Stand. But something I've always needed is a custom menu. The one I'm using at the moment ( a custom edit of the default one) is ok... but it's still the default menu, really. I've tried to make it a lot more interesting, but it didn't really work. So I'd be really greatful if someone could help me out and script it.

I know that I could probably event it, but as everything else in the game (such as the HUD) is evented, I'm already pretty high on the picture count, and more conditional branches will make the game impossibly laggy. So that's why I need it scripted.

Design

Ok, this is the main design of the menu:

LMSMenu.png


As you can see, this is a quick mock up in paint, so I'm going to explain it.

The blue is where the map behind is shown.

The grey is the windowskin.

The black and white boxes are where the selection cursor is.

In the top left hand corner there are the player's stats. The face is just an image in the pictures folder. The red bar is the health bar, and the blue one is the infection metre. The health is obviously displayed according to the characters health, but the infection metre is a custom system, so that should be made to just read a variable. Both are out of 50.
To the right of that is a box that shows two other things. 'Location' is obviously the name of the map the player is on. Underneath there is 'Zombies Killed'. This is another variable. The number that variable is set to is displayed to the right.
In the bottom left corner, there is the selection window. Selecting 'Missions' takes you to another, premade scene. Don't worry about that. 'Save' obviously takes you to the default save menu, and the same with Exit, taking you to the end window.
Selecting 'Inventory' is where the menu gets a little more complicated. When you select Inventory, the large middle window becomes active, and the selection window is deactivated. In this middle window is all the items and weapons you have in your inventory. Each are represented by a picture in the Pictures folder that is the same name as the item or weapon. The name, and the description of the item is shown in a long window below the item menu, that is not shown in the mock up (I forgot to put that on). When you press Enter on that item or weapon, you either use the item if it is an item, or equip it if it is a weapon. Pressing escape takes you back to the selection window.


Ok, that is everything. I really hope someone can make this for me. The person who does will get credited ingame. Thanks in Advance.
 
Two things. First, I misplaced the vertical coordinates, leading to the sprites being superimposed on each other. Second, I had to shrink the image size to 88x88 to fit properly within the cursor rectangle.

Also, I'm pretty sure I've got it now. How's this?

Code:
#==============================================================================

# ** Window_Help2

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

#  This window shows skill and item explanations along with actor status.

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

 

class Window_Help2 < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 594, 64)

    self.contents = Bitmap.new(width - 32, height - 32)

  end

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

  # * Set Text

  #  text  : text string displayed in window

  #  align : alignment (0..flush left, 1..center, 2..flush right)

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

  def set_text(text, align = 0)

    # If at least one part of text and alignment differ from last time

    if text != @text or align != @align

      # Redraw text

      self.contents.clear

      self.contents.font.color = normal_color

      self.contents.draw_text(4, 0, self.width - 40, 32, text, align)

      @text = text

      @align = align

      @actor = nil

    end

    self.visible = true

  end

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

  # * Set Actor

  #     actor : status displaying actor

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

  def set_actor(actor)

    if actor != @actor

      self.contents.clear

      draw_actor_name(actor, 4, 0)

      draw_actor_state(actor, 140, 0)

      draw_actor_hp(actor, 284, 0)

      draw_actor_sp(actor, 460, 0)

      @actor = actor

      @text = nil

      self.visible = true

    end

  end

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

  # * Set Enemy

  #     enemy : name and status displaying enemy

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

  def set_enemy(enemy)

    text = enemy.name

    state_text = make_battler_state_text(enemy, 112, false)

    if state_text != ""

      text += "  " + state_text

    end

    set_text(text, 1)

  end

end

 

 

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

# ** Window_MenuStatus

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

#  This window displays an image of the player, their health, and their

#  Infection level on screen.

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

 

class Window_MenuStatus < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 260, 117)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    # Generate Static Colors

    color_red = Color.new(255, 0, 0, 255)

    color_orange = Color.new(255, 128, 0, 255)

    color_blue = Color.new(0, 0, 255, 255)

    color_lightblue = Color.new(0, 128, 255, 255)

    color_black = Color.new(0, 0, 0, 255)

    # Create bitmaps

    actor_bitmap = RPG::Cache.picture('Actor1')

    hp_bitmap = RPG::Cache.picture('HPBAR')

    infection_bitmap = RPG::Cache.picture('INBAR')

    background_bitmap = RPG::Cache.picture('BGBAR')

    shadow_bitmap = RPG::Cache.picture('SHADOW')

    # Display actor image

    self.contents.blt(0, 0, actor_bitmap, Rect.new(0, 0, 85, 85))

    # Display shadow bitmap for HP and Infection gradient bars

    self.contents.blt(112, 27, shadow_bitmap, Rect.new(0, 0, 110, 20))

    self.contents.blt(112, 48, shadow_bitmap, Rect.new(0, 0, 110, 20))

    # Display background for HP and Infection gradient bars

    self.contents.blt(112, 27, background_bitmap, Rect.new(0, 0, 100, 10))

    self.contents.blt(112, 48, background_bitmap, Rect.new(0, 0, 100, 10))

    # Find current HP percentage

    max_hp = $game_actors[1].maxhp.to_f

    hp = $game_actors[1].hp.to_f

    hp_percent = ((hp / max_hp) * 100).to_i

    # Find current Infection percentage

    infection = $game_variables[1].to_f

    infection_percent = ((infection / 50.0) * 100).to_i

    # Generate HP and Infection bar rects

    hp_rect = Rect.new(0, 0, hp_percent, 10)

    infection_rect = Rect.new(0, 0, infection_percent, 10)

    # Display gradient bars for HP and Infection

    self.contents.blt(112, 27, hp_bitmap, hp_rect)

    self.contents.blt(112, 48, infection_bitmap, infection_rect)

  end

end

 

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

# ** Window_MenuInfo

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

#  This window displays the current map and the number of zombies killed

#  on screen.

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

 

class Window_MenuInfo < Window_Base

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 319, 117)

    self.contents = Bitmap.new(width - 32, height - 32)

    refresh

  end

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

  # * Refresh

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

  def refresh

    self.contents.clear

    # Get map id

    map_id = $game_map.map_id

    # load map name

    map_data = load_data('Data/MapInfos.rxdata')

    map_name = map_data[map_id].name

    self.contents.draw_text(0, 10, 212, 32, map_name)

    self.contents.font.color = system_color

    self.contents.draw_text(0, 43, 212, 32, 'Zombies Killed:')

    self.contents.font.color = normal_color

    kills = $game_variables[2].to_s

    self.contents.draw_text(72, 43, 212, 32, kills, 2)

  end

end

 

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

# ** Window_Item

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

#  This window displays items in possession on the item and battle screens.

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

 

class Window_Item < Window_Selectable

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

  # * Object Initialization

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

  def initialize

    super(0, 0, 416, 224)

    @column_max = 4

    refresh

    self.index = 0

    # If in battle, move window to center of screen

    # and make it semi-transparent

    if $game_temp.in_battle

      self.y = 64

      self.height = 256

      self.back_opacity = 160

    end

  end

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

  # * Get Item

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

  def item

    return @data[self.index]

  end

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

  # * Get Top Row

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

  def top_row

    # Divide y-coordinate of window contents transfer origin by 1 row

    # height of 96

    return self.oy / 96

  end

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

  # * Set Top Row

  #     row : row shown on top

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

  def top_row=(row)

    # If row is less than 0, change it to 0

    if row < 0

      row = 0

    end

    # If row exceeds row_max - 1, change it to row_max - 1

    if row > row_max - 1

      row = row_max - 1

    end

    # Multiply 1 row height by 96 for y-coordinate of window contents

    # transfer origin

    self.oy = row * 96

  end

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

  # * Get Number of Rows Displayable on 1 Page

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

  def page_row_max

    # Subtract a frame height of 32 from the window height, and divide it by

    # 1 row height of 96

    return (self.height - 32) / 96

  end

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

  # * Refresh

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

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    # Add item

    for i in 1...$data_items.size

      if $game_party.item_number(i) > 0

        @data.push($data_items[i])

      end

    end

    # Also add weapons and items if outside of battle

    unless $game_temp.in_battle

      for i in 1...$data_weapons.size

        if $game_party.weapon_number(i) > 0

          @data.push($data_weapons[i])

        end

      end

      for i in 1...$data_armors.size

        if $game_party.armor_number(i) > 0

          @data.push($data_armors[i])

        end

      end

    end

    if @index > (@data.size - 1)

      @index = (@data.size - 1)

    end

    # If item count is not 0, make a bit map and draw all items

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 96)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

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

  # * Draw Item

  #     index : item number

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

  def draw_item(index)

    item = @data[index]

    case item

    when RPG::Item

      number = $game_party.item_number(item.id)

    when RPG::Weapon

      number = $game_party.weapon_number(item.id)

    when RPG::Armor

      number = $game_party.armor_number(item.id)

    end

    actor = $game_party.actors[0]

    if item.is_a?(RPG::Item) and

      $game_party.item_can_use?(item.id)

      self.contents.font.color = normal_color

    elsif (item.is_a?(RPG::Weapon) and actor.equippable?(item)) ||

          (item.is_a?(RPG::Armor) and actor.equippable?(item))

      self.contents.font.color = normal_color

    else

      self.contents.font.color = disabled_color

    end

    x = 4 + index % 4 * 96

    y = index / 4 * 96

    rect = Rect.new(x, y, self.width / @column_max - 32, 88)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    bitmap = RPG::Cache.icon(item.icon_name)

    opacity = self.contents.font.color == normal_color ? 255 : 128

    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 88, 88), opacity)

    self.contents.draw_text(x + 64, y + 64, 24, 32, number.to_s, 2)

  end

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

  # * Update Cursor Rectangle

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

  def update_cursor_rect

    # If cursor position is less than 0

    if @index < 0

      self.cursor_rect.empty

      return

    end

    # Get current row

    row = @index / @column_max

    # If current row is before top row

    if row < self.top_row

      # Scroll so that current row becomes top row

      self.top_row = row

    end

    # If current row is more to back than back row

    if row > self.top_row + (self.page_row_max - 1)

      # Scroll so that current row becomes back row

      self.top_row = row - (self.page_row_max - 1)

    end

    # Calculate cursor width

    cursor_width = (self.width - 32) / @column_max

    # Calculate cursor coordinates

    x = @index % @column_max * (cursor_width)

    y = @index / @column_max * 96 - self.oy

    # Update cursor rectangle

    self.cursor_rect.set(x, y, cursor_width, 96)

  end

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

  # * Help Text Update

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

  def update_help

    @help_window.set_text(self.item == nil ? "" : self.item.description)

  end

end

 

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

# ** Scene_Map

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

#  This class performs map screen processing.

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

 

class Scene_Map

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

  # * Menu Call

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

  def call_menu

    # Hide HUD

    pictures = $game_screen.pictures

    original_opacity = []

    for i in 1...10

      picture = pictures[i]

      origin = picture.origin

      x = picture.x

      y = picture.y

      zoom_x = picture.zoom_x

      zoom_y = picture.zoom_y

      original_opacity.push(picture.opacity)

      blend_type = picture.blend_type

      pictures[i].move(1, origin, x, y, zoom_x, zoom_y, 0.0, blend_type)

    end

    $game_screen.update

    # Clear menu call flag

    $game_temp.menu_calling = false

    # If menu beep flag is set

    if $game_temp.menu_beep

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Clear menu beep flag

      $game_temp.menu_beep = false

    end

    # Straighten player position

    $game_player.straighten

    # Switch to menu screen

    $scene = Scene_Menu.new(0, original_opacity)

  end

end

 

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

# ** Scene_Menu

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

#  This class performs menu screen processing.

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

 

class Scene_Menu

  ORIGINAL_OPACITY = []

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

  # * Object Initialization

  #     index   : command cursor's initial position

  #     opacity : HUD opacity values

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

  def initialize(index = 0, opacity = nil)

    @menu_index = index

    if opacity != nil

      for i in 0...opacity.size

        ORIGINAL_OPACITY[i] = opacity[i]

      end

    end

  end

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

  # * Main Processing

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

  def main

    # Display map behind menu

    @spriteset = Spriteset_Map.new

    # Make command window

    s1 = 'Inventory'

    s2 = 'Missions'

    s3 = 'Save'

    s4 = 'Exit'

    @command_window = Window_Command.new(162, [s1, s2, s3, s4])

    @command_window.index = @menu_index

    @command_window.x = 23

    @command_window.y = 155

    # If number of party members is 0

    if $game_party.actors.size == 0

      # Disable items, skills, equipment, and status

      @command_window.disable_item(0)

    end

    # If save is forbidden

    if $game_system.save_disabled

      # Disable save

      @command_window.disable_item(3)

    end

    # Make status window

    @status_window = Window_MenuStatus.new

    @status_window.x = 23

    @status_window.y = 23

    # Make information window

    @info_window = Window_MenuInfo.new

    @info_window.x = 298

    @info_window.y = 23

    # Make help window

    @help_window = Window_Help2.new

    @help_window.x = 23

    @help_window.y = 394

    # Make item window

    @item_window = Window_Item.new

    @item_window.x = 201

    @item_window.y = 155

    @item_window.active = false

    @item_window.help_window = @help_window

    # Make target window (set to invisible / inactive)

    @target_window = Window_Target.new

    @target_window.visible = false

    @target_window.active = false

    # 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

    @info_window.dispose

    @help_window.dispose

    @item_window.dispose

    @target_window.dispose

    # Dispose of map

    @spriteset.dispose

    # Display HUD if going to Map

    if $scene.is_a? Scene_Map

      pictures = $game_screen.pictures

      for i in 1...10

        picture = pictures[i]

        origin = picture.origin

        x = picture.x

        y = picture.y

        zoom_x = picture.zoom_x

        zoom_y = picture.zoom_y

        opacity = ORIGINAL_OPACITY[i - 1].to_s.to_f

        blend_type = picture.blend_type

        pictures[i].move(1, origin, x, y, zoom_x, zoom_y, opacity, blend_type)

      end

      $game_screen.update

    end

  end

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

  # * Frame Update

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

  def update

    # Update Screen

    $game_screen.update

    # Update map

    @spriteset.update

    # Update windows

    @command_window.update

    @status_window.update

    @info_window.update

    @help_window.update

    @item_window.update

    @target_window.update

    # If command window is active: call update_command

    if @command_window.active

      update_command

      return

    end

    # If item window is active: call update_item

    if @item_window.active

      update_item

      return

    end

    # If target window is active: call update_target

    if @target_window.active

      update_target

      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

      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)

        # Make status window active

        @command_window.active = false

        @item_window.active = true

        @item_window.index = 0

      when 1  # skill

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to end game screen

        $scene = Scene_Mission.new

      when 2  # save

        # If saving is forbidden

        if $game_system.save_disabled

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # Switch to save screen

        $scene = Scene_Save.new

      when 3  # 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

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

  # * Frame Update (when item window is active)

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

  def update_item

    @item_window.refresh

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      @command_window.active = true

      @item_window.active = false

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Get currently selected data on the item window

      @item = @item_window.item

      # If not a use item

      if @item.is_a?(RPG::Item)

        # If it can't be used

        unless $game_party.item_can_use?(@item.id)

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        # Play decision SE

        $game_system.se_play($data_system.decision_se)

        # If effect scope is an ally

        if @item.scope >= 3

          # Activate target window

          @item_window.active = false

          @target_window.visible = true

          @target_window.active = true

          # Set cursor position to effect scope (single / all)

          if @item.scope == 4 || @item.scope == 6

            @target_window.index = -1

          else

            @target_window.index = 0

          end

        # If effect scope is other than an ally

        else

          # If command event ID is valid

          if @item.common_event_id > 0

            # Command event call reservation

            $game_temp.common_event_id = @item.common_event_id

            # Play item use SE

            $game_system.se_play(@item.menu_se)

            # If consumable

            if @item.consumable

              # Decrease used items by 1

              $game_party.lose_item(@item.id, 1)

              # Draw item window item

              @item_window.draw_item(@item_window.index)

            end

            # Switch to map screen

            $scene = Scene_Map.new

            return

          end

        end

        return

      elsif @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)

        actor = $game_party.actors[0]

        if actor.equippable?(@item)

          # Play equip SE

          $game_system.se_play($data_system.equip_se)

          if @item.is_a?(RPG::Weapon)

            actor.equip(0, @item.id)

          else

            p @item.type

            actor.equip(@item.kind + 1, @item.id)

          end

        else

          # Play buzzer SE

          $game_system.se_play($data_system.buzzer_se)

        end

      end

    end

  end

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

  # * Frame Update (when target window is active)

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

  def update_target

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # If unable to use because items ran out

      unless $game_party.item_can_use?(@item.id)

        # Remake item window contents

        @item_window.refresh

      end

      # Erase target window

      @item_window.active = true

      @target_window.visible = false

      @target_window.active = false

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # If items are used up

      if $game_party.item_number(@item.id) == 0

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

        return

      end

      # If target is all

      if @target_window.index == -1

        # Apply item effects to entire party

        used = false

        for i in $game_party.actors

          used |= i.item_effect(@item)

        end

      end

      # If single target

      if @target_window.index >= 0

        # Apply item use effects to target actor

        target = $game_party.actors[@target_window.index]

        used = target.item_effect(@item)

      end

      # If an item was used

      if used

        # Play item use SE

        $game_system.se_play(@item.menu_se)

        # If consumable

        if @item.consumable

          # Decrease used items by 1

          $game_party.lose_item(@item.id, 1)

          # Redraw item window item

          @item_window.draw_item(@item_window.index)

        end

        # Remake target window contents

        @target_window.refresh

        # If all party members are dead

        if $game_party.all_dead?

          # Switch to game over screen

          $scene = Scene_Gameover.new

          return

        end

        # If common event ID is valid

        if @item.common_event_id > 0

          # Common event call reservation

          $game_temp.common_event_id = @item.common_event_id

          # Switch to map screen

          $scene = Scene_Map.new

          return

        end

      end

      # If item wasn't used

      unless used

        # Play buzzer SE

        $game_system.se_play($data_system.buzzer_se)

      end

      return

    end

  end

end

 

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

# ** Scene_Save

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

#  This class performs save screen processing.

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

 

class Scene_Save < Scene_File

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

  # * Cancel Processing

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

  def on_cancel

    # Play cancel SE

    $game_system.se_play($data_system.cancel_se)

    # If called from event

    if $game_temp.save_calling

      # Clear save call flag

      $game_temp.save_calling = false

      # Switch to map screen

      $scene = Scene_Map.new

      return

    end

    # Set frame count for tone change

    frames = 40

    until frames <= 0

      # Update screen

      $game_screen.update

      # Subtract one frame from count

      frames -= 1

    end

    # Switch to menu screen

    $scene = Scene_Menu.new(2)

  end

end

 

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

# ** Scene_End

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

#  This class performs game end screen processing.

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

 

class Scene_End

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

  # * Main Processing

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

  def main

    # Display map behind menu

    @spriteset = Spriteset_Map.new

    # Make command window

    s1 = "To Title"

    s2 = "Shutdown"

    s3 = "Cancel"

    @command_window = Window_Command.new(192, [s1, s2, s3])

    @command_window.x = 320 - @command_window.width / 2

    @command_window.y = 240 - @command_window.height / 2

    # 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 window

    @command_window.dispose

    # If switching to title screen

    if $scene.is_a?(Scene_Title)

      # Fade out screen

      Graphics.transition

      Graphics.freeze

    end

  end

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

  # * Frame Update

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

  def update

    # Update map

    @spriteset.update

    # Update command window

    @command_window.update

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Set frame count for tone change

      frames = 40

      until frames <= 0

        # Update screen

        $game_screen.update

        # Subtract one frame from count

        frames -= 1

      end

      # Switch to menu screen

      $scene = Scene_Menu.new(3)

      return

    end

    # If C button was pressed

    if Input.trigger?(Input::C)

      # Branch by command window cursor position

      case @command_window.index

      when 0  # to title

        command_to_title

      when 1  # shutdown

        command_shutdown

      when 2  # quit

        command_cancel

      end

      return

    end

  end

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

  # *  Process When Choosing [Cancel] Command

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

  def command_cancel

    # Play decision SE

    $game_system.se_play($data_system.decision_se)

    # Set frame count for tone change

    frames = 40

    until frames <= 0

      # Update screen

      $game_screen.update

      # Subtract one frame from count

      frames -= 1

    end

    # Switch to menu screen

    $scene = Scene_Menu.new(3)

  end

end
 

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