Class: Game_Picture

Inherits:
Object
  • Object
show all
Defined in:
Game_Picture.rb

Overview

** Game_Picture


This class handles pictures. It is created only when a picture of a specific

number is required internally for the Game_Pictures class.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Game_Picture) initialize(number)


  • Object Initialization




26
27
28
29
30
31
32
# File 'Game_Picture.rb', line 26

def initialize(number)
  @number = number
  init_basic
  init_target
  init_tone
  init_rotate
end

Instance Attribute Details

- (Object) angle (readonly)

rotation angle



22
23
24
# File 'Game_Picture.rb', line 22

def angle
  @angle
end

- (Object) blend_type (readonly)

blend method



20
21
22
# File 'Game_Picture.rb', line 20

def blend_type
  @blend_type
end

- (Object) name (readonly)

filename



13
14
15
# File 'Game_Picture.rb', line 13

def name
  @name
end

- (Object) number (readonly)


  • Public Instance Variables




12
13
14
# File 'Game_Picture.rb', line 12

def number
  @number
end

- (Object) opacity (readonly)

opacity level



19
20
21
# File 'Game_Picture.rb', line 19

def opacity
  @opacity
end

- (Object) origin (readonly)

starting point



14
15
16
# File 'Game_Picture.rb', line 14

def origin
  @origin
end

- (Object) tone (readonly)

color tone



21
22
23
# File 'Game_Picture.rb', line 21

def tone
  @tone
end

- (Object) x (readonly)

x-coordinate



15
16
17
# File 'Game_Picture.rb', line 15

def x
  @x
end

- (Object) y (readonly)

y-coordinate



16
17
18
# File 'Game_Picture.rb', line 16

def y
  @y
end

- (Object) zoom_x (readonly)

x directional zoom rate



17
18
19
# File 'Game_Picture.rb', line 17

def zoom_x
  @zoom_x
end

- (Object) zoom_y (readonly)

y directional zoom rate



18
19
20
# File 'Game_Picture.rb', line 18

def zoom_y
  @zoom_y
end

Instance Method Details

- (Object) erase


  • Erase Picture




115
116
117
# File 'Game_Picture.rb', line 115

def erase
  @name = ""
end

- (Object) init_basic


  • Initialize Basic Variable




36
37
38
39
40
41
42
# File 'Game_Picture.rb', line 36

def init_basic
  @name = ""
  @origin = @x = @y = 0
  @zoom_x = @zoom_y = 100.0
  @opacity = 255.0
  @blend_type = 1
end

- (Object) init_rotate


  • Initialize Rotation




65
66
67
68
# File 'Game_Picture.rb', line 65

def init_rotate
  @angle = 0
  @rotate_speed = 0
end

- (Object) init_target


  • Initialize Movement Target




46
47
48
49
50
51
52
53
# File 'Game_Picture.rb', line 46

def init_target
  @target_x = @x
  @target_y = @y
  @target_zoom_x = @zoom_x
  @target_zoom_y = @zoom_y
  @target_opacity = @opacity
  @duration = 0
end

- (Object) init_tone


  • Initialize Color Tone




57
58
59
60
61
# File 'Game_Picture.rb', line 57

def init_tone
  @tone = Tone.new
  @tone_target = Tone.new
  @tone_duration = 0
end

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


  • Move Picture




88
89
90
91
92
93
94
95
96
97
# File 'Game_Picture.rb', line 88

def move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, 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
  @duration = duration
end

- (Object) rotate(speed)


  • Change Rotation Speed




101
102
103
# File 'Game_Picture.rb', line 101

def rotate(speed)
  @rotate_speed = speed
end

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


  • Show Picture




72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'Game_Picture.rb', line 72

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
  init_target
  init_tone
  init_rotate
end

- (Object) start_tone_change(tone, duration)


  • Start Changing Color Tone




107
108
109
110
111
# File 'Game_Picture.rb', line 107

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

- (Object) update


  • Frame Update




121
122
123
124
125
# File 'Game_Picture.rb', line 121

def update
  update_move
  update_tone_change
  update_rotate
end

- (Object) update_move


  • Update Picture Move




129
130
131
132
133
134
135
136
137
138
# File 'Game_Picture.rb', line 129

def update_move
  return if @duration == 0
  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

- (Object) update_rotate


  • Update Rotation




154
155
156
157
158
159
# File 'Game_Picture.rb', line 154

def update_rotate
  return if @rotate_speed == 0
  @angle += @rotate_speed / 2.0
  @angle += 360 while @angle < 0
  @angle %= 360
end

- (Object) update_tone_change


  • Update Color Tone Change




142
143
144
145
146
147
148
149
150
# File 'Game_Picture.rb', line 142

def update_tone_change
  return if @tone_duration == 0
  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