diff --git a/README.md b/README.md index bfb8114..219594c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Creating a multiplayer first-person-shooter in pure Ruby; Using C extensions onl ![screenshot](https://raw.githubusercontent.com/cyberarm/i-mic-fps/master/screenshots/screenshot-game.png) ## Using -Ruby 2.5+ interpeter with support for the Gosu game library C extension. +Ruby 3.0+ interpeter with support for the Gosu game library C extension. * Clone or download this repo * `bundle install` * `bundle exec ruby i-mic-fps.rb [options]` diff --git a/lib/ext/element.rb b/lib/ext/element.rb new file mode 100644 index 0000000..605aa78 --- /dev/null +++ b/lib/ext/element.rb @@ -0,0 +1,13 @@ +module CyberarmEngine + class Element + alias enter_original enter + + def enter(_sender) + if @block && is_a?(CyberarmEngine::Element::Link) + get_sample("#{IMICFPS::GAME_ROOT_PATH}/static/sounds/ui_hover.ogg").play + end + + enter_original(_sender) + end + end +end \ No newline at end of file diff --git a/lib/sound_effects/fade_in.rb b/lib/sound_effects/fade_in.rb index 0a77721..4a1a501 100644 --- a/lib/sound_effects/fade_in.rb +++ b/lib/sound_effects/fade_in.rb @@ -19,7 +19,7 @@ class IMICFPS end def calculate_volume - volume = (SoundManager.sfx_volume - @initial_volume) * ratio + (SoundManager.sfx_volume - @initial_volume) * ratio end def update diff --git a/lib/states/game_states/boot.rb b/lib/states/game_states/boot.rb index 0cdfa34..db15437 100644 --- a/lib/states/game_states/boot.rb +++ b/lib/states/game_states/boot.rb @@ -6,6 +6,8 @@ class IMICFPS @title = Text.new(IMICFPS::NAME, size: 100, z: 0, color: Gosu::Color.new(0xff000000), border: false, font: IMICFPS::BOLD_SANS_FONT) @logo = get_image("#{IMICFPS::GAME_ROOT_PATH}/static/logo.png") + @title_screen_sound = get_sample("#{IMICFPS::GAME_ROOT_PATH}/static/sounds/title_screen.ogg") + @start_time = Gosu.milliseconds @time_to_live = 5_000 @@ -43,6 +45,8 @@ class IMICFPS # SoundManager.sound_effect(SoundEffect::FadeIn, sound: SoundManager.sound("base", :shield_regen), duration: 3_000.0) window.needs_cursor = false + + @title_screen_sound_channel = @title_screen_sound.play(1.0) end def draw @@ -88,6 +92,7 @@ class IMICFPS def button_down(id) super + @title_screen_sound_channel.stop push_state(MainMenu) end end diff --git a/static/sounds/title_screen.ogg b/static/sounds/title_screen.ogg new file mode 100644 index 0000000..432a134 Binary files /dev/null and b/static/sounds/title_screen.ogg differ diff --git a/static/sounds/ui_hover.ogg b/static/sounds/ui_hover.ogg new file mode 100644 index 0000000..d1a24b1 Binary files /dev/null and b/static/sounds/ui_hover.ogg differ