From 31b0cb31172b7ccdf8d40b259ca7da61852de393 Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Wed, 30 Jan 2019 13:39:02 -0600 Subject: [PATCH] Added main menu which is currently not yet functional --- assets/.gitkeep | 0 data/.gitkeep | 0 i-mic-rts.rb | 78 +++++++---------------------------------- lib/server/.gitkeep | 0 lib/states/.gitkeep | 0 lib/states/boot.rb | 73 ++++++++++++++++++++++++++++++++++++++ lib/states/main_menu.rb | 23 ++++++++++++ 7 files changed, 108 insertions(+), 66 deletions(-) create mode 100644 assets/.gitkeep create mode 100644 data/.gitkeep create mode 100644 lib/server/.gitkeep create mode 100644 lib/states/.gitkeep create mode 100644 lib/states/boot.rb create mode 100644 lib/states/main_menu.rb diff --git a/assets/.gitkeep b/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/.gitkeep b/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/i-mic-rts.rb b/i-mic-rts.rb index 5017a01..d3d5a18 100644 --- a/i-mic-rts.rb +++ b/i-mic-rts.rb @@ -1,71 +1,17 @@ -require "gosu" +begin + require "cyberarm_engine" +rescue LoadError + require_relative "../cyberarm_engine/lib/cyberarm_engine" +end -class Window < Gosu::Window - def initialize - super(Gosu.screen_width, Gosu.screen_height, fullscreen: true) - @title = Gosu::Font.new(56, name: "Noto Sans Display", bold: true) - @text = Gosu::Font.new(18, name: "Noto Sans Thaana", bold: true) - @name = "I-MIC RTS" - @logo = Gosu::Image.new("../../Documents/Inkscape/ruby_clan_logo-i_mic_rts.png") +require_relative "lib/states/boot" +require_relative "lib/states/main_menu" - @messages = ["Loading", "Compiling Protons", "Launching Warhead", "git push origin --force"] - @messages_index = 0 - @status = @messages[@messages_index] - - @last_update = Gosu.milliseconds - @update_interval = 250 - - @background = Gosu::Color.new(0x007a0d71) - @background_two = Gosu::Color.new(0x007b6ead) - end - - def draw - draw_quad( - 0, 0, @background_two, - self.width, 0, @background, - 0, self.height, @background, - self.width, self.height, @background_two - ) - - draw_rect( - 0, self.height/2 - 35, - self.width, 71, - Gosu::Color.new(0xff949dad) - ) - - c = Gosu::Color.new(0xff55dae1) - c2 = Gosu::Color.new(0xff3c9ec5) - draw_quad( - 0, self.height/2 - 30, c, - self.width, self.height/2 - 30, c2, - 0, self.height/2 + 30, c, - self.width, self.height/2 + 30, c2 - ) - - - @logo.draw(self.width/2 - @logo.width/2, self.height/2 - (@logo.height/3 + 14), 0) - - @text.draw_text(@status, self.width - (@text.text_width(@status.gsub(".", "")) + @text.text_width("...")), self.height - @text.height, 0) - end - - def update - @background.alpha+=1 - @background_two.alpha+=1 - - if Gosu.milliseconds > @last_update + @update_interval - @last_update = Gosu.milliseconds - - - split = @status.scan(".") - if split.size >= 3 - @messages_index+=1 - @messages_index = 0 unless @messages_index < @messages.size - @status = @messages[@messages_index] - else - @status = "#{@status}." - end - end +class Window < CyberarmEngine::Engine + def setup + self.caption = "I-MIC RTS (#{Gosu.language})" + push_state(Boot) end end -Window.new.show \ No newline at end of file +Window.new(Gosu.screen_width, Gosu.screen_height, false).show \ No newline at end of file diff --git a/lib/server/.gitkeep b/lib/server/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/states/.gitkeep b/lib/states/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/lib/states/boot.rb b/lib/states/boot.rb new file mode 100644 index 0000000..03b3e42 --- /dev/null +++ b/lib/states/boot.rb @@ -0,0 +1,73 @@ +class Boot < CyberarmEngine::GameState + def setup + @title = Gosu::Font.new(56, name: "Noto Sans Display", bold: true) + @text = Gosu::Font.new(18, name: "Noto Sans Thaana", bold: true) + @name = "I-MIC RTS" + @logo = Gosu::Image.new("../../Documents/Inkscape/ruby_clan_logo-i_mic_rts.png") + + @messages = ["Loading", "Compiling Protons", "Launching Warhead", "git push origin --force"] + @messages_index = 0 + @status = @messages[@messages_index] + + @last_update = Gosu.milliseconds + @update_interval = 250 + + @background = Gosu::Color.new(0x007a0d71) + @background_two = Gosu::Color.new(0x007b6ead) + + @boot_life = 5_000 + @boot_started = Gosu.milliseconds + end + + def draw + Gosu.draw_quad( + 0, 0, @background_two, + $window.width, 0, @background, + 0, $window.height, @background, + $window.width, $window.height, @background_two + ) + + Gosu.draw_rect( + 0, $window.height/2 - 35, + $window.width, 71, + Gosu::Color.new(0xff949dad) + ) + + c = Gosu::Color.new(0xff55dae1) + c2 = Gosu::Color.new(0xff3c9ec5) + Gosu.draw_quad( + 0, $window.height/2 - 30, c, + $window.width, $window.height/2 - 30, c2, + 0, $window.height/2 + 30, c, + $window.width, $window.height/2 + 30, c2 + ) + + + @logo.draw($window.width/2 - @logo.width/2, $window.height/2 - (@logo.height/3 + 14), 0) + + @text.draw_text(@status, $window.width - (@text.text_width(@status.gsub(".", "")) + @text.text_width("...")), $window.height - @text.height, 0) + end + + def update + @background.alpha+=1 + @background_two.alpha+=1 + + if Gosu.milliseconds > @boot_started + @boot_life + push_state(MainMenu) + end + + if Gosu.milliseconds > @last_update + @update_interval + @last_update = Gosu.milliseconds + + + split = @status.scan(".") + if split.size >= 3 + @messages_index+=1 + @messages_index = 0 unless @messages_index < @messages.size + @status = @messages[@messages_index] + else + @status = "#{@status}." + end + end + end +end \ No newline at end of file diff --git a/lib/states/main_menu.rb b/lib/states/main_menu.rb new file mode 100644 index 0000000..0b3abbd --- /dev/null +++ b/lib/states/main_menu.rb @@ -0,0 +1,23 @@ +class MainMenu < CyberarmEngine::Container + def setup + show_cursor = true + set_layout_y(10, 20) + + flow(width: $window.width, padding: 10, margin: 10) do + image("assets/logo_small.png") + text "Main Menu", align: "center", size: 30 + end + + stack(width: 250) do + button("Play") + button("About") + button("Exit") do + close + end + end + end + + def draw + fill(Gosu::Color.new(0xff7a0d71)) + end +end \ No newline at end of file