mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Added Close game state, tweaked Boot state
This commit is contained in:
@@ -60,7 +60,7 @@ require_relative "lib/ui/menus/level_select_menu"
|
|||||||
require_relative "lib/ui/menus/game_pause_menu"
|
require_relative "lib/ui/menus/game_pause_menu"
|
||||||
|
|
||||||
require_relative "lib/states/game_states/boot"
|
require_relative "lib/states/game_states/boot"
|
||||||
# require_relative "lib/states/game_states/close"
|
require_relative "lib/states/game_states/close"
|
||||||
require_relative "lib/states/game_states/game"
|
require_relative "lib/states/game_states/game"
|
||||||
require_relative "lib/states/game_states/loading_state"
|
require_relative "lib/states/game_states/loading_state"
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class IMICFPS
|
|||||||
def draw_quad(*args)
|
def draw_quad(*args)
|
||||||
window.draw_quad(*args)
|
window.draw_quad(*args)
|
||||||
end
|
end
|
||||||
def fill(color = Gosu::Color::WHITE)
|
def fill(color = Gosu::Color::WHITE, z = 0)
|
||||||
draw_rect(0, 0, window.width, window.height, color)
|
draw_rect(0, 0, window.width, window.height, color, z)
|
||||||
end
|
end
|
||||||
def fill_quad(x1, y1, x2, y2, x3, y3, x4, y4, color = Gosu::Color::WHITE, z = 0, mode = :default)
|
def fill_quad(x1, y1, x2, y2, x3, y3, x4, y4, color = Gosu::Color::WHITE, z = 0, mode = :default)
|
||||||
draw_quad(
|
draw_quad(
|
||||||
|
|||||||
@@ -1,20 +1,25 @@
|
|||||||
class IMICFPS
|
class IMICFPS
|
||||||
class Boot < GameState
|
class Boot < GameState
|
||||||
require_relative "../../../../gosu_more_drawables/lib/gosu_more_drawables/draw_circle"
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@primary_color = Gosu::Color.rgba(255, 127, 0, 200)
|
@primary_color = Gosu::Color.rgba(255, 127, 0, 200)
|
||||||
@accent_color = Gosu::Color.rgba(155, 27, 0, 200)
|
@accent_color = Gosu::Color.rgba(155, 27, 0, 200)
|
||||||
|
|
||||||
|
@color_step = 10
|
||||||
|
@transparency = 200
|
||||||
|
@bar_size = 50
|
||||||
|
@slope = 250
|
||||||
|
|
||||||
@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: "Droid Serif")
|
||||||
@logo = get_image(IMICFPS::GAME_ROOT_PATH + "/static/logo.png")
|
@logo = get_image(IMICFPS::GAME_ROOT_PATH + "/static/logo.png")
|
||||||
|
|
||||||
@start_time = Gosu.milliseconds
|
@start_time = Gosu.milliseconds
|
||||||
@time_to_live = 3_000
|
@time_to_live = 3_000
|
||||||
|
|
||||||
|
window.needs_cursor = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
menu_background(@primary_color, 10, 200, 50, 250)
|
menu_background(@primary_color, @color_step, @transparency, @bar_size, @slope)
|
||||||
|
|
||||||
fraction_left = ((Gosu.milliseconds - @start_time) / (@time_to_live - 200).to_f)
|
fraction_left = ((Gosu.milliseconds - @start_time) / (@time_to_live - 200).to_f)
|
||||||
|
|
||||||
@@ -52,8 +57,12 @@ class IMICFPS
|
|||||||
push_state(MainMenu) if Gosu.milliseconds - @start_time >= @time_to_live
|
push_state(MainMenu) if Gosu.milliseconds - @start_time >= @time_to_live
|
||||||
end
|
end
|
||||||
|
|
||||||
def button_up(id)
|
def button_down(id)
|
||||||
push_state(MainMenu)
|
if id == Gosu::KbEscape or
|
||||||
|
(id >= Gosu::GP_LEFT and id >= Gosu::GP_BUTTON_15) or
|
||||||
|
id == Gosu::MsLeft
|
||||||
|
push_state(MainMenu)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
62
lib/states/game_states/close.rb
Normal file
62
lib/states/game_states/close.rb
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
class IMICFPS
|
||||||
|
class Close < GameState
|
||||||
|
def setup
|
||||||
|
@primary_color = Gosu::Color.rgba(255, 127, 0, 200)
|
||||||
|
@accent_color = Gosu::Color.rgba(155, 27, 0, 200)
|
||||||
|
|
||||||
|
@color_step = 10
|
||||||
|
@transparency = 200
|
||||||
|
@bar_size = 50
|
||||||
|
@slope = 250
|
||||||
|
|
||||||
|
@logo = get_image(IMICFPS::GAME_ROOT_PATH + "/static/logo.png")
|
||||||
|
|
||||||
|
@start_time = Gosu.milliseconds
|
||||||
|
@time_to_live = 3_000
|
||||||
|
|
||||||
|
window.needs_cursor = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
menu_background(@primary_color, @color_step, @transparency, @bar_size, @slope.round)
|
||||||
|
|
||||||
|
fraction_left = 1 - ((Gosu.milliseconds - @start_time) / (@time_to_live - 200).to_f)
|
||||||
|
|
||||||
|
Gosu.draw_quad(
|
||||||
|
0, 0, @primary_color,
|
||||||
|
window.width, 0, @primary_color,
|
||||||
|
window.width, window.height, @accent_color,
|
||||||
|
0, window.height, @accent_color
|
||||||
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
)
|
||||||
|
|
||||||
|
@logo.draw(window.width / 2 - @logo.width / 2, window.height / 2 - @logo.height / 2, 0)
|
||||||
|
|
||||||
|
fill(Gosu::Color.rgba(0,0,0, 255 * (1.1 - fraction_left)))
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
window.close! if Gosu.milliseconds - @start_time >= @time_to_live
|
||||||
|
@slope -= 25 * window.dt
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_down(id)
|
||||||
|
if id == Gosu::KbEscape or
|
||||||
|
(id >= Gosu::GP_LEFT and id >= Gosu::GP_BUTTON_15) or
|
||||||
|
id == Gosu::MsLeft
|
||||||
|
window.close!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -13,7 +13,7 @@ class IMICFPS
|
|||||||
push_state(SettingsMenu)
|
push_state(SettingsMenu)
|
||||||
end
|
end
|
||||||
|
|
||||||
link "Quit" do
|
link "Leave" do
|
||||||
push_state(MainMenu)
|
push_state(MainMenu)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -73,6 +73,10 @@ class IMICFPS
|
|||||||
@delta_time = Gosu.milliseconds
|
@delta_time = Gosu.milliseconds
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def close
|
||||||
|
push_state(Close)
|
||||||
|
end
|
||||||
|
|
||||||
def button_down(id)
|
def button_down(id)
|
||||||
if @show_console
|
if @show_console
|
||||||
@console.button_down(id)
|
@console.button_down(id)
|
||||||
|
|||||||
Reference in New Issue
Block a user