Added comment 'state' for show a comment above the robot (TODO: make it non-scaled and actually hover above robot)

This commit is contained in:
2021-10-23 12:40:13 -05:00
parent 15d8e2ff62
commit 0d6fb8a657

View File

@@ -1,7 +1,9 @@
module TAC module TAC
class Simulator class Simulator
class Robot class Robot
attr_accessor :position, :angle FONT = Gosu::Font.new(11)
attr_accessor :position, :angle, :comment
attr_reader :alliance, :width, :depth attr_reader :alliance, :width, :depth
def initialize(alliance:, width:, depth:) def initialize(alliance:, width:, depth:)
@alliance = alliance @alliance = alliance
@@ -15,6 +17,8 @@ module TAC
@unit = :ticks @unit = :ticks
@ticks_per_revolution = 240 @ticks_per_revolution = 240
@gear_ratio = 1 @gear_ratio = 1
@comment = ""
end end
def draw def draw
@@ -32,6 +36,9 @@ module TAC
end 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)
end end
FONT.draw_text(@comment, 2.2, 2.2, 0, 1, 1, Gosu::Color::BLACK)
FONT.draw_text(@comment, 2, 2, 0)
end end
end end
@@ -91,6 +98,10 @@ module TAC
@queue << Delay.new(robot: self, time_in_seconds: time_in_seconds) @queue << Delay.new(robot: self, time_in_seconds: time_in_seconds)
end end
def comment(comment)
@queue << Comment.new(robot: self, comment: comment)
end
def speed def speed
@ticks_per_revolution / @gear_ratio @ticks_per_revolution / @gear_ratio
end end
@@ -296,6 +307,24 @@ module TAC
@accumulator += dt @accumulator += dt
end end
end end
class Comment < State
def initialize(robot:, comment:)
@robot = robot
@comment = comment
end
def start
@robot.comment = @comment
@complete = true
end
def draw
end
def update(dt)
end
end
end end
end end
end end