mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-13 06:42:35 +00:00
Breathe a little life into the Boot state
This commit is contained in:
@@ -3,11 +3,43 @@
|
||||
class IMICFPS
|
||||
class Boot < GameState
|
||||
def setup
|
||||
@title = Text.new(IMICFPS::NAME, size: 100, z: 0, color: Gosu::Color.new(0xff000000), shadow: false, font: "Droid Serif")
|
||||
@title = Text.new(IMICFPS::NAME, size: 100, z: 0, color: Gosu::Color.new(0xff000000), shadow: false, font: IMICFPS::BOLD_SANS_FONT)
|
||||
@logo = get_image("#{IMICFPS::GAME_ROOT_PATH}/static/logo.png")
|
||||
|
||||
@start_time = Gosu.milliseconds
|
||||
@time_to_live = 3_000
|
||||
@time_to_live = 5_000
|
||||
|
||||
timing = Gosu.milliseconds
|
||||
@animators = [
|
||||
@fade_animator = CyberarmEngine::Animator.new(
|
||||
start_time: timing,
|
||||
duration: 500,
|
||||
from: 0.0,
|
||||
to: 1.0,
|
||||
tween: :ease_in_out
|
||||
),
|
||||
@logo_animator = CyberarmEngine::Animator.new(
|
||||
start_time: timing += 500,
|
||||
duration: 500,
|
||||
from: 0.0,
|
||||
to: 1.0,
|
||||
tween: :swing_to#:bounce_past
|
||||
),
|
||||
@title_animator = CyberarmEngine::Animator.new(
|
||||
start_time: timing += 1_000,
|
||||
duration: 500,
|
||||
from: 0.0,
|
||||
to: 1.0,
|
||||
tween: :swing_to#:ease_out_circ
|
||||
),
|
||||
@arc_animator = CyberarmEngine::Animator.new(
|
||||
start_time: timing += 500,
|
||||
duration: 2_500,
|
||||
from: 0.0,
|
||||
to: 1.0,
|
||||
tween: :ease_in_out
|
||||
)
|
||||
]
|
||||
|
||||
# SoundManager.sound_effect(SoundEffect::FadeIn, sound: SoundManager.sound("base", :shield_regen), duration: 3_000.0)
|
||||
window.needs_cursor = false
|
||||
@@ -19,34 +51,40 @@ class IMICFPS
|
||||
menu_background(Menu::PRIMARY_COLOR, Menu::ACCENT_COLOR, Menu::BAR_COLOR_STEP, Menu::BAR_ALPHA, Menu::BAR_SIZE, Menu::BAR_SLOPE)
|
||||
|
||||
if fraction_left <= 1.0
|
||||
Gosu.draw_circle(
|
||||
window.width / 2,
|
||||
window.height / 2,
|
||||
@logo.width / 2, 128, Gosu::Color.new(0x11ffffff)
|
||||
)
|
||||
Gosu.scale(@logo_animator.transition, @logo_animator.transition, window.width / 2, window.height / 2) do
|
||||
Gosu.draw_circle(
|
||||
window.width / 2,
|
||||
window.height / 2,
|
||||
@logo.width / 2, 128, Gosu::Color.new(0x11ffffff)
|
||||
)
|
||||
|
||||
Gosu.draw_arc(
|
||||
window.width / 2,
|
||||
window.height / 2,
|
||||
@logo.width / 2, fraction_left.clamp(0.0, 1.0), 128, 8, Gosu::Color.new(0x33ff8800)
|
||||
)
|
||||
Gosu.draw_arc(
|
||||
window.width / 2,
|
||||
window.height / 2,
|
||||
@logo.width / 2, @arc_animator.transition, 128, 8, Gosu::Color.new(0x33ff8800)
|
||||
)
|
||||
|
||||
@logo.draw(window.width / 2 - @logo.width / 2, window.height / 2 - @logo.height / 2, 0)
|
||||
@logo.draw(window.width / 2 - @logo.width / 2, window.height / 2 - @logo.height / 2, 0)
|
||||
end
|
||||
|
||||
@title.draw
|
||||
|
||||
fill(Gosu::Color.rgba(0, 0, 0, 255 * (1.2 - fraction_left)))
|
||||
fill(Gosu::Color.rgba(0, 0, 0, 255 * (1 - @fade_animator.transition)))
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@animators.each(&:update)
|
||||
|
||||
@title.x = window.width / 2 - @title.width / 2
|
||||
@title.y = 0
|
||||
@title.y = (0 - @title.height) + (@title.height * @title_animator.transition)
|
||||
|
||||
push_state(MainMenu) if Gosu.milliseconds - @start_time >= @time_to_live
|
||||
end
|
||||
|
||||
def button_up(id)
|
||||
def button_down(id)
|
||||
super
|
||||
|
||||
if (id == Gosu::KbEscape) ||
|
||||
((id >= Gosu::GP_LEFT) && (id >= Gosu::GP_BUTTON_15)) ||
|
||||
(id == Gosu::MsLeft)
|
||||
|
||||
Reference in New Issue
Block a user