[Script] [ACE] [ACE]IB Menu

TobiTobi Posts: 92Registered
[chapter]Chức năng[/chapter]
Script này giúp bạn có một menu trông giống với game kinh dị nổi tiếng Ib!
[chapter]Hình ảnh[/chapter]
IbScreen4.png
[chapter]Script[/chapter]
################################################################################
##### IB Menu
################################################################################
# Author : Biward
# Date : 22/06/2014
# Version : 2.0 VXAce
#
# This script let you have a IBLike Menu. It shows the life of an hero that you
# can define with script calls and it shows the objects that you wanted to show
#
# 4 commands :
# - perso_menu(id)
# The menu will show the life of the actor id.
#
# - menu_item(id)
# This command add the item id in the menu
#
# - remove_menu_item(id)
# This command remove the item id of the menu
#
# - save_access(bol)
# This command let you enable (replace bol by true) or disable (replace bol by
# false) the save menu access.
#
################################################################################
##### ConfigurationMenu
################################################################################
module BIKO
  # Indicate here the ID of the actor
  Id_hero = 1

  # Life Bar's position [x, y]
  Position_life = [16, 60]
     
  # First Item's position [x, y]
  Position_items = [200, 80]
  
  ### Save Text
  # Save Text's position [x, y]
  Position_save_text = [55, 350]
  
  # Save Text which can indicate the key to press
  Save_text = "F5:Save"
  
  # Save Text's color [red, green, blue, opacity]
  Color_Savetext = [255, 200, 200, 255]
  
  # Save Text's size 
  Size_Savetext = 20
  
  # Key which let you access to the save menu
  Key_Save = :F5     
end
################################################################################
##### Beginning of the Script
################################################################################
################################################################################
### Scene_Menu
################################################################################
class Scene_Menu
     
  class << self
    attr_accessor :perso, :items, :savedisable
  end
  
  #-----------------------------------------------------------------------------
  # * Overwritten Method : Check Variables
  #-----------------------------------------------------------------------------
  def start
    super
    check_variables
    create_back
    create_life
    create_window_items
    create_savetext if sdisable?
  end
  
  #-----------------------------------------------------------------------------
  # * Overwritten Method : Check Variables
  #-----------------------------------------------------------------------------
  def terminate
    super
    dispose_life
    dispose_back
    dispose_window_items
    dispose_savetext if sdisable?
  end
  
  #-----------------------------------------------------------------------------
  # * Overwritten Method : Update
  #-----------------------------------------------------------------------------
  def update
    super
    SceneManager.return if Input.trigger?(:B)
    go_savemenu if Input.trigger?(BIKO::Key_Save) && sdisable?
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : sdisable?
  #-----------------------------------------------------------------------------
  def sdisable?
    return (! Scene_Menu.savedisable)    
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Check Variables
  #-----------------------------------------------------------------------------
  def check_variables
    Scene_Menu.perso ||= BIKO::Id_hero if BIKO::Id_hero > 0
    Scene_Menu.items ||= []
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Create Life
  #-----------------------------------------------------------------------------
  def create_life
    @window_life = Window_Base.new(-16, -16, Graphics.width + 32, Graphics.height + 32)
    @window_life.opacity = 0
    spritelife_back = Cache.system("HP_BAR_BACK")
    spritelife = Cache.system("HP_BAR")
    src_rect_back = Rect.new(0, 0, spritelife.width, spritelife.height)
    mp = ($game_actors[Scene_Menu.perso].hp.to_f / $game_actors[Scene_Menu.perso].mhp.to_f ).to_f * spritelife.height.to_f
    src_rect = Rect.new(0, spritelife.height - mp, spritelife.width, spritelife.height)
    x = BIKO::Position_life[0]
    y = BIKO::Position_life[1]
    pp = spritelife.height - mp
    @window_life.contents.blt(x, y, spritelife_back, src_rect_back)
    @window_life.contents.blt(x, y + pp, spritelife, src_rect)
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Create Back
  #-----------------------------------------------------------------------------
  def create_back
    @spriteback = Sprite.new
    @spriteback.bitmap = Cache.system("MenuBack")
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Create Savetext
  #-----------------------------------------------------------------------------
  def create_savetext
    @savetext = Sprite.new
    @savetext.bitmap = Bitmap.new(Graphics.width, Graphics.height)
    @savetext.bitmap.font.size = BIKO::Size_Savetext
    @savetext.bitmap.font.color = Color.new(BIKO::Color_Savetext[0], BIKO::Color_Savetext[1], BIKO::Color_Savetext[2], BIKO::Color_Savetext[3])
    @savetext.bitmap.draw_text(BIKO::Position_save_text[0], BIKO::Position_save_text[1] - 200, 544, 416, BIKO::Save_text, 0)
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Create Window Items
  #-----------------------------------------------------------------------------
  def create_window_items
    @img ||= []
    @x ||= BIKO::Position_items[0]
    @y ||= BIKO::Position_items[1]
    @i ||= 0
    Scene_Menu.items.each do |i|
      @img << Sprite.new
      @img[@i].bitmap = Cache.system($data_items[i].name.to_s)
      @img[@i].x = @x ; @img[@i].y = @y
      @y += @img[@i].height ; @i += 1
    end
  end
     
  #-----------------------------------------------------------------------------
  # * New Method : Dispose Life
  #-----------------------------------------------------------------------------
  def dispose_life
    @window_life.dispose
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Dispose Back
  #-----------------------------------------------------------------------------
  def dispose_back
    @spriteback.dispose
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Dispose Window Items
  #-----------------------------------------------------------------------------
  def dispose_window_items
    @img.each { |i| i.dispose }
  end
  
  #-----------------------------------------------------------------------------
  # * New Method : Dispose Savetext
  #-----------------------------------------------------------------------------
  def dispose_savetext
    @savetext.dispose
  end
     
  #-----------------------------------------------------------------------------
  # * New Method : Go Savemenu
  #-----------------------------------------------------------------------------
  def go_savemenu    
    SceneManager.call(Scene_Save)
  end
end

################################################################################
### Game Interpreter
################################################################################
class Game_Interpreter
  #-----------------------------------------------------------------------------
  # * New Method : Perso Menu
  #-----------------------------------------------------------------------------
  def perso_menu(id)
    Scene_Menu.perso = id
  end
  #-----------------------------------------------------------------------------
  # * New Method : Menu Item
  #-----------------------------------------------------------------------------
  def menu_item(id)
    Scene_Menu.items ||= []
    Scene_Menu.items << id if ! Scene_Menu.items.include?(id)
  end
  #-----------------------------------------------------------------------------
  # * New Method : Remove Menu Item
  #-----------------------------------------------------------------------------
  def remove_menu_item(id)
    Scene_Menu.items ||= []
    index = Scene_Menu.items.index(id) if Scene_Menu.items.include?(id)
    Scene_Menu.items.delete_at(index) if index
  end
  #-----------------------------------------------------------------------------
  # * New Method : save_access
  #-----------------------------------------------------------------------------
  def save_access(bol)
    Scene_Menu.savedisable = (! bol)
  end
end
################################################################################
##### End of the Script
################################################################################
[chapter]Credit[/chapter]
- Biwy
[chapter]CHÚ Ý[/chapter]
Tình hình là cái script này cần 3 hình ảnh như sau (Mình để bằng tiếng anh bởi không rõ lắm về khoản này) :
Requires :
You will need 3 images :
- HP_BAR : which is the flower (the life bar). She goes up to bottom.
- HP_BAR_BACK : which is the the life bar "background"
- MenuBack : which is the background image

Of course, you will need an image for each item you want to display. You just have to put an image with the item's name in the Graphics/System folder.



P/s :Ai kiếm hộ mấy cái hình ảnh với :laclac:

Comments

Sign In or Register to comment.