Class: Game_Picture

Inherits:
Object show all
Defined in:
scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb

Overview

Describe a picture display on the Screen

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(number) ⇒ Game_Picture

Initialize the Game_Picture with default value

Parameters:

  • number (Integer)

    the “id” of the picture



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 19

def initialize(number)
  @number = number
  @name = nil.to_s
  @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
  @mirror = false
end

Instance Attribute Details

#angle (readonly)

回転角度



15
16
17
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 15

def angle
  @angle
end

#blend_type (readonly)

ブレンド方法



13
14
15
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 13

def blend_type
  @blend_type
end

#mirror

Returns the value of attribute mirror.



16
17
18
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 16

def mirror
  @mirror
end

#name (readonly)

ファイル名



6
7
8
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 6

def name
  @name
end

#number (readonly)

ピクチャ番号



5
6
7
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 5

def number
  @number
end

#opacity (readonly)

不透明度



12
13
14
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 12

def opacity
  @opacity
end

#origin (readonly)

原点



7
8
9
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 7

def origin
  @origin
end

#tone (readonly)

色調



14
15
16
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 14

def tone
  @tone
end

#x (readonly)

X 座標



8
9
10
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 8

def x
  @x
end

#y (readonly)

Y 座標



9
10
11
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 9

def y
  @y
end

#zoom_x (readonly)

X 方向拡大率



10
11
12
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 10

def zoom_x
  @zoom_x
end

#zoom_y (readonly)

Y 方向拡大率



11
12
13
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 11

def zoom_y
  @zoom_y
end

Instance Method Details

#erase

Remove the picture from the screen



107
108
109
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 107

def erase
  @name = nil.to_s
end

#move(duration, origin, x, y, zoom_x, zoom_y, opacity, blend_type)

Move a picture

Parameters:

  • duration (Integer)

    the number of frame the picture takes to move

  • origin (Integer)

    the origin type (top left / center)

  • x (Numeric)

    the x position on the screen

  • y (Numeric)

    the y position on the screen

  • zoom_x (Numeric)

    the zoom on the width

  • zoom_y (Numeric)

    the zoom on the height

  • opacity (Numeric)

    the opacity of the picture

  • blend_type (Integer)

    the blend_type of the picture



81
82
83
84
85
86
87
88
89
90
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 81

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

#rotate(speed)

Rotate the picture

Parameters:

  • speed (Numeric)

    the rotation speed (2*angle / frame)



93
94
95
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 93

def rotate(speed)
  @rotate_speed = speed
end

#show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)

Show a picture

Parameters:

  • name (String)

    The name of the image in Graphics/Pictures

  • origin (Integer)

    the origin type (top left / center)

  • x (Numeric)

    the x position on the screen

  • y (Numeric)

    the y position on the screen

  • zoom_x (Numeric)

    the zoom on the width

  • zoom_y (Numeric)

    the zoom on the height

  • opacity (Numeric)

    the opacity of the picture

  • blend_type (Integer)

    the blend_type of the picture



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 51

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

#start_tone_change(tone, duration)

Start a tone change of the picture

Parameters:

  • tone (Tone)

    the new tone of the picture

  • duration (Integer)

    the number of frame the tone change takes



99
100
101
102
103
104
105
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 99

def start_tone_change(tone, duration)
  @tone_target = tone.clone
  @tone_duration = duration
  if @tone_duration == 0
    @tone = @tone_target.clone
  end
end

#update

Update the picture state change



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/01800 Game_Picture.rb', line 116

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