-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmovie.rb
78 lines (73 loc) · 2.21 KB
/
movie.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
# Copyright 2019 Victor David Santos
#
# This file is part of Super Bombinhas.
#
# Super Bombinhas is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Super Bombinhas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Super Bombinhas. If not, see <https://www.gnu.org/licenses/>.
require_relative 'global'
class Movie
def initialize(id)
@id = id
files = Dir["#{Res.prefix}img/movie/#{id}-*"].sort
@scenes = []
files.each do |f|
@scenes << Res.img("movie_#{f.split('/')[-1].chomp('.png')}")
end
@scene = @timer = 0
@alpha = 255
@changing = 1
@time_limit = id == 0 ? 890 : 1595
SB.play_song(Res.song(id == 0 ? :movieSad : :movie))
end
def update
if @changing
@alpha += @changing == 0 ? 5 : -5
if @alpha == 255
@changing = 1
@timer = 0
@scene += 1
@texts = nil
finish if @scene == @scenes.length
elsif @alpha == 0
@texts = SB.text("movie_#{@id}_#{@scene}").split('/')
@changing = nil
end
else
@timer += 1
@changing = 0 if SB.key_pressed?(:confirm) || @timer == @time_limit
end
end
def finish
if @id == 0
SB.start_new_game
else
SB.next_world
end
end
def draw
@scenes[@scene].draw(80, 20, 0, 2, 2)
@texts.each_with_index do |text, i|
next if @timer <= i * 60
alpha = ((@timer - i * 60).to_f / 60 * 255).round
alpha = 255 if alpha > 255
SB.text_helper.write_breaking(text, 80, 280 + i * 100, 640, :justified, 0xffffff, alpha)
end if @texts
if @changing
c = @alpha << 24
G.window.draw_quad 0, 0, c,
C::SCREEN_WIDTH, 0, c,
0, C::SCREEN_HEIGHT, c,
C::SCREEN_WIDTH, C::SCREEN_HEIGHT, c, 0
end
end
end