-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimation.rb
156 lines (120 loc) · 4.44 KB
/
animation.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
99
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
149
150
151
152
153
154
155
156
module Animation
def self.initialize()
@@animation = nil
@@speed = 0.3
@@vspeed = 0.0
@@x = 0
@@y = -128
@@color = nil
@@filter_color = nil
@@anim_state = 0
@@star_image = Image.new("res/lsd_star.png")
@@star_x = 0
@@lsd_filter = Image.new("res/lsd_filter.png")
@@lsd_filter_color = Color.new(0, 255, 255, 255)
@@lsd_filter_angle = 0.0
end
def self.launch(animation)
return if @@animation != nil
@@animation = animation
if @@animation == :normal_booster then
@@color = Color.new(128, 128, 128, 128)
@@filter_color = Color.new(0, 0, 0, 0)
@@anim_state = 0
elsif @@animation == :super_booster then
@@color = Color.new(128, 32, 255, 32)
@@filter_color = Color.new(0, 0, 0, 0)
@@anim_state = 0
elsif @@animation == :hyper_booster then
@@color = Color.new(128, 255, 255, 0)
@@filter_color = Color.new(0, 0, 0, 0)
@@anim_state = 0
end
end
def self.update
if @@animation != nil then
if @@anim_state == 0 then
if @@y < $game.settings.default_height / 4 then
@@vspeed += @@speed if @@vspeed < 7.0
else
@@vspeed -= @@speed if @@vspeed > 0.6
@@vspeed = 0.6 if @@vspeed <= 0.6
end
if @@y + 64 > $game.settings.default_height / 2
@@anim_state = 1
end
@@filter_color = Color.new(@@filter_color.alpha + 2, 0, 0, 0) if @@filter_color.alpha < 150
@@y += @@vspeed
if @@lsd_filter_color.alpha < 255 then
@@lsd_filter_color = Color.new(@@lsd_filter_color.alpha + 5, 255, 255, 255)
end
elsif @@anim_state == 1 then
@@vspeed += @@speed
@@y += @@vspeed
@@filter_color = Color.new(@@filter_color.alpha - 3, 0, 0, 0) if @@filter_color.alpha > 0
if @@y > $game.settings.default_height then
Animation::reset()
end
if @@lsd_filter_color.alpha > 0 then
@@lsd_filter_color = Color.new(@@lsd_filter_color.alpha - 5, 255, 255, 255)
end
end
if @@animation == :hyper_booster then
@@star_x += 4
@@lsd_filter_angle += 4.0
end
end
end
def self.draw
if @@animation != nil then
Gosu.draw_rect(0, 0, $game.settings.default_width, $game.settings.default_height, @@filter_color, 500)
if @@animation == :normal_booster then
Gosu.draw_rect(@@x, @@y, $game.settings.default_width, 128, @@color, 500)
$font.draw("Normal Booster",
@@x + ($game.settings.default_width - $font.text_width("Normal Booster")) / 2,
@@y + (128 - $font.height) / 2,
500)
elsif @@animation == :super_booster then
Gosu.draw_rect(@@x, @@y, $game.settings.default_width, 128, @@color, 500)
$font.draw("Super Booster",
@@x + ($game.settings.default_width - $font.text_width("Super Booster")) / 2,
@@y + (128 - $font.height) / 2,
500)
elsif @@animation == :hyper_booster then
# puts @@lsd_filter_angle
@@lsd_filter.draw_rot($game.settings.default_width / 2, $game.settings.default_height / 2, 500,
@@lsd_filter_angle,
0.5,
0.5,
1.0,
1.0,
@@lsd_filter_color)
($game.settings.default_width / 128 + 1).times do |i|
x = @@star_x + i * 128
if x > $game.settings.default_width then
x = @@star_x + i * 128 - $game.settings.default_width - 128
end
@@star_image.draw(x, @@y, 500)
end
Gosu.draw_rect(@@x, @@y, $game.settings.default_width, 128, @@color, 500)
$font.draw("Hyper Booster",
@@x + ($game.settings.default_width - $font.text_width("Hyper Booster")) / 2,
@@y + (128 - $font.height) / 2,
500)
end
end
end
def self.reset
@@speed = 0.3
@@vspeed = 0.0
@@x = 0
@@y = -128
@@color = nil
@@filter_color = nil
@@anim_state = 0
@@animation = nil
@@star_x = 0
@@lsd_filter_color = Color.new(0, 255, 255, 255)
@@lsd_filter_angle = 0.0
end
end