Added title screen sound, added sound when mousing over menu links, update "required" Ruby version to 3.0+ in README

This commit is contained in:
2021-06-03 03:05:10 +00:00
parent 3986b1b0af
commit ec2b32ff92
6 changed files with 20 additions and 2 deletions

View File

@@ -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]`

13
lib/ext/element.rb Normal file
View File

@@ -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

View File

@@ -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

View File

@@ -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

Binary file not shown.

BIN
static/sounds/ui_hover.ogg Normal file

Binary file not shown.