mirror of
https://github.com/TimeCrafters/timecrafters_configuration_tool_desktop.git
synced 2025-12-16 05:42:35 +00:00
Added delay state to simulator
This commit is contained in:
@@ -87,6 +87,10 @@ module TAC
|
|||||||
@queue << Turn.new(robot: self, relative_angle: relative_angle, power: power)
|
@queue << Turn.new(robot: self, relative_angle: relative_angle, power: power)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delay(time_in_seconds)
|
||||||
|
@queue << Delay.new(robot: self, time_in_seconds: time_in_seconds)
|
||||||
|
end
|
||||||
|
|
||||||
def speed
|
def speed
|
||||||
@ticks_per_revolution / @gear_ratio
|
@ticks_per_revolution / @gear_ratio
|
||||||
end
|
end
|
||||||
@@ -95,7 +99,7 @@ module TAC
|
|||||||
@queue
|
@queue
|
||||||
end
|
end
|
||||||
|
|
||||||
class State
|
class State
|
||||||
def start
|
def start
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -259,6 +263,39 @@ class State
|
|||||||
@last_angle = @robot.angle
|
@last_angle = @robot.angle
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Delay < State
|
||||||
|
def initialize(robot:, time_in_seconds:)
|
||||||
|
@robot = robot
|
||||||
|
@time_in_seconds = time_in_seconds
|
||||||
|
|
||||||
|
@accumulator = 0.0
|
||||||
|
end
|
||||||
|
|
||||||
|
def start
|
||||||
|
@complete = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def draw
|
||||||
|
fraction = @accumulator / @time_in_seconds.to_f
|
||||||
|
|
||||||
|
Gosu.draw_arc(
|
||||||
|
@robot.position.x + @robot.width / 2,
|
||||||
|
@robot.position.y + @robot.depth / 2,
|
||||||
|
@robot.width > @robot.depth ? @robot.width : @robot.depth,
|
||||||
|
1 - fraction,
|
||||||
|
360,
|
||||||
|
1,
|
||||||
|
TAC::Palette::TIMECRAFTERS_TERTIARY
|
||||||
|
)
|
||||||
|
|
||||||
|
@complete = fraction >= 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def update(dt)
|
||||||
|
@accumulator += dt
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user