From 0b3897451e0ad5b6f483e1e9f7a6333a43c86e93 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Thu, 31 Dec 2020 08:41:40 -0600 Subject: [PATCH] Added team colors hash --- i-mic-rts.rb | 1 + lib/player.rb | 2 +- lib/team_colors.rb | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 lib/team_colors.rb diff --git a/i-mic-rts.rb b/i-mic-rts.rb index 9a62256..14fcf45 100755 --- a/i-mic-rts.rb +++ b/i-mic-rts.rb @@ -18,6 +18,7 @@ require_relative "lib/errors" require_relative "lib/window" require_relative "lib/camera" require_relative "lib/setting" +require_relative "lib/team_colors" require_relative "lib/states/boot" require_relative "lib/states/game" diff --git a/lib/player.rb b/lib/player.rb index 653416c..492a4de 100644 --- a/lib/player.rb +++ b/lib/player.rb @@ -2,7 +2,7 @@ class IMICRTS class Player attr_reader :id, :name, :color, :team, :entities, :orders, :camera, :spawnpoint attr_reader :selected_entities - def initialize(id:, spawnpoint:, name: nil, color: Gosu::Color.rgb(rand(150..200), rand(100..200), rand(150..200)), team: nil) + def initialize(id:, spawnpoint:, name: nil, color: IMICRTS::TeamColors.values.sample, team: nil) @id = id @spawnpoint = spawnpoint @name = name ? name : "Novice-#{id}" diff --git a/lib/team_colors.rb b/lib/team_colors.rb new file mode 100644 index 0000000..97c5aba --- /dev/null +++ b/lib/team_colors.rb @@ -0,0 +1,16 @@ +class IMICRTS + TeamColors = { + lightred: Gosu::Color.rgb(255, 100, 100), + red: Gosu::Color::RED, + lightblue: Gosu::Color.rgb(100, 100, 255), + blue: Gosu::Color::BLUE, + lime: Gosu::Color::GREEN, + lightgreen: Gosu::Color.rgb(50, 200, 50), + green: Gosu::Color.rgb(0, 200, 0), + orange: Gosu::Color.rgb(255, 127, 0), + gold: Gosu::Color::YELLOW, + lightgray: Gosu::Color::WHITE, + gray: Gosu::Color::GRAY, + black: Gosu::Color.rgb(25, 25, 25), + } +end \ No newline at end of file