mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Updated Field/Robot/Simulator to use parent container's z index to remove need for Gosu.flush and causing Field to be drawn on top of tooltip's and menus, Added Power Play field, replaced font, enabled static option for text to improve rendering appearance, misc. bug fixes and tweaks.
This commit is contained in:
@@ -12,14 +12,14 @@ module TAC
|
||||
@scale = 1
|
||||
@size = 0
|
||||
@field_size = 144 # inches [1 pixel = 1 inch]
|
||||
@z = @container.z + 1
|
||||
|
||||
@blue = Gosu::Color.new(0xff_004080)
|
||||
@red = Gosu::Color.new(0xff_800000)
|
||||
@soft_orange = Gosu::Color.rgb(255, 175, 0)
|
||||
end
|
||||
|
||||
def draw
|
||||
Gosu.flush
|
||||
|
||||
Gosu.clip_to(@position.x, @position.y, @size, @size) do
|
||||
Gosu.translate(@position.x, @position.y) do
|
||||
draw_field
|
||||
@@ -34,88 +34,90 @@ module TAC
|
||||
end
|
||||
|
||||
def draw_field
|
||||
Gosu.draw_rect(0, 0, @field_size * @scale, @field_size * @scale, Gosu::Color::GRAY)
|
||||
Gosu.draw_rect(0, 0, @field_size * @scale, @field_size * @scale, Gosu::Color::GRAY, @z)
|
||||
6.times do |i| # Tile lines across
|
||||
next if i == 0
|
||||
Gosu.draw_rect((@field_size * @scale) / 6 * i, 0, 1, @field_size * @scale, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect((@field_size * @scale) / 6 * i, 0, 1, @field_size * @scale, Gosu::Color::BLACK, @z)
|
||||
end
|
||||
6.times do |i| # Tile lines down
|
||||
next if i == 0
|
||||
Gosu.draw_rect(0, (@field_size * @scale) / 6 * i, @field_size * @scale, 1, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(0, (@field_size * @scale) / 6 * i, @field_size * @scale, 1, Gosu::Color::BLACK, @z)
|
||||
end
|
||||
end
|
||||
|
||||
def draw_field_skystone
|
||||
# blue bridge
|
||||
Gosu.draw_rect(0, @field_size / 2 - 2, 48, 1, @blue)
|
||||
Gosu.draw_rect(0, @field_size / 2 + 1, 48, 1, @blue)
|
||||
Gosu.draw_rect(0, @field_size / 2 - 2, 48, 1, @blue, @z)
|
||||
Gosu.draw_rect(0, @field_size / 2 + 1, 48, 1, @blue, @z)
|
||||
|
||||
# mid bridge
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 - 9.25, 48, 18.5, Gosu::Color.new(0xff_222222))
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 - 2, 48, 1, Gosu::Color::YELLOW)
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 + 1, 48, 1, Gosu::Color::YELLOW)
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 - 9.25, 48, 18.5, Gosu::Color.new(0xff_222222), @z)
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 - 2, 48, 1, @soft_orange, @z)
|
||||
Gosu.draw_rect(@field_size / 2 - 24, @field_size / 2 + 1, 48, 1, @soft_orange, @z)
|
||||
|
||||
# blue bridge
|
||||
Gosu.draw_rect(@field_size - 48, @field_size / 2 - 2, 48, 1, @red)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size / 2 + 1, 48, 1, @red)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size / 2 - 2, 48, 1, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size / 2 + 1, 48, 1, @red, @z)
|
||||
|
||||
# blue build site
|
||||
Gosu.draw_quad(
|
||||
24 - 2, 0, @blue,
|
||||
24, 0, @blue,
|
||||
0, 24 - 2, @blue,
|
||||
0, 24, @blue
|
||||
)
|
||||
0, 24, @blue,
|
||||
@z
|
||||
)
|
||||
|
||||
# red build site
|
||||
Gosu.draw_quad(
|
||||
@field_size - (24 - 2), 0, @red,
|
||||
@field_size - (24 - 0), 0, @red,
|
||||
@field_size, 24 - 2, @red,
|
||||
@field_size, 24, @red
|
||||
)
|
||||
@field_size, 24, @red,
|
||||
@z
|
||||
)
|
||||
|
||||
# blue depot
|
||||
Gosu.draw_rect(@field_size - 24, @field_size - 24, 24, 2, @blue)
|
||||
Gosu.draw_rect(@field_size - 24, @field_size - 24, 2, 24, @blue)
|
||||
Gosu.draw_rect(@field_size - 24, @field_size - 24, 24, 2, @blue, @z)
|
||||
Gosu.draw_rect(@field_size - 24, @field_size - 24, 2, 24, @blue, @z)
|
||||
|
||||
# red depot
|
||||
Gosu.draw_rect(-1, @field_size - 24, 24, 2, @red)
|
||||
Gosu.draw_rect(22, @field_size - 24, 2, 24, @red)
|
||||
Gosu.draw_rect(-1, @field_size - 24, 24, 2, @red, @z)
|
||||
Gosu.draw_rect(22, @field_size - 24, 2, 24, @red, @z)
|
||||
|
||||
# blue foundation
|
||||
Gosu.draw_rect(48, 4, 18.5, 34.5, @blue)
|
||||
Gosu.draw_rect(48, 4, 18.5, 34.5, @blue, @z)
|
||||
|
||||
# red foundation
|
||||
Gosu.draw_rect(@field_size - (48 + 18.5), 4, 18.5, 34.5, @red)
|
||||
Gosu.draw_rect(@field_size - (48 + 18.5), 4, 18.5, 34.5, @red, @z)
|
||||
|
||||
# stones
|
||||
6.times do |i|
|
||||
Gosu.draw_rect(48, @field_size - 8 * i - 8, 4, 8, Gosu::Color::YELLOW)
|
||||
Gosu.draw_rect(48, @field_size - 8 * i - 8, 4, 8, @soft_orange, @z)
|
||||
end
|
||||
6.times do |i|
|
||||
Gosu.draw_rect(@field_size - (48 + 4), @field_size - 8 * i - 8, 4, 8, Gosu::Color::YELLOW)
|
||||
Gosu.draw_rect(@field_size - (48 + 4), @field_size - 8 * i - 8, 4, 8, @soft_orange, @z)
|
||||
end
|
||||
end
|
||||
|
||||
def draw_field_ultimate_goal
|
||||
# middle line
|
||||
Gosu.draw_rect(0, @field_size / 2 - 13, @field_size, 2, Gosu::Color::WHITE)
|
||||
Gosu.draw_rect(0, @field_size / 2 - 13, @field_size, 2, Gosu::Color::WHITE, @z)
|
||||
|
||||
# phantom center line to indict half field for remote season field
|
||||
Gosu.draw_rect(@field_size / 2 - (0.5 + 24), 0, 1, @field_size, 0x88_448844)
|
||||
Gosu.draw_rect(@field_size / 2 - (0.5 + 24), 0, 1, @field_size, 0x88_448844, @z)
|
||||
|
||||
|
||||
# blue starting lines
|
||||
Gosu.draw_rect(24 - 1, @field_size - 24, 2, 24, @blue)
|
||||
Gosu.draw_rect(48 - 1, @field_size - 24, 2, 24, @blue)
|
||||
Gosu.draw_rect(24 - 1, @field_size - 24, 2, 24, @blue, @z)
|
||||
Gosu.draw_rect(48 - 1, @field_size - 24, 2, 24, @blue, @z)
|
||||
|
||||
# blue wobbly wobs
|
||||
Gosu.draw_circle(24, @field_size - 24, 4, 32, @blue)
|
||||
Gosu.draw_circle(48, @field_size - 24, 4, 32, @blue)
|
||||
Gosu.draw_circle(24, @field_size - 24, 4, 32, @blue, @z)
|
||||
Gosu.draw_circle(48, @field_size - 24, 4, 32, @blue, @z)
|
||||
|
||||
# blue starter stack
|
||||
Gosu.draw_rect(36 - 1, @field_size - 50, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 50, 2, 2, @blue, @z)
|
||||
|
||||
# blue target zones
|
||||
# A
|
||||
@@ -132,15 +134,15 @@ module TAC
|
||||
end
|
||||
|
||||
# red starting lines
|
||||
Gosu.draw_rect(@field_size - 24 - 1, @field_size - 24, 2, 24, @red)
|
||||
Gosu.draw_rect(@field_size - 48 - 1, @field_size - 24, 2, 24, @red)
|
||||
Gosu.draw_rect(@field_size - 24 - 1, @field_size - 24, 2, 24, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 48 - 1, @field_size - 24, 2, 24, @red, @z)
|
||||
|
||||
# red wobbly wobs
|
||||
Gosu.draw_circle(@field_size - 24, @field_size - 24, 4, 32, @red)
|
||||
Gosu.draw_circle(@field_size - 48, @field_size - 24, 4, 32, @red)
|
||||
Gosu.draw_circle(@field_size - 24, @field_size - 24, 4, 32, @red, @z)
|
||||
Gosu.draw_circle(@field_size - 48, @field_size - 24, 4, 32, @red, @z)
|
||||
|
||||
# red starter stack
|
||||
Gosu.draw_rect(@field_size - 37, @field_size - 50, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 37, @field_size - 50, 2, 2, @red, @z)
|
||||
|
||||
# red target zones
|
||||
# A
|
||||
@@ -161,91 +163,88 @@ module TAC
|
||||
|
||||
def draw_field_freight_frenzy
|
||||
# blue ZONE
|
||||
Gosu.draw_rect(24, @field_size - 24, 2, 24, @blue)
|
||||
Gosu.draw_rect(24, @field_size - 24, 24, 2, @blue)
|
||||
Gosu.draw_rect(48 - 2, @field_size - 24, 2, 24, @blue)
|
||||
Gosu.draw_rect(24, @field_size - 24, 2, 24, @blue, @z)
|
||||
Gosu.draw_rect(24, @field_size - 24, 24, 2, @blue, @z)
|
||||
Gosu.draw_rect(48 - 2, @field_size - 24, 2, 24, @blue, @z)
|
||||
|
||||
# blue barcode 1
|
||||
Gosu.draw_rect(36 - 1, @field_size - 24 - 4, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 36 - 1, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 48 + 2, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 24 - 4, 2, 2, @blue, @z)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 36 - 1, 2, 2, @blue, @z)
|
||||
Gosu.draw_rect(36 - 1, @field_size - 48 + 2, 2, 2, @blue, @z)
|
||||
|
||||
# blue barcode 2
|
||||
Gosu.draw_rect(36 - 1, 48 + 2, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, 60 - 1, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, 72 - 4, 2, 2, @blue)
|
||||
Gosu.draw_rect(36 - 1, 48 + 2, 2, 2, @blue, @z)
|
||||
Gosu.draw_rect(36 - 1, 60 - 1, 2, 2, @blue, @z)
|
||||
Gosu.draw_rect(36 - 1, 72 - 4, 2, 2, @blue, @z)
|
||||
|
||||
# blue wobble goal
|
||||
Gosu.draw_circle(48, 84, 9, 32, @blue)
|
||||
Gosu.draw_circle(48, 84, 9, 32, @blue, @z)
|
||||
|
||||
# blue shared wobble goal
|
||||
Gosu.draw_circle(@field_size / 2, 24, 9, 32, @blue)
|
||||
Gosu.draw_circle(@field_size / 2, 24, 9, 32, @blue, @z)
|
||||
|
||||
# red ZONE
|
||||
Gosu.draw_rect(@field_size - 24 - 2, @field_size - 24, 2, 24, @red)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size - 24, 24, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size - 24, 2, 24, @red)
|
||||
Gosu.draw_rect(@field_size - 24 - 2, @field_size - 24, 2, 24, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size - 24, 24, 2, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 48, @field_size - 24, 2, 24, @red, @z)
|
||||
|
||||
# red barcode 1
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 24 - 4, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 36 - 1, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 48 + 2, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 24 - 4, 2, 2, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 36 - 1, 2, 2, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, @field_size - 48 + 2, 2, 2, @red, @z)
|
||||
|
||||
# red barcode 2
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 48 + 2, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 60 - 1, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 72 - 4, 2, 2, @red)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 48 + 2, 2, 2, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 60 - 1, 2, 2, @red, @z)
|
||||
Gosu.draw_rect(@field_size - 36 - 1, 72 - 4, 2, 2, @red, @z)
|
||||
|
||||
# red wobble goal
|
||||
Gosu.draw_circle(@field_size - 48, 84, 9, 32, @red)
|
||||
Gosu.draw_circle(@field_size - 48, 84, 9, 32, @red, @z)
|
||||
|
||||
# red shared wobble goal
|
||||
Gosu.clip_to(@field_size / 2, 0, 10, 48) do
|
||||
Gosu.draw_circle(@field_size / 2, 24, 9, 32, @red)
|
||||
end
|
||||
# Gosu.clip_to(@field_size / 2, 0, 10, 48) do
|
||||
Gosu.draw_circle(@field_size / 2, 24, 9, 32, @red, @z)
|
||||
# end
|
||||
|
||||
# white corner left
|
||||
faint_white = Gosu::Color.rgb(240, 240, 240)
|
||||
|
||||
Gosu.draw_rect(0, 46 - 2, 46, 2, faint_white)
|
||||
Gosu.draw_rect(46 - 2, 0, 2, 46, faint_white)
|
||||
Gosu.draw_rect(0, 46 - 2, 46, 2, faint_white, @z)
|
||||
Gosu.draw_rect(46 - 2, 0, 2, 46, faint_white, @z)
|
||||
# white corner right
|
||||
Gosu.draw_rect(@field_size - 46, 46 - 2, 46, 2, faint_white)
|
||||
Gosu.draw_rect(@field_size - 46, 0, 2, 46, faint_white)
|
||||
Gosu.draw_rect(@field_size - 46, 46 - 2, 46, 2, faint_white, @z)
|
||||
Gosu.draw_rect(@field_size - 46, 0, 2, 46, faint_white, @z)
|
||||
|
||||
# cross bars
|
||||
bar_gray = Gosu::Color.rgb(50, 50, 50)
|
||||
# MAIN
|
||||
Gosu.draw_rect(13.75, 48 - 2, @field_size - 13.75 * 2, 1, bar_gray)
|
||||
Gosu.draw_rect(13.75, 48 + 1, @field_size - 13.75 * 2, 1, bar_gray)
|
||||
Gosu.draw_rect(13.75, 48 - 2, 1, 4, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(@field_size - 13.75 - 1, 48 - 2, 1, 4, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(13.75, 48 - 2, @field_size - 13.75 * 2, 1, bar_gray, @z)
|
||||
Gosu.draw_rect(13.75, 48 + 1, @field_size - 13.75 * 2, 1, bar_gray, @z)
|
||||
Gosu.draw_rect(13.75, 48 - 2, 1, 4, Gosu::Color::BLACK, @z)
|
||||
Gosu.draw_rect(@field_size - 13.75 - 1, 48 - 2, 1, 4, Gosu::Color::BLACK, @z)
|
||||
|
||||
# BLUE
|
||||
Gosu.draw_rect(48 - 2, 13.75, 1, 48 - 13.75 - 2, bar_gray)
|
||||
Gosu.draw_rect(48 + 1, 13.75, 1, 48 - 13.75 - 2, bar_gray)
|
||||
Gosu.draw_rect(48 - 2, 13.75, 4, 1, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(48 - 2, 48 - 3, 4, 1, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(48 - 2, 13.75, 1, 48 - 13.75 - 2, bar_gray, @z)
|
||||
Gosu.draw_rect(48 + 1, 13.75, 1, 48 - 13.75 - 2, bar_gray, @z)
|
||||
Gosu.draw_rect(48 - 2, 13.75, 4, 1, Gosu::Color::BLACK, @z)
|
||||
Gosu.draw_rect(48 - 2, 48 - 3, 4, 1, Gosu::Color::BLACK, @z)
|
||||
|
||||
# RED
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 13.75, 1, 48 - 13.75 - 2, bar_gray)
|
||||
Gosu.draw_rect(@field_size - 48 + 1, 13.75, 1, 48 - 13.75 - 2, bar_gray)
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 13.75, 4, 1, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 48 - 3, 4, 1, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 13.75, 1, 48 - 13.75 - 2, bar_gray, @z)
|
||||
Gosu.draw_rect(@field_size - 48 + 1, 13.75, 1, 48 - 13.75 - 2, bar_gray, @z)
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 13.75, 4, 1, Gosu::Color::BLACK, @z)
|
||||
Gosu.draw_rect(@field_size - 48 - 2, 48 - 3, 4, 1, Gosu::Color::BLACK, @z)
|
||||
|
||||
# Duck Delivery
|
||||
Gosu.draw_circle(2, @field_size - 2, 9, 16, Gosu::Color.rgb(75, 75, 75))
|
||||
Gosu.draw_circle(@field_size - 2, @field_size - 2, 9, 16, Gosu::Color.rgb(75, 75, 75))
|
||||
|
||||
# packages
|
||||
soft_orange = Gosu::Color.rgb(255, 175, 0)
|
||||
|
||||
7.times do |y|
|
||||
7.times do |x|
|
||||
if x.even?
|
||||
Gosu.draw_rect(x * 3 + 1, y * 3 + 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect(x * 3 + 1, y * 3 + 1, 2, 2, @soft_orange, @z)
|
||||
else
|
||||
Gosu.draw_circle(x * 3 + 2, y * 3 + 2, 1, 16, faint_white)
|
||||
Gosu.draw_circle(x * 3 + 2, y * 3 + 2, 1, 16, faint_white, @z)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -253,24 +252,95 @@ module TAC
|
||||
7.times do |y|
|
||||
7.times do |x|
|
||||
if x.even?
|
||||
Gosu.draw_rect((@field_size - 4) - x * 3 + 1, y * 3 + 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect((@field_size - 4) - x * 3 + 1, y * 3 + 1, 2, 2, @soft_orange, @z)
|
||||
else
|
||||
Gosu.draw_circle((@field_size - 4) - x * 3 + 2, y * 3 + 2, 1, 16, faint_white)
|
||||
Gosu.draw_circle((@field_size - 4) - x * 3 + 2, y * 3 + 2, 1, 16, faint_white, @z)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Gosu.draw_rect(0, 60 - 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect(0, 108 - 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect(@field_size - 2, 60 - 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect(@field_size - 2, 108 - 1, 2, 2, soft_orange)
|
||||
Gosu.draw_rect(0, 60 - 1, 2, 2, @soft_orange, @z)
|
||||
Gosu.draw_rect(0, 108 - 1, 2, 2, @soft_orange, @z)
|
||||
Gosu.draw_rect(@field_size - 2, 60 - 1, 2, 2, @soft_orange, @z)
|
||||
Gosu.draw_rect(@field_size - 2, 108 - 1, 2, 2, @soft_orange, @z)
|
||||
end
|
||||
|
||||
def draw_field_power_play
|
||||
# pole junctions (Drawn before ground junctions to be lazy- ground junctions will cover non-existant poles)
|
||||
5.times do |y|
|
||||
5.times do |x|
|
||||
Gosu.draw_circle(24 + (x * 24), 24 + (y * 24), 0.5, 16, @soft_orange, @z)
|
||||
end
|
||||
end
|
||||
|
||||
# ground junction
|
||||
3.times do |y|
|
||||
3.times do |x|
|
||||
Gosu.draw_circle(24 + (x * 48), 24 + (y * 48), 3, 16, Gosu::Color::BLACK, @z)
|
||||
end
|
||||
end
|
||||
|
||||
# Field cones
|
||||
2.times do |y|
|
||||
2.times do |x|
|
||||
Gosu.draw_circle(36 + (x * 72), 36 + (y * 72), 2, 16, x.zero? ? @blue : @red, @z)
|
||||
end
|
||||
end
|
||||
|
||||
# alliance LINEs
|
||||
2.times do |y|
|
||||
2.times do |x|
|
||||
Gosu.draw_rect(59 + (x * 24), y * (144 - 23.5), 2, 23.5, x.zero? ? @blue : @red, @z)
|
||||
end
|
||||
end
|
||||
|
||||
# alliance LINE cones
|
||||
2.times do |y|
|
||||
2.times do |x|
|
||||
Gosu.draw_circle(60 + (x * 24), y * (144 - 4) + 2, 2, 16, x.zero? ? @blue : @red, @z)
|
||||
end
|
||||
end
|
||||
|
||||
# Corner TAPE
|
||||
4.times do |i|
|
||||
Gosu.rotate(i * 90.0, 72, 72) do
|
||||
Gosu.draw_quad(
|
||||
24 - 2, 0, i.even? ? @red : @blue,
|
||||
24, 0, i.even? ? @red : @blue,
|
||||
0, 24 - 2, i.even? ? @red : @blue,
|
||||
0, 24, i.even? ? @red : @blue,
|
||||
@z
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# Triangle TAPE
|
||||
2.times do |i|
|
||||
Gosu.rotate(i * 180.0, 72, 72) do
|
||||
Gosu.draw_quad(
|
||||
0, 72 - 10.5, i.odd? ? @red : @blue,
|
||||
10.5, 72, i.odd? ? @red : @blue,
|
||||
8.5, 72, i.odd? ? @red : @blue,
|
||||
0, 72 - 8.5, i.odd? ? @red : @blue,
|
||||
@z
|
||||
)
|
||||
|
||||
Gosu.draw_quad(
|
||||
0, 72 + 10.5, i.odd? ? @red : @blue,
|
||||
10.5, 72, i.odd? ? @red : @blue,
|
||||
8.5, 72, i.odd? ? @red : @blue,
|
||||
0, 72 + 8.5, i.odd? ? @red : @blue,
|
||||
@z
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def draw_tile_box(color)
|
||||
Gosu.draw_rect(0, 0, 24, 2, color)
|
||||
Gosu.draw_rect(22, 2, 2, 22, color)
|
||||
Gosu.draw_rect(0, 22, 22, 2, color)
|
||||
Gosu.draw_rect(0, 2, 2, 22, color)
|
||||
Gosu.draw_rect(0, 0, 24, 2, color, @z)
|
||||
Gosu.draw_rect(22, 2, 2, 22, color, @z)
|
||||
Gosu.draw_rect(0, 22, 22, 2, color, @z)
|
||||
Gosu.draw_rect(0, 2, 2, 22, color, @z)
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -4,13 +4,16 @@ module TAC
|
||||
FONT = Gosu::Font.new(11)
|
||||
|
||||
attr_accessor :position, :angle, :comment
|
||||
attr_reader :alliance, :width, :depth
|
||||
def initialize(alliance:, width:, depth:)
|
||||
attr_reader :alliance, :width, :depth, :z
|
||||
def initialize(alliance:, width:, depth:, container:)
|
||||
@alliance = alliance
|
||||
@width, @depth = width, depth
|
||||
@width = width
|
||||
@depth = depth
|
||||
@container = container
|
||||
|
||||
@position = CyberarmEngine::Vector.new
|
||||
@angle = 0
|
||||
@z = @container.z + 1
|
||||
|
||||
@queue = []
|
||||
|
||||
@@ -24,28 +27,28 @@ module TAC
|
||||
def draw
|
||||
Gosu.translate(@width / 2, @depth / 2) do
|
||||
Gosu.rotate(@angle, @position.x, @position.y) do
|
||||
Gosu.draw_rect(@position.x - @width / 2, @position.y - @depth / 2, @width, @depth, Gosu::Color::BLACK)
|
||||
Gosu.draw_rect(@position.x - @width / 2 + 1, @position.y - @depth / 2 + 1, @width - 2, @depth - 2, Gosu::Color.new(0xff_808022))
|
||||
Gosu.draw_rect(@position.x - @width / 2, @position.y - @depth / 2, @width, @depth, Gosu::Color::BLACK, @z)
|
||||
Gosu.draw_rect(@position.x - @width / 2 + 1, @position.y - @depth / 2 + 1, @width - 2, @depth - 2, Gosu::Color.new(0xff_808022), @z)
|
||||
|
||||
if @alliance == :blue
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, TAC::Palette::BLUE_ALLIANCE)
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, TAC::Palette::BLUE_ALLIANCE, @z)
|
||||
elsif @alliance == :red
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, TAC::Palette::RED_ALLIANCE)
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, TAC::Palette::RED_ALLIANCE, @z)
|
||||
else
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, @alliance)
|
||||
Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, @alliance, @z)
|
||||
end
|
||||
Gosu.draw_circle(@position.x, @position.y - @depth * 0.25, 2, 3, TAC::Palette::TIMECRAFTERS_TERTIARY)
|
||||
Gosu.draw_circle(@position.x, @position.y - @depth * 0.25, 2, 3, TAC::Palette::TIMECRAFTERS_TERTIARY, @z)
|
||||
end
|
||||
|
||||
FONT.draw_text(@comment, 2.2, 2.2, 0, 1, 1, Gosu::Color::BLACK)
|
||||
FONT.draw_text(@comment, 2, 2, 0)
|
||||
FONT.draw_text(@comment, 2.2, 2.2, @z, 1, 1, Gosu::Color::BLACK)
|
||||
FONT.draw_text(@comment, 2, 2, @z)
|
||||
end
|
||||
end
|
||||
|
||||
def update(dt)
|
||||
@angle %= 360.0
|
||||
|
||||
if state = @queue.first
|
||||
if (state = @queue.first)
|
||||
state.update(dt)
|
||||
|
||||
if state.complete?
|
||||
@@ -145,9 +148,10 @@ module TAC
|
||||
def draw
|
||||
Gosu.draw_line(
|
||||
@robot.position.x + @robot.width / 2, @robot.position.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@goal.x + @robot.width / 2, @goal.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY
|
||||
@goal.x + @robot.width / 2, @goal.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@robot.z
|
||||
)
|
||||
Gosu.draw_rect(@goal.x + (@robot.width / 2 - 1), @goal.y + (@robot.depth / 2 - 1), 2, 2, Gosu::Color::RED)
|
||||
Gosu.draw_rect(@goal.x + (@robot.width / 2 - 1), @goal.y + (@robot.depth / 2 - 1), 2, 2, Gosu::Color::RED, @robot.z)
|
||||
end
|
||||
|
||||
def update(dt)
|
||||
@@ -191,9 +195,10 @@ module TAC
|
||||
def draw
|
||||
Gosu.draw_line(
|
||||
@robot.position.x + @robot.width / 2, @robot.position.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@goal.x + @robot.width / 2, @goal.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY
|
||||
@goal.x + @robot.width / 2, @goal.y + @robot.depth / 2, TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@robot.z
|
||||
)
|
||||
Gosu.draw_rect(@goal.x + (@robot.width / 2 - 1), @goal.y + (@robot.depth / 2 - 1), 2, 2, Gosu::Color::RED)
|
||||
Gosu.draw_rect(@goal.x + (@robot.width / 2 - 1), @goal.y + (@robot.depth / 2 - 1), 2, 2, Gosu::Color::RED, @robot.z)
|
||||
end
|
||||
|
||||
def update(dt)
|
||||
@@ -245,7 +250,8 @@ module TAC
|
||||
fraction,
|
||||
360,
|
||||
1,
|
||||
TAC::Palette::TIMECRAFTERS_TERTIARY
|
||||
TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@robot.z
|
||||
)
|
||||
end
|
||||
|
||||
@@ -254,7 +260,8 @@ module TAC
|
||||
@robot.position.y + @robot.depth / 2 + Gosu.offset_y(@target_angle, @robot.width > @robot.depth ? @robot.width : @robot.depth),
|
||||
1,
|
||||
9,
|
||||
Gosu::Color::RED
|
||||
Gosu::Color::RED,
|
||||
@robot.z
|
||||
)
|
||||
# Gosu.draw_arc(@position.x, @position.y, 6, 1.0, 32, 2, @alliance)
|
||||
end
|
||||
@@ -297,7 +304,8 @@ module TAC
|
||||
1 - fraction,
|
||||
360,
|
||||
1,
|
||||
TAC::Palette::TIMECRAFTERS_TERTIARY
|
||||
TAC::Palette::TIMECRAFTERS_TERTIARY,
|
||||
@robot.z
|
||||
)
|
||||
|
||||
@complete = fraction >= 1
|
||||
|
||||
@@ -8,7 +8,7 @@ module TAC
|
||||
@field_container = field_container
|
||||
|
||||
@robots = []
|
||||
@field = Field.new(simulation: self, season: :freight_frenzy, container: @field_container)
|
||||
@field = Field.new(simulation: self, season: :power_play, container: @field_container)
|
||||
@show_paths = false
|
||||
|
||||
@last_milliseconds = Gosu.milliseconds
|
||||
@@ -29,7 +29,7 @@ module TAC
|
||||
def update
|
||||
@accumulator += (Gosu.milliseconds - @last_milliseconds) / 1000.0
|
||||
|
||||
while(@accumulator > @simulation_step)
|
||||
while @accumulator > @simulation_step
|
||||
@field.update
|
||||
@robots.each { |robot| robot.update(@simulation_step) }
|
||||
|
||||
@@ -41,7 +41,7 @@ module TAC
|
||||
end
|
||||
|
||||
def create_robot(alliance:, width:, depth:)
|
||||
robot = Simulator::Robot.new(alliance: alliance, width: width, depth: depth)
|
||||
robot = Simulator::Robot.new(alliance: alliance, width: width, depth: depth, container: @field_container)
|
||||
@robots << robot
|
||||
|
||||
return robot
|
||||
|
||||
Reference in New Issue
Block a user