Added require_all method to replace explicitly requiring every source file, added SoundManager and sound effects, added sound for shield/health regen

This commit is contained in:
2020-05-08 19:03:45 -05:00
parent bc695df4a1
commit e3a2c9abe0
13 changed files with 197 additions and 106 deletions

View File

@@ -0,0 +1,32 @@
class IMICFPS
class SoundEffect
class FadeIn < SoundEffect
def setup
@start_time = Gosu.milliseconds
@duration = @options[:duration] # in milliseconds
@initial_volume = @options[:volume] ? @options[:volume] : 0.0
@sound = @options[:sound]
raise "duration not specified!" unless @duration
@channel = @sound.play(calculate_volume)
end
def ratio
(Gosu.milliseconds - @start_time.to_f) / @duration
end
def calculate_volume
volume = (SoundManager.sfx_volume - @initial_volume) * ratio
end
def update
@channel.volume = calculate_volume
end
def done?
(Gosu.milliseconds - @start_time.to_f) / @duration >= 1.0
end
end
end
end