Class: Game_Screen

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

Overview

** Game_Screen


This class handles screen maintenance data, such as changes in color tone,

flashes, etc. It's used within the Game_Map and Game_Troop classes.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Game_Screen) initialize


  • Object Initialization




22
23
24
25
# File 'Game_Screen.rb', line 22

def initialize
  @pictures = Game_Pictures.new
  clear
end

Instance Attribute Details

- (Object) brightness (readonly)


  • Public Instance Variables




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

def brightness
  @brightness
end

- (Object) flash_color (readonly)

flash color



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

def flash_color
  @flash_color
end

- (Object) pictures (readonly)

pictures



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

def pictures
  @pictures
end

- (Object) shake (readonly)

shake positioning



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

def shake
  @shake
end

- (Object) tone (readonly)

color tone



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

def tone
  @tone
end

- (Object) weather_power (readonly)

weather intensity (Float)



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

def weather_power
  @weather_power
end

- (Object) weather_type (readonly)

weather type



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

def weather_type
  @weather_type
end

Instance Method Details

- (Object) change_weather(type, power, duration)


  • Change Weather

     type  : type (:none, :rain, :storm, :snow)
     power: intensity
    If weather type is none (:none), set @weather_power_target (target
    value of intensity) to 0 to represent gradual stopping of rain, but
    only in this case.



132
133
134
135
136
137
# File 'Game_Screen.rb', line 132

def change_weather(type, power, duration)
  @weather_type = type if type != :none || duration == 0
  @weather_power_target = type == :none ? 0.0 : power.to_f
  @weather_duration = duration
  @weather_power = @weather_power_target if duration == 0
end

- (Object) clear


  • Clear




29
30
31
32
33
34
35
36
# File 'Game_Screen.rb', line 29

def clear
  clear_fade
  clear_tone
  clear_flash
  clear_shake
  clear_weather
  clear_pictures
end

- (Object) clear_fade


  • Clear Fade In/Out




40
41
42
43
44
# File 'Game_Screen.rb', line 40

def clear_fade
  @brightness = 255
  @fadeout_duration = 0
  @fadein_duration = 0
end

- (Object) clear_flash


  • Clear Flash




56
57
58
59
# File 'Game_Screen.rb', line 56

def clear_flash
  @flash_color = Color.new
  @flash_duration = 0
end

- (Object) clear_pictures


  • Clear Picture




82
83
84
# File 'Game_Screen.rb', line 82

def clear_pictures
  @pictures.each {|picture| picture.erase }
end

- (Object) clear_shake


  • Clear Shake




63
64
65
66
67
68
69
# File 'Game_Screen.rb', line 63

def clear_shake
  @shake_power = 0
  @shake_speed = 0
  @shake_duration = 0
  @shake_direction = 1
  @shake = 0
end

- (Object) clear_tone


  • Clear Color Tone




48
49
50
51
52
# File 'Game_Screen.rb', line 48

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

- (Object) clear_weather


  • Clear Weather




73
74
75
76
77
78
# File 'Game_Screen.rb', line 73

def clear_weather
  @weather_type = :none
  @weather_power = 0
  @weather_power_target = 0
  @weather_duration = 0
end

- (Object) start_fadein(duration)


  • Start Fadein




95
96
97
98
# File 'Game_Screen.rb', line 95

def start_fadein(duration)
  @fadein_duration = duration
  @fadeout_duration = 0
end

- (Object) start_fadeout(duration)


  • Start Fadeout




88
89
90
91
# File 'Game_Screen.rb', line 88

def start_fadeout(duration)
  @fadeout_duration = duration
  @fadein_duration = 0
end

- (Object) start_flash(color, duration)


  • Start Flashing




110
111
112
113
# File 'Game_Screen.rb', line 110

def start_flash(color, duration)
  @flash_color = color.clone
  @flash_duration = duration
end

- (Object) start_flash_for_damage


  • Start Flash (for Poison/Damage Floor)




231
232
233
# File 'Game_Screen.rb', line 231

def start_flash_for_damage
  start_flash(Color.new(255,0,0,128), 8)
end

- (Object) start_shake(power, speed, duration)


  • Start Shaking

    power: intensity
    speed: speed



119
120
121
122
123
# File 'Game_Screen.rb', line 119

def start_shake(power, speed, duration)
  @shake_power = power
  @shake_speed = speed
  @shake_duration = duration
end

- (Object) start_tone_change(tone, duration)


  • Start Changing Color Tone




102
103
104
105
106
# File 'Game_Screen.rb', line 102

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




141
142
143
144
145
146
147
148
149
# File 'Game_Screen.rb', line 141

def update
  update_fadeout
  update_fadein
  update_tone
  update_flash
  update_shake
  update_weather
  update_pictures
end

- (Object) update_fadein


  • Update Fadein




163
164
165
166
167
168
169
# File 'Game_Screen.rb', line 163

def update_fadein
  if @fadein_duration > 0
    d = @fadein_duration
    @brightness = (@brightness * (d - 1) + 255) / d
    @fadein_duration -= 1
  end
end

- (Object) update_fadeout


  • Update Fadeout




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

def update_fadeout
  if @fadeout_duration > 0
    d = @fadeout_duration
    @brightness = (@brightness * (d - 1)) / d
    @fadeout_duration -= 1
  end
end

- (Object) update_flash


  • Update Flash




186
187
188
189
190
191
192
# File 'Game_Screen.rb', line 186

def update_flash
  if @flash_duration > 0
    d = @flash_duration
    @flash_color.alpha = @flash_color.alpha * (d - 1) / d
    @flash_duration -= 1
  end
end

- (Object) update_pictures


  • Update Pictures




225
226
227
# File 'Game_Screen.rb', line 225

def update_pictures
  @pictures.each {|picture| picture.update }
end

- (Object) update_shake


  • Update Shake




196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'Game_Screen.rb', line 196

def update_shake
  if @shake_duration > 0 || @shake != 0
    delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
    if @shake_duration <= 1 && @shake * (@shake + delta) < 0
      @shake = 0
    else
      @shake += delta
    end
    @shake_direction = -1 if @shake > @shake_power * 2
    @shake_direction = 1 if @shake < - @shake_power * 2
    @shake_duration -= 1
  end
end

- (Object) update_tone


  • Update Tone




173
174
175
176
177
178
179
180
181
182
# File 'Game_Screen.rb', line 173

def update_tone
  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
end

- (Object) update_weather


  • Update Weather




212
213
214
215
216
217
218
219
220
221
# File 'Game_Screen.rb', line 212

def update_weather
  if @weather_duration > 0
    d = @weather_duration
    @weather_power = (@weather_power * (d - 1) + @weather_power_target) / d
    @weather_duration -= 1
    if @weather_duration == 0 && @weather_power_target == 0
      @weather_type = :none
    end
  end
end