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

 Username:
 Password:
   Not a member? Register!



Home > RGSS Script Reference > Game_Picture

Game_Picture


Inherits from: None

Description: This class holds information about a picture and contains methods for showing, moving, rotating, and erasing pictures.

Code


class Game_Picture
# ------------------------------------  
  attr_reader   :number
  attr_reader   :name
  attr_reader   :origin
  attr_reader   :x
  attr_reader   :y
  attr_reader   :zoom_x
  attr_reader   :zoom_y
  attr_reader   :opacity
  attr_reader   :blend_type
  attr_reader   :tone
  attr_reader   :angle
# ------------------------------------  
  def initialize(number)
    @number = number
    @name = ""
    @origin = 0
    @x = 0.0
    @y = 0.0
    @zoom_x = 100.0
    @zoom_y = 100.0
    @opacity = 255.0
    @blend_type = 1
    @duration = 0
    @target_x = @x
    @target_y = @y
    @target_zoom_x = @zoom_x
    @target_zoom_y = @zoom_y
    @target_opacity = @opacity
    @tone = Tone.new(0, 0, 0, 0)
    @tone_target = Tone.new(0, 0, 0, 0)
    @tone_duration = 0
    @angle = 0
    @rotate_speed = 0
  end
# ------------------------------------  
  def show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)
    @name = name
    @origin = origin
    @x = x.to_f
    @y = y.to_f
    @zoom_x = zoom_x.to_f
    @zoom_y = zoom_y.to_f
    @opacity = opacity.to_f
    @blend_type = blend_type
    @duration = 0
    @target_x = @x
    @target_y = @y
    @target_zoom_x = @zoom_x
    @target_zoom_y = @zoom_y
    @target_opacity = @opacity
    @tone = Tone.new(0, 0, 0, 0)
    @tone_target = Tone.new(0, 0, 0, 0)
    @tone_duration = 0
    @angle = 0
    @rotate_speed = 0
  end
# ------------------------------------  
  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
  end
# ------------------------------------  
  def rotate(speed)
    @rotate_speed = speed
  end
# ------------------------------------  
  def start_tone_change(tone, duration)
    @tone_target = tone.clone
    @tone_duration = duration
    if @tone_duration == 0
      @tone = @tone_target.clone
    end
  end
# ------------------------------------  
  def erase
    @name = ""
  end
# ------------------------------------  
  def update
    if @duration >= 1
      d = @duration
      @x = (@x * (d - 1) + @target_x) / d
      @y = (@y * (d - 1) + @target_y) / d
      @zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d
      @zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d
      @opacity = (@opacity * (d - 1) + @target_opacity) / d
      @duration -= 1
    end
    if @tone_duration >= 1
      d = @tone_duration
      @tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
      @tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
      @tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
      @tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
      @tone_duration -= 1
    end
    if @rotate_speed != 0
      @angle += @rotate_speed / 2.0
      while @angle < 0
        @angle += 360
      end
      @angle %= 360
    end
  end
end

Properties


Number: The picture's ID number defined in the "Show Picture" command.

Name: The picture's filename.

Origin: The point relative to which the picture will be shown (0 = Upper-Left, 1 = Center).

X: The X coordinate of the picture's origin.

Y: The Y coordinate of the picture's origin.

Zoom_X: The horizontal magnification of the picture.

Zoom_Y: The vertical magnification of the picture.

Opacity: The picture's opacity value (0 = Completely transparent, 255 = Completely opaque)

Blend_Type: The picture's graphical blend type (0 = Normal, 1 = Additive, 2 = Negative).

Tone: The picture's tone setting.

Angle: The picture's rotation angle relative to its original orientation. Increasing the angle represents a rotation to the right relative to the origin, while decreasing the angle represents a rotation to the left relative to the origin.

Duration: The remaining time in a "Move Picture" command.

Target_X: The target X coordinate for a "Move Picture" command.

Target_Y: The target Y coordinate for a "Move Picture" command.

Target_Zoom_X: The target horizontal magnification for a "Move Picture" command.

Target_Zoom_Y: The target vertical magnification for a "Move Picture" command.

Target_Opacity: The target opacity value for a "Move Picture" command.

Tone_Target: The tone target for a "Tint Picture" command.

Tone_Duration: The remaining time in a "Tint Picture" command.

Rotate_Speed: The rotation speed of the picture.

Methods


Initialize

Arguments:
Number: The picture number to initialize.
Local Variables: None

How it Works: This method initializes the picture to a null state.

Show

Arguments:
Name: The picture's filename.
Origin: The origin value of the picture.
X: The X coordinate at which to show the picture.
Y: The Y coordinate at which to show the picture.
Zoom_X: The horizontal magnification for the picture.
Zoom_Y: The vertical magnification for the picture.
Opacity: The opacity value of the picture.
Blend_Type: The graphical blend type of the picture.
Local Variables: None

How it Works: This method shows a picture on the screen. The lower-level graphics routines actually handle showing the picture, so this method just sets the instance variables associated with the picture to the appropriate values.

Move

Arguments:
Duration: The transition time for the Move Picture operation, in frames.
Name: The picture's filename.
Origin: The origin value of the picture. It's possible to move a picture from Upper-Left-relative coordinates to Center-relative coordinates and vice-versa.
X: The X coordinate to which to move the picture.
Y: The Y coordinate to which to move the picture.
Zoom_X: The new horizontal magnification for the picture after movement.
Zoom_Y: The new vertical magnification for the picture after movement.
Opacity: The opacity value of the picture after movement.
Blend_Type: The graphical blend type of the picture after movement.
Local Variables: None

How it Works: This method sets up a "Move Picture" command. The Update method carries out the frame-by-frame updating of the movement effect. This method just sets the instance variables representing the new values.

Rotate

Arguments:
Speed: The rotation speed of the picture. A positive value indicates rotating to the right, while a negative value indicates rotating to the left.
Local Variables: None

How it Works: This method sets up a "Rotate Picture" command. The Update method carries out the frame-by-frame updating of the rotation effect. This method sets the rotation speed instance variable.

Start_Tone_Change

Arguments:
Tone: The new tone.
Duration: The transition time from the old tone to the new tone, in frames.
Local Variables: None

How it Works: This method sets up a "Tint Picture" command. This method sets the @tone_target and @tone_duration instance variables. If the value of @tone_duration is 0, the method sets the picture's current tone to the new tone directly. Otherwise, the Update method carries out the frame-by-frame updating of the tinting effect.

Erase

Arguments: None
Local Variables: None

How it Works: Erases the picture by setting its filename to a null string.

Update

Arguments: None
Local Variables: None

How it Works: This method does the frame-by-frame transition updates for "Move Picture", "Tint Picture", and "Rotate Picture". The if @duration >= 1 clause handles Move Picture effects. The instance variable change statements for @x, @y, @zoom_x, @zoom_y, and @opacity each change their respective picture properties by an amount equal to ((target value - previous value) / total duration). The if @tone_duration >= 1 clause handles tone changes in progress, updating each of the four tone components (red, green, blue, gray) by an amount equal to ((target value - previous value) / total duration). Finally, the if @rotate_speed != 0 clause handles picture rotation. The picture's angle is rotated by one half of one degree per unit of rotation speed. The while loop converts a negative angle into the equivilant positive angle by adding 360. The modulous statement ensures that the value of @angle represents a rotation angle only a part of one revolution from the origin, since allowing multiple revolutions adds more complexity without adding any functionality. 
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