mirror of
https://github.com/cyberarm/i-mic-rts.git
synced 2025-12-13 14:52:35 +00:00
Redid menus, stubbed Entity
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/vehicles/harvester/images/harvester.png
Normal file
BIN
assets/vehicles/harvester/images/harvester.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 734 B |
19
i-mic-rts.rb
19
i-mic-rts.rb
@@ -1,20 +1,19 @@
|
|||||||
require "base64"
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
require "cyberarm_engine"
|
require "cyberarm_engine"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require_relative "lib/window"
|
||||||
|
|
||||||
require_relative "lib/states/boot"
|
require_relative "lib/states/boot"
|
||||||
|
require_relative "lib/states/game"
|
||||||
|
require_relative "lib/states/closing"
|
||||||
|
require_relative "lib/states/about_menu"
|
||||||
require_relative "lib/states/main_menu"
|
require_relative "lib/states/main_menu"
|
||||||
|
|
||||||
class Window < CyberarmEngine::Engine
|
require_relative "lib/zorder"
|
||||||
def setup
|
require_relative "lib/entity"
|
||||||
self.caption = "I-MIC RTS (#{Gosu.language})"
|
# require_relative "lib/entities/"
|
||||||
push_state(MainMenu)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Window.new(Gosu.screen_width, Gosu.screen_height, true).show
|
IMICRTS::Window.new(width: Gosu.screen_width, height: Gosu.screen_height, fullscreen: true).show
|
||||||
Window.new(width: Gosu.screen_width/2, height: Gosu.screen_height/2, fullscreen: false).show
|
|
||||||
13
lib/entity.rb
Normal file
13
lib/entity.rb
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class Entity
|
||||||
|
def initialize(images:, position:, angle:)
|
||||||
|
@images = images
|
||||||
|
@position = position
|
||||||
|
@angle = angle
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
@images.draw_rot(@position.x, @position.y, @position.z, @angle)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
18
lib/states/about_menu.rb
Normal file
18
lib/states/about_menu.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class AboutMenu < CyberarmEngine::GuiState
|
||||||
|
def setup
|
||||||
|
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||||
|
|
||||||
|
stack(height: 1.0) do
|
||||||
|
background [0xff555555, Gosu::Color::GRAY]
|
||||||
|
|
||||||
|
label "About I-MIC-RTS", text_size: 78, margin: 20
|
||||||
|
label "Words go here.\nMore words also go here. Thank you and have a nice day."
|
||||||
|
|
||||||
|
button("Back", width: 1.0) do
|
||||||
|
push_state(MainMenu)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,76 +1,78 @@
|
|||||||
class Boot < CyberarmEngine::GameState
|
class IMICRTS
|
||||||
def setup
|
class Boot < CyberarmEngine::GameState
|
||||||
@title = Gosu::Font.new(56, name: "Noto Sans Display", bold: true)
|
def setup
|
||||||
@text = Gosu::Font.new(18, name: "Noto Sans Thaana", bold: true)
|
@title = Gosu::Font.new(56, name: "Noto Sans Display", bold: true)
|
||||||
@name = "I-MIC RTS"
|
@text = Gosu::Font.new(18, name: "Noto Sans Thaana", bold: true)
|
||||||
@logo = Gosu::Image.new("assets/logo.png")
|
@name = "I-MIC RTS"
|
||||||
|
@logo = Gosu::Image.new("assets/logo.png")
|
||||||
|
|
||||||
@messages = ["Loading", "Compiling Protons", "Launching Warhead", "git push origin --force"]
|
@messages = ["Loading", "Compiling Protons", "Launching Warhead", "git push origin --force"]
|
||||||
@messages_index = 0
|
@messages_index = 0
|
||||||
@status = @messages[@messages_index]
|
@status = @messages[@messages_index]
|
||||||
|
|
||||||
@last_update = Gosu.milliseconds
|
@last_update = Gosu.milliseconds
|
||||||
@update_interval = 250
|
@update_interval = 250
|
||||||
|
|
||||||
@switcher = CyberarmEngine::Timer.new(5_000) do
|
@switcher = CyberarmEngine::Timer.new(5_000) do
|
||||||
push_state(MainMenu)
|
push_state(MainMenu)
|
||||||
end
|
|
||||||
|
|
||||||
@loader = CyberarmEngine::Timer.new(250) do
|
|
||||||
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
|
||||||
|
|
||||||
|
@loader = CyberarmEngine::Timer.new(250) do
|
||||||
|
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
|
||||||
|
|
||||||
|
@background = Gosu::Color.new(0x007a0d71)
|
||||||
|
@background_two = Gosu::Color.new(0x007b6ead)
|
||||||
|
|
||||||
|
$window.width = Gosu.screen_width
|
||||||
|
$window.height = Gosu.screen_height
|
||||||
|
$window.fullscreen = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@background = Gosu::Color.new(0x007a0d71)
|
def draw
|
||||||
@background_two = Gosu::Color.new(0x007b6ead)
|
Gosu.draw_quad(
|
||||||
|
0, 0, @background_two,
|
||||||
|
$window.width, 0, @background,
|
||||||
|
0, $window.height, @background,
|
||||||
|
$window.width, $window.height, @background_two
|
||||||
|
)
|
||||||
|
|
||||||
$window.width = Gosu.screen_width
|
Gosu.draw_rect(
|
||||||
$window.height = Gosu.screen_height
|
0, $window.height/2 - 35,
|
||||||
$window.fullscreen = true
|
$window.width, 71,
|
||||||
end
|
Gosu::Color.new(0xff949dad)
|
||||||
|
)
|
||||||
|
|
||||||
def draw
|
c = Gosu::Color.new(0xff55dae1)
|
||||||
Gosu.draw_quad(
|
c2 = Gosu::Color.new(0xff3c9ec5)
|
||||||
0, 0, @background_two,
|
Gosu.draw_quad(
|
||||||
$window.width, 0, @background,
|
0, $window.height/2 - 30, c,
|
||||||
0, $window.height, @background,
|
$window.width, $window.height/2 - 30, c2,
|
||||||
$window.width, $window.height, @background_two
|
0, $window.height/2 + 30, c,
|
||||||
)
|
$window.width, $window.height/2 + 30, c2
|
||||||
|
)
|
||||||
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)
|
@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)
|
@text.draw_text(@status, $window.width - (@text.text_width(@status.gsub(".", "")) + @text.text_width("...")), $window.height - @text.height, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
self.show_cursor = false
|
self.show_cursor = false
|
||||||
|
|
||||||
@background.alpha+=1
|
@background.alpha+=1
|
||||||
@background_two.alpha+=1
|
@background_two.alpha+=1
|
||||||
|
|
||||||
@switcher.update
|
@switcher.update
|
||||||
@loader.update
|
@loader.update
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
28
lib/states/closing.rb
Normal file
28
lib/states/closing.rb
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class Closing < CyberarmEngine::GuiState
|
||||||
|
def setup
|
||||||
|
@logo = Gosu::Image.new("assets/logo.png")
|
||||||
|
@color = Gosu::Color.new(0xffffffff)
|
||||||
|
|
||||||
|
@started_at = Gosu.milliseconds
|
||||||
|
@close_time = 3_000
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
Gosu.draw_rect(0, 0, window.width, window.height, @color)
|
||||||
|
@logo.draw(window.width / 2 - @logo.width / 2, window.height / 2 - @logo.height / 2, 2, 1.0, 1.0, @color)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
super
|
||||||
|
factor = (1.0 - ((Gosu.milliseconds - @started_at) / @close_time.to_f)).clamp(0.0, 1.0)
|
||||||
|
@color.alpha = 255 * (factor - 0.1)
|
||||||
|
|
||||||
|
window.close if Gosu.milliseconds - @started_at >= @close_time
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_up(id)
|
||||||
|
window.close if id == Gosu::KB_ESCAPE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
47
lib/states/game.rb
Normal file
47
lib/states/game.rb
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class Game < CyberarmEngine::GuiState
|
||||||
|
def setup
|
||||||
|
@units = []
|
||||||
|
|
||||||
|
stack(height: 1.0) do
|
||||||
|
background [0xff555555, Gosu::Color::GRAY]
|
||||||
|
|
||||||
|
label "SIDEBAR", text_size: 78
|
||||||
|
label ""
|
||||||
|
|
||||||
|
button("Harvest", width: 1.0) do
|
||||||
|
@units << Entity.new(
|
||||||
|
images: Gosu::Image.new("assets/vehicles/harvester/images/harvester.png", retro: true),
|
||||||
|
position: CyberarmEngine::Vector.new(rand(window.width), rand(window.height), ZOrder::GROUND_VEHICLE),
|
||||||
|
angle: rand(360)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
button("Construction Worker", width: 1.0) do
|
||||||
|
@units << Entity.new(
|
||||||
|
images: Gosu::Image.new("assets/vehicles/construction_worker/images/construction_worker.png", retro: true),
|
||||||
|
position: CyberarmEngine::Vector.new(rand(window.width), rand(window.height), ZOrder::GROUND_VEHICLE),
|
||||||
|
angle: rand(360)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
label ""
|
||||||
|
|
||||||
|
button("Leave", width: 1.0) do
|
||||||
|
finalize
|
||||||
|
push_state(MainMenu)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
super
|
||||||
|
Gosu.draw_rect(0, 0, window.width, window.height, Gosu::Color.rgb(10, 175, 35))
|
||||||
|
|
||||||
|
@units.each(&:draw)
|
||||||
|
end
|
||||||
|
|
||||||
|
def finalize
|
||||||
|
# TODO: Release bound objects/remove self from Window.states array
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,53 +1,25 @@
|
|||||||
class MainMenu < CyberarmEngine::GuiState
|
class IMICRTS
|
||||||
def setup
|
class MainMenu < CyberarmEngine::GuiState
|
||||||
self.show_cursor = true
|
def setup
|
||||||
|
self.show_cursor = true
|
||||||
|
|
||||||
@container = stack do
|
background [0xff7b6ead, 0xff7a0d71, 0xff7a0d71, 0xff7b6ead]
|
||||||
background 0xff00aa00
|
|
||||||
|
|
||||||
flow do
|
stack(height: 1.0) do
|
||||||
|
background [0xff555555, Gosu::Color::GRAY]
|
||||||
stack(height: 1.0) do
|
label "I-MIC-RTS", text_size: 78, margin: 20
|
||||||
background Gosu::Color.rgba(50, 50, 50, 200)
|
button("Play", width: 1.0) do
|
||||||
button("Play")
|
push_state(Game)
|
||||||
button("About")
|
|
||||||
button("Exit") do
|
|
||||||
$window.close
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
stack do
|
button("About", width: 1.0) do
|
||||||
image("assets/logo.png", height: 275) do
|
push_state(AboutMenu)
|
||||||
pop_state if previous_state
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
stack do
|
button("Exit", width: 1.0) do
|
||||||
background Gosu::Color.rgba(50, 50, 50, 200)
|
push_state(Closing)
|
||||||
|
|
||||||
1.times do
|
|
||||||
label "Username"
|
|
||||||
@username = edit_line ""
|
|
||||||
label "Password"
|
|
||||||
@password = edit_line "", type: :password
|
|
||||||
|
|
||||||
check_box "Remember me?", checked: true
|
|
||||||
|
|
||||||
flow do
|
|
||||||
button "Log In" do
|
|
||||||
push_state(Boot)
|
|
||||||
puts "Logging in... #{@username.value}:#{Base64.encode64(@password.value)}"
|
|
||||||
end
|
|
||||||
button "Sign Up"
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
$window.width = @container.width
|
|
||||||
$window.height = @container.height
|
|
||||||
$window.fullscreen = false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
11
lib/window.rb
Normal file
11
lib/window.rb
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class Window < CyberarmEngine::Engine
|
||||||
|
def setup
|
||||||
|
Gosu.milliseconds # Start counter
|
||||||
|
|
||||||
|
self.caption = "I-MIC RTS (#{Gosu.language})"
|
||||||
|
push_state(Boot)
|
||||||
|
# push_state(MainMenu)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
12
lib/zorder.rb
Normal file
12
lib/zorder.rb
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
class IMICRTS
|
||||||
|
class ZOrder
|
||||||
|
base_z = 5
|
||||||
|
enum = [
|
||||||
|
:GROUND_VEHICLE
|
||||||
|
]
|
||||||
|
|
||||||
|
enum.each_with_index do |constant, index|
|
||||||
|
self.const_set(constant, index + base_z)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user