fixing invisible bikes and broken warping

This commit is contained in:
Dustin Carlino 2019-03-14 16:27:53 -07:00
parent 78fe1fcc82
commit e6d51cf421
3 changed files with 30 additions and 13 deletions

View File

@ -57,6 +57,11 @@ impl BlockingPlugin for WarpState {
InputResult::StillActive => {} InputResult::StillActive => {}
}, },
WarpState::Warping(started, line, id) => { WarpState::Warping(started, line, id) => {
// Weird to do stuff for any event?
if ctx.input.nonblocking_is_update_event() {
ctx.input.use_update_event();
}
ctx.hints.mode = EventLoopMode::Animation; ctx.hints.mode = EventLoopMode::Animation;
let percent = elapsed_seconds(*started) / ANIMATION_TIME_S; let percent = elapsed_seconds(*started) / ANIMATION_TIME_S;
if percent >= 1.0 { if percent >= 1.0 {

View File

@ -14,23 +14,28 @@ pub struct DrawBike {
// TODO the turn arrows for bikes look way wrong // TODO the turn arrows for bikes look way wrong
// TODO maybe also draw lookahead buffer to know what the car is considering // TODO maybe also draw lookahead buffer to know what the car is considering
stopping_buffer: Option<Polygon>, stopping_buffer: Option<Polygon>,
zorder: isize,
draw_default: Drawable, draw_default: Drawable,
} }
impl DrawBike { impl DrawBike {
pub fn new(input: DrawCarInput, prerender: &Prerender, cs: &ColorScheme) -> DrawBike { pub fn new(
input: DrawCarInput,
map: &Map,
prerender: &Prerender,
cs: &ColorScheme,
) -> DrawBike {
let stopping_buffer = input.stopping_trace.map(|t| t.make_polygons(BIKE_WIDTH)); let stopping_buffer = input.stopping_trace.map(|t| t.make_polygons(BIKE_WIDTH));
let polygon = input.body.make_polygons(BIKE_WIDTH); let polygon = input.body.make_polygons(BIKE_WIDTH);
let draw_default = prerender.upload_borrowed(vec![( let draw_default = prerender.upload_borrowed(vec![(
match input.status { match input.status {
CarStatus::Debug => cs // TODO color.shift(input.id.0) actually looks pretty bad still
.get_def("debug bike", Color::BLUE.alpha(0.8)) CarStatus::Debug => cs.get_def("debug bike", Color::BLUE.alpha(0.8)),
.shift(input.id.0),
// TODO Hard to see on the greenish bike lanes? :P // TODO Hard to see on the greenish bike lanes? :P
CarStatus::Moving => cs.get_def("moving bike", Color::GREEN).shift(input.id.0), CarStatus::Moving => cs.get_def("moving bike", Color::GREEN),
CarStatus::Stuck => cs.get_def("stuck bike", Color::RED).shift(input.id.0), CarStatus::Stuck => cs.get_def("stuck bike", Color::RED),
CarStatus::Parked => panic!("Can't have a parked bike"), CarStatus::Parked => panic!("Can't have a parked bike"),
}, },
&polygon, &polygon,
@ -40,6 +45,7 @@ impl DrawBike {
id: input.id, id: input.id,
polygon, polygon,
stopping_buffer, stopping_buffer,
zorder: input.on.get_zorder(map),
draw_default, draw_default,
} }
} }
@ -57,12 +63,14 @@ impl Renderable for DrawBike {
g.redraw(&self.draw_default); g.redraw(&self.draw_default);
} }
if let Some(ref t) = self.stopping_buffer { if opts.debug_mode {
g.draw_polygon( if let Some(ref t) = self.stopping_buffer {
ctx.cs g.draw_polygon(
.get_def("bike stopping buffer", Color::RED.alpha(0.7)), ctx.cs
t, .get_def("bike stopping buffer", Color::RED.alpha(0.7)),
); t,
);
}
} }
} }
@ -73,4 +81,8 @@ impl Renderable for DrawBike {
fn contains_pt(&self, pt: Pt2D, _: &Map) -> bool { fn contains_pt(&self, pt: Pt2D, _: &Map) -> bool {
self.polygon.contains_pt(pt) self.polygon.contains_pt(pt)
} }
fn get_zorder(&self) -> isize {
self.zorder
}
} }

View File

@ -69,7 +69,7 @@ pub fn draw_vehicle(
cs: &ColorScheme, cs: &ColorScheme,
) -> Box<Renderable> { ) -> Box<Renderable> {
if input.vehicle_type == VehicleType::Bike { if input.vehicle_type == VehicleType::Bike {
Box::new(DrawBike::new(input, prerender, cs)) Box::new(DrawBike::new(input, map, prerender, cs))
} else { } else {
Box::new(DrawCar::new(input, map, prerender, cs)) Box::new(DrawCar::new(input, map, prerender, cs))
} }