why is my slider rendering wrong
This commit is contained in:
parent
74d63a216e
commit
b1b5050105
4 changed files with 23 additions and 14 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1132,7 +1132,7 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
|||
[[package]]
|
||||
name = "libosu"
|
||||
version = "0.0.12"
|
||||
source = "git+https://github.com/iptq/libosu?rev=7acc09af59b789f78c21c259d4e1e246e9cf0b08#7acc09af59b789f78c21c259d4e1e246e9cf0b08"
|
||||
source = "git+https://github.com/iptq/libosu?rev=5a8501aec0f4f2232507f80a65b8b31be8756414#5a8501aec0f4f2232507f80a65b8b31be8756414"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags",
|
||||
|
|
|
@ -19,4 +19,4 @@ num = "0.3.1"
|
|||
|
||||
[dependencies.libosu]
|
||||
git = "https://github.com/iptq/libosu"
|
||||
rev = "7acc09af59b789f78c21c259d4e1e246e9cf0b08"
|
||||
rev = "5a8501aec0f4f2232507f80a65b8b31be8756414"
|
||||
|
|
13
src/game.rs
13
src/game.rs
|
@ -6,7 +6,8 @@ use anyhow::Result;
|
|||
use ggez::{
|
||||
event::{EventHandler, KeyCode, KeyMods},
|
||||
graphics::{
|
||||
self, DrawMode, DrawParam, FillOptions, FilterMode, Mesh, Rect, StrokeOptions, Text, WHITE,
|
||||
self, Color, DrawMode, DrawParam, FillOptions, FilterMode, Mesh, Rect, StrokeOptions, Text,
|
||||
WHITE,
|
||||
},
|
||||
Context, GameError, GameResult,
|
||||
};
|
||||
|
@ -68,6 +69,14 @@ impl Game {
|
|||
|
||||
graphics::clear(ctx, [0.0, 0.0, 0.0, 1.0].into());
|
||||
|
||||
let playfield = Mesh::new_rectangle(
|
||||
ctx,
|
||||
DrawMode::Stroke(StrokeOptions::default()),
|
||||
EDITOR_SCREEN,
|
||||
Color::new(1.0, 1.0, 1.0, 0.5),
|
||||
)?;
|
||||
graphics::draw(ctx, &playfield, DrawParam::default())?;
|
||||
|
||||
let time = self.song.as_ref().unwrap().position()?;
|
||||
let text = Text::new(format!("time: {}", time).as_ref());
|
||||
graphics::queue_text(ctx, &text, [0.0, 0.0], Some(WHITE));
|
||||
|
@ -84,7 +93,7 @@ impl Game {
|
|||
|
||||
let osupx_scale_x = EDITOR_SCREEN.w / 512.0;
|
||||
let osupx_scale_y = EDITOR_SCREEN.h / 384.0;
|
||||
let cs_osupx = 54.4 - 4.48 * self.beatmap.difficulty.circle_size;
|
||||
let cs_osupx = self.beatmap.difficulty.circle_size_osupx();
|
||||
let cs_real = cs_osupx * osupx_scale_x;
|
||||
|
||||
for ho in visible_hitobjects.iter() {
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
use std::collections::{HashMap, VecDeque};
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use std::collections::VecDeque;
|
||||
|
||||
use anyhow::Result;
|
||||
use ggez::{
|
||||
conf::NumSamples,
|
||||
graphics::{
|
||||
self, Canvas, Color, DrawMode, DrawParam, LineCap, LineJoin, Mesh, Rect, StrokeOptions,
|
||||
},
|
||||
graphics::{self, DrawMode, DrawParam, LineCap, LineJoin, Mesh, Rect, StrokeOptions},
|
||||
nalgebra::Point2,
|
||||
Context,
|
||||
};
|
||||
|
@ -32,7 +27,7 @@ pub fn render_slider(
|
|||
|
||||
let osupx_scale_x = rect.w as f64 / 512.0;
|
||||
let osupx_scale_y = rect.h as f64 / 384.0;
|
||||
let cs_osupx = 54.4 - 4.48 * beatmap.difficulty.circle_size as f64;
|
||||
let cs_osupx = beatmap.difficulty.circle_size_osupx() as f64;
|
||||
let cs_real = cs_osupx * osupx_scale_x;
|
||||
|
||||
let (mut boundx, mut boundy, mut boundw, mut boundh) = (0.0f64, 0.0f64, 0.0f64, 0.0f64);
|
||||
|
@ -75,9 +70,14 @@ fn get_spline(
|
|||
let points = control_points
|
||||
.iter()
|
||||
.map(|p| Point(p.0 as f64, p.1 as f64))
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
match kind {
|
||||
SliderSplineKind::Linear => points,
|
||||
SliderSplineKind::Linear => {
|
||||
let start = points[0];
|
||||
let unit = (points[1] - points[0]).norm();
|
||||
let end = points[0] + unit * pixel_length;
|
||||
vec![start, end]
|
||||
}
|
||||
SliderSplineKind::Perfect => {
|
||||
let (p1, p2, p3) = (points[0], points[1], points[2]);
|
||||
let (center, radius) = Math::circumcircle(p1, p2, p3);
|
||||
|
|
Loading…
Reference in a new issue