From d372c50ecfd79ac7ad9d1a2db706c31533ef71d3 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Sat, 9 Jan 2021 15:59:39 -0600 Subject: [PATCH] stack before translating --- README.md | 2 -- src/game/mod.rs | 4 ++-- src/game/sliders.rs | 22 +++++++++++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 642fd77..8352b5f 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,6 @@ wrapper script isn't written yet, in this case i just copied bass.dll to the pro roadmap ------- -- [ ] stacking -- [ ] fix slider overlap problem - [ ] long term: - [ ] new framework diff --git a/src/game/mod.rs b/src/game/mod.rs index 8bc61c0..42af5d4 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -172,8 +172,8 @@ impl Game { let ho_time = (ho.inner.start_time.0 as f64) / 1000.0; let stacking = ho.stacking as f32 * STACK_DISTANCE as f32; let pos = [ - PLAYFIELD_BOUNDS.x + osupx_scale_x * ho.inner.pos.0 as f32 - stacking, - PLAYFIELD_BOUNDS.y + osupx_scale_y * ho.inner.pos.1 as f32 - stacking, + PLAYFIELD_BOUNDS.x + osupx_scale_x * (ho.inner.pos.0 as f32 - stacking), + PLAYFIELD_BOUNDS.y + osupx_scale_y * (ho.inner.pos.1 as f32 - stacking), ]; let color = draw_info.color; diff --git a/src/game/sliders.rs b/src/game/sliders.rs index 90933b7..d03ec0a 100644 --- a/src/game/sliders.rs +++ b/src/game/sliders.rs @@ -72,7 +72,7 @@ pub fn render_slider<'a>( }) .collect::>>(); - // draw slider body + // draw slider border let canvas = Canvas::with_window_size(ctx)?; let opts = StrokeOptions::default() .with_line_cap(LineCap::Round) @@ -88,6 +88,26 @@ pub fn render_slider<'a>( graphics::clear(ctx, Color::new(0.0, 0.0, 0.0, 0.0)); graphics::draw(ctx, &body, DrawParam::default())?; graphics::set_canvas(ctx, None); + let mut border_color = graphics::WHITE; + border_color.a = color.a; + graphics::draw(ctx, &canvas, DrawParam::default().color(border_color))?; + + // draw slider body + let canvas = Canvas::with_window_size(ctx)?; + let opts = StrokeOptions::default() + .with_line_cap(LineCap::Round) + .with_line_join(LineJoin::Round) + .with_line_width(cs_real as f32 * 1.8); + let body = Mesh::new_polyline( + ctx, + DrawMode::Stroke(opts), + spline_mapped.as_ref(), + graphics::WHITE, + )?; + graphics::set_canvas(ctx, Some(&canvas)); + graphics::clear(ctx, Color::new(0.0, 0.0, 0.0, 0.0)); + graphics::draw(ctx, &body, DrawParam::default())?; + graphics::set_canvas(ctx, None); graphics::draw(ctx, &canvas, DrawParam::default().color(color))?; // draw control points wireframe