Class: Game_Screen

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

Overview

Update every component that affect the screen

Constant Summary collapse

NEUTRAL_TONE =
Tone.new(0, 0, 0, 0)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGame_Screen

default initializer



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 13

def initialize
  @tone = Tone.new(0, 0, 0, 0)
  @tone_target = Tone.new(0, 0, 0, 0)
  @tone_duration = 0
  @flash_color = Color.new(0, 0, 0, 0)
  @flash_duration = 0
  @shake_power = 0
  @shake_speed = 0
  @shake_duration = 0
  @shake_direction = 1
  @shake = 0
  @pictures = [nil]
  for i in 1..100
    @pictures.push(Game_Picture.new(i))
  end
  @weather_type = 0
  @weather_max = 0.0
  @weather_type_target = 0
  @weather_max_target = 0.0
  @weather_duration = 0
end

Instance Attribute Details

#flash_color (readonly)

フラッシュ色



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

def flash_color
  @flash_color
end

#pictures (readonly)

ピクチャ



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

def pictures
  @pictures
end

#shake (readonly)

シェイク位置



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

def shake
  @shake
end

#tone (readonly)

色調



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

def tone
  @tone
end

#weather_max (readonly)

天候 画像の最大数



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

def weather_max
  @weather_max
end

#weather_type (readonly)

天候 タイプ



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

def weather_type
  @weather_type
end

Instance Method Details

#start_flash(color, duration)

start a flash process

Parameters:

  • color (Color)

    a color

  • duration (Integer)

    the time it takes in frame



47
48
49
50
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 47

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

#start_shake(power, speed, duration)

start a screen shake process

Parameters:

  • power (Integer)

    the power of the shake (distance between normal position and shake limit position)

  • speed (Integer)

    the speed of the shake (10 = 4 frame to get one shake period)

  • duration (Integer)

    the time the shake lasts



55
56
57
58
59
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 55

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

#start_tone_change(tone, duration)

start a tone change process

Parameters:

  • tone (Tone)

    the new tone

  • duration (Integer)

    the time it takes in frame



37
38
39
40
41
42
43
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 37

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 every process and picture



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
142
143
144
145
146
147
148
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 100

def update
  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 @flash_duration >= 1
    d = @flash_duration
    @flash_color.alpha = @flash_color.alpha * (d - 1) / d
    @flash_duration -= 1
  end
  if @shake_duration >= 1 or @shake != 0
    delta = (@shake_power * @shake_speed * @shake_direction) / 10.0
    if @shake_duration <= 1 and @shake * (@shake + delta) < 0
      @shake = 0
    else
      @shake += delta
    end
    if @shake > @shake_power * 2
      @shake_direction = -1
    end
    if @shake < - @shake_power * 2
      @shake_direction = 1
    end
    if @shake_duration >= 1
      @shake_duration -= 1
    end
  end
  if @weather_duration >= 1
    d = @weather_duration
    @weather_max = (@weather_max * (d - 1) + @weather_max_target) / d
    @weather_duration -= 1
    if @weather_duration == 0
      @weather_type = @weather_type_target
    end
  end
  if $game_temp.in_battle
    for i in 51..100
      @pictures[i].update
    end
  else
    for i in 1..50
      @pictures[i].update
    end
  end
end

#weather(type, power, duration, psdk_weather: nil)

starts a weather change process

Parameters:

  • type (Integer)

    the type of the weather

  • power (Numeric)

    The power of the weather

  • duration (Integer)

    the time it takes to change the weather

  • psdk_weather (Integer, nil) (defaults to: nil)

    the PSDK weather type



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'scripts/01450 Systems/00003 Map Engine/00001 Graphics/02000 Game_Screen.rb', line 65

def weather(type, power, duration, psdk_weather: nil)
  #> Set weather to PSDK
  unless psdk_weather
    case type
    when 1, 2 #Rain / Storm
      $env.apply_weather(1)
      type = 1
    when 3 # Snow
      $env.apply_weather(4)
      type = 4
    else
      $env.apply_weather(0, 0)
      type = 0
    end
  else
    type = psdk_weather
    $env.apply_weather(psdk_weather)
  end
  #> Define Weather
  @weather_type_target = type
  if @weather_type_target != 0
    @weather_type = @weather_type_target
  end
  if @weather_type_target == 0
    @weather_max_target = 0.0
  else
    @weather_max_target = (power + 1) * 4.0
  end
  @weather_duration = duration
  if @weather_duration == 0
    @weather_type = @weather_type_target
    @weather_max = @weather_max_target
  end
end