Submit Your Article Guild Wars 2 Forum RPG Maker VX.com
 
RPG Maker
 

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Window_BattleResult

Window_BattleResult


Inherits from: Window_Base

Description: This is the class for the window that appears when you win a battle. It shows the amount of experience points and money obtained, as well as any items the enemy dropped.

Code


class Window_BattleResult < Window_Base
# ------------------------------------
 def initialize(exp, gold, treasures)
    @exp = exp
    @gold = gold
    @treasures = treasures
    super(160, 0, 320, @treasures.size * 32 + 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.y = 160 - height / 2
    self.back_opacity = 160
    self.visible = false
    refresh
  end
# ------------------------------------
  def refresh
    self.contents.clear
    x = 4
    self.contents.font.color = normal_color
    cx = contents.text_size(@exp.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @exp.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    cx = contents.text_size("EXP").width
    self.contents.draw_text(x, 0, 64, 32, "EXP")
    x += cx + 16
    self.contents.font.color = normal_color
    cx = contents.text_size(@gold.to_s).width
    self.contents.draw_text(x, 0, cx, 32, @gold.to_s)
    x += cx + 4
    self.contents.font.color = system_color
    self.contents.draw_text(x, 0, 128, 32, $data_system.words.gold)
    y = 32
    for item in @treasures
      draw_item_name(item, 4, y)
      y += 32
    end
  end
end

Properties


Exp: The experience point value to show in the window.

Gold: The money value to show in the window.

Treasures: An array representing the items dropped by the enemy.

Methods


Initialize

Arguments:
Exp: The experience point value to show in the window.
Gold: The money value to show in the window.
Treasures: An array representing the items dropped by the enemy.
Local Variables: None

How it Works: This method initializes the window's state. The @experience, @gold, and @treasures instances variables are set to the values passed to this method. The super(160, 0, 320, @treasures.size * 32 + 64) statement sets the width of the window at 320 pixels, and the height of the window at 64, plus 32 for each item the monsters dropped. The Y coordinate of the window is then set to 160 minus half the height of the window.

Refresh

Arguments: None
Local Variables: None

How it Works: This method draws the window contents. First, all contents are cleared from the window. The experience point value and money value are drawn on one line. For all four strings on the first line, the y coordinate is 0. The first thing drawn is the number of experience points earned. This is drawn at x coordinate 4. Next, the x coordinate is moved to the right by 4 plus how wide the experience value string is, in pixels. The string "EXP" is drawn in the system color at the new x coordinate. The x coordinate is again moved to the right by 16 plus the width of the string "EXP" in the current font, in pixels. At that new x coordinate, the amount of money gained is drawn. The x coordinate is moved to the right one last time by 4 pixels plus the width of the money value in the current font, in pixels. At this new x coordinate, the system string for "money" is drawn in the system color. The y coordinate is then set to 32. For each treasure in the array, the Window_Base#draw_item_name method is called to draw the item's icon and name at x coordinate 4 and the current y coordinate, which is increased by 32 for each item drawn. 
Syntax
@
@@
$
alias
[array index]
attr_accessor
attr_reader
attr_writer
class
def
do
ensure
for
if
[iterator]
key => value
new
next
nil
redo
require
return
rescue
self
super
undef
unless
until
while
yield

Classes
Arrow_Actor
Arrow_Base
Arrow_Enemy
Game_Actor
Game_Actors
Game_BattleAct
Game_Battler
Game_Character
Game_Common
Game_Enemy
Game_Event
Game_Map
Game_Party
Game_Picture
Game_Player
Game_Screen
Game_SlfSwitch
Game_Switches
Game_System
Game_Troop
Game_Variables
Interpreter
Scene_Debug
Scene_End
Scene_Equip
Scene_File
Scene_Gameover
Scene_Item
Scene_Load
Scene_Map
Scene_Menu
Scene_Name
Scene_Save
Scene_Shop
Scene_Skill
Scene_Status
Scene_Title
Sprite_Battler
Sprite_Character
Sprite_Picture
Sprite_Timer
Spriteset_Battle
Spriteset_Map
Window_Base
Window_Battleresult
Window_Battlestatus
Window_Command
Window_DebugLeft
Window_DebugRight
Window_EquipItem
Window_EquipLeft
Window_EquipRight
Window_Gold
Window_Help
Window_InputNumb
Window_Item
Window_MenuStatus
Window_Message
Window_NameEdit
Window_NameInput
Window_PartyCom
Window_PlayTime
Window_SaveFile
Window_Selectable
Window_ShopBuy
Window_ShopCom
Window_ShopNum
Window_ShopSell
Window_ShopStatus
Window_Skill
Window_SkillStatus
Window_Status
Window_Steps
Window_Target

Other
Class Hierarchy
Global Variables


RPG RPG Revolution
RPG RPG Revolution is your #1 stop for game development and console RPG games, as well as those created by people like you. Link to us to support us, so we may grow to be better website community for you.

RPG RPG Revolution is an Privacy Policy and Legal