Class: Game_Screen
- Inherits:
-
Object
- Object
- Game_Screen
- Defined in:
- lib/rgss3_default_scripts/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
-
#brightness ⇒ Object
readonly
————————————————————————– * Public Instance Variables ————————————————————————–.
-
#flash_color ⇒ Object
readonly
flash color.
-
#pictures ⇒ Object
readonly
pictures.
-
#shake ⇒ Object
readonly
shake positioning.
-
#tone ⇒ Object
readonly
color tone.
-
#weather_power ⇒ Object
readonly
weather intensity (Float).
-
#weather_type ⇒ Object
readonly
weather type.
Instance Method Summary collapse
-
#change_weather(type, power, duration) ⇒ Object
————————————————————————– * 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.
-
#clear ⇒ Object
————————————————————————– * Clear ————————————————————————–.
-
#clear_fade ⇒ Object
————————————————————————– * Clear Fade In/Out ————————————————————————–.
-
#clear_flash ⇒ Object
————————————————————————– * Clear Flash ————————————————————————–.
-
#clear_pictures ⇒ Object
————————————————————————– * Clear Picture ————————————————————————–.
-
#clear_shake ⇒ Object
————————————————————————– * Clear Shake ————————————————————————–.
-
#clear_tone ⇒ Object
————————————————————————– * Clear Color Tone ————————————————————————–.
-
#clear_weather ⇒ Object
————————————————————————– * Clear Weather ————————————————————————–.
-
#initialize ⇒ Game_Screen
constructor
————————————————————————– * Object Initialization ————————————————————————–.
-
#start_fadein(duration) ⇒ Object
————————————————————————– * Start Fadein ————————————————————————–.
-
#start_fadeout(duration) ⇒ Object
————————————————————————– * Start Fadeout ————————————————————————–.
-
#start_flash(color, duration) ⇒ Object
————————————————————————– * Start Flashing ————————————————————————–.
-
#start_flash_for_damage ⇒ Object
————————————————————————– * Start Flash (for Poison/Damage Floor) ————————————————————————–.
-
#start_shake(power, speed, duration) ⇒ Object
————————————————————————– * Start Shaking power: intensity speed: speed ————————————————————————–.
-
#start_tone_change(tone, duration) ⇒ Object
————————————————————————– * Start Changing Color Tone ————————————————————————–.
-
#update ⇒ Object
————————————————————————– * Frame Update ————————————————————————–.
-
#update_fadein ⇒ Object
————————————————————————– * Update Fadein ————————————————————————–.
-
#update_fadeout ⇒ Object
————————————————————————– * Update Fadeout ————————————————————————–.
-
#update_flash ⇒ Object
————————————————————————– * Update Flash ————————————————————————–.
-
#update_pictures ⇒ Object
————————————————————————– * Update Pictures ————————————————————————–.
-
#update_shake ⇒ Object
————————————————————————– * Update Shake ————————————————————————–.
-
#update_tone ⇒ Object
————————————————————————– * Update Tone ————————————————————————–.
-
#update_weather ⇒ Object
————————————————————————– * Update Weather ————————————————————————–.
Constructor Details
#initialize ⇒ Game_Screen
-
Object Initialization
22 23 24 25 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 22 def initialize @pictures = Game_Pictures.new clear end |
Instance Attribute Details
#brightness ⇒ Object (readonly)
-
Public Instance Variables
12 13 14 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 12 def brightness @brightness end |
#flash_color ⇒ Object (readonly)
flash color
14 15 16 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 14 def flash_color @flash_color end |
#pictures ⇒ Object (readonly)
pictures
15 16 17 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 15 def pictures @pictures end |
#shake ⇒ Object (readonly)
shake positioning
16 17 18 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 16 def shake @shake end |
#tone ⇒ Object (readonly)
color tone
13 14 15 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 13 def tone @tone end |
#weather_power ⇒ Object (readonly)
weather intensity (Float)
18 19 20 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 18 def weather_power @weather_power end |
#weather_type ⇒ Object (readonly)
weather type
17 18 19 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 17 def weather_type @weather_type end |
Instance Method Details
#change_weather(type, power, duration) ⇒ Object
-
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 'lib/rgss3_default_scripts/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 |
#clear ⇒ Object
-
Clear
29 30 31 32 33 34 35 36 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 29 def clear clear_fade clear_tone clear_flash clear_shake clear_weather clear_pictures end |
#clear_fade ⇒ Object
-
Clear Fade In/Out
40 41 42 43 44 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 40 def clear_fade @brightness = 255 @fadeout_duration = 0 @fadein_duration = 0 end |
#clear_flash ⇒ Object
-
Clear Flash
56 57 58 59 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 56 def clear_flash @flash_color = Color.new @flash_duration = 0 end |
#clear_pictures ⇒ Object
-
Clear Picture
82 83 84 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 82 def clear_pictures @pictures.each {|picture| picture.erase } end |
#clear_shake ⇒ Object
-
Clear Shake
63 64 65 66 67 68 69 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 63 def clear_shake @shake_power = 0 @shake_speed = 0 @shake_duration = 0 @shake_direction = 1 @shake = 0 end |
#clear_tone ⇒ Object
-
Clear Color Tone
48 49 50 51 52 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 48 def clear_tone @tone = Tone.new @tone_target = Tone.new @tone_duration = 0 end |
#clear_weather ⇒ Object
-
Clear Weather
73 74 75 76 77 78 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 73 def clear_weather @weather_type = :none @weather_power = 0 @weather_power_target = 0 @weather_duration = 0 end |
#start_fadein(duration) ⇒ Object
-
Start Fadein
95 96 97 98 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 95 def start_fadein(duration) @fadein_duration = duration @fadeout_duration = 0 end |
#start_fadeout(duration) ⇒ Object
-
Start Fadeout
88 89 90 91 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 88 def start_fadeout(duration) @fadeout_duration = duration @fadein_duration = 0 end |
#start_flash(color, duration) ⇒ Object
-
Start Flashing
110 111 112 113 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 110 def start_flash(color, duration) @flash_color = color.clone @flash_duration = duration end |
#start_flash_for_damage ⇒ Object
-
Start Flash (for Poison/Damage Floor)
231 232 233 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 231 def start_flash_for_damage start_flash(Color.new(255,0,0,128), 8) end |
#start_shake(power, speed, duration) ⇒ Object
-
Start Shaking
power: intensity speed: speed
119 120 121 122 123 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 119 def start_shake(power, speed, duration) @shake_power = power @shake_speed = speed @shake_duration = duration end |
#start_tone_change(tone, duration) ⇒ Object
-
Start Changing Color Tone
102 103 104 105 106 |
# File 'lib/rgss3_default_scripts/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 |
#update ⇒ Object
-
Frame Update
141 142 143 144 145 146 147 148 149 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 141 def update update_fadeout update_fadein update_tone update_flash update_shake update_weather update_pictures end |
#update_fadein ⇒ Object
-
Update Fadein
163 164 165 166 167 168 169 |
# File 'lib/rgss3_default_scripts/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 |
#update_fadeout ⇒ Object
-
Update Fadeout
153 154 155 156 157 158 159 |
# File 'lib/rgss3_default_scripts/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 |
#update_flash ⇒ Object
-
Update Flash
186 187 188 189 190 191 192 |
# File 'lib/rgss3_default_scripts/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 |
#update_pictures ⇒ Object
-
Update Pictures
225 226 227 |
# File 'lib/rgss3_default_scripts/Game_Screen.rb', line 225 def update_pictures @pictures.each {|picture| picture.update } end |
#update_shake ⇒ Object
-
Update Shake
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/rgss3_default_scripts/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 |
#update_tone ⇒ Object
-
Update Tone
173 174 175 176 177 178 179 180 181 182 |
# File 'lib/rgss3_default_scripts/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 |
#update_weather ⇒ Object
-
Update Weather
212 213 214 215 216 217 218 219 220 221 |
# File 'lib/rgss3_default_scripts/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 |