switch to dev branch of ggez

This commit is contained in:
Michael Zhang 2021-01-13 06:20:02 -06:00
parent 904f9e91f6
commit 09d26a9022
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
12 changed files with 1316 additions and 662 deletions

1918
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -16,7 +16,7 @@ members = [
[dependencies]
anyhow = "1.0.38"
bass-sys = { path = "bass-sys" }
ggez = "0.5.1"
ggez = { git = "https://github.com/ggez/ggez", branch = "devel" }
log = "0.4.13"
stderrlog = "0.5.1"
num = "0.3.1"

View file

@ -5,3 +5,4 @@ authors = ["Michael Zhang <mail@mzhang.io>"]
edition = "2018"
[dependencies]
winit = "0.24.0"

2
framework/src/game.rs Normal file
View file

@ -0,0 +1,2 @@
pub struct Game {
}

10
src/game/background.rs Normal file
View file

@ -0,0 +1,10 @@
use anyhow::Result;
use ggez::Context;
use super::Game;
impl Game {
pub(super) fn draw_background(&self, ctx: &mut Context) -> Result<()> {
Ok(())
}
}

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use ggez::{
graphics::{self, Color, DrawMode, DrawParam, Mesh, StrokeOptions},
nalgebra::Point2,
mint::Point2,
Context,
};
@ -35,7 +35,7 @@ impl Game {
let x = BOUNDS.x + x as f32 * BOUNDS.w / 512.0;
let line = Mesh::new_line(
ctx,
&[Point2::new(x, min_y), Point2::new(x, max_y)],
&[Point2::from([x, min_y]), Point2::from([x, max_y])],
weight,
color,
)?;
@ -50,7 +50,7 @@ impl Game {
let y = BOUNDS.y + y as f32 * BOUNDS.h / 384.0;
let line = Mesh::new_line(
ctx,
&[Point2::new(min_x, y), Point2::new(max_x, y)],
&[Point2::from([min_x, y]), Point2::from([max_x, y])],
weight,
color,
)?;

View file

@ -1,3 +1,4 @@
mod background;
mod grid;
mod seeker;
mod sliders;
@ -146,6 +147,7 @@ impl Game {
graphics::clear(ctx, [0.0, 0.0, 0.0, 1.0].into());
self.draw_background(ctx)?;
self.draw_grid(ctx)?;
let time = self.song.as_ref().unwrap().position()?;

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use ggez::{
graphics::{self, Color, DrawParam, Mesh, Rect},
nalgebra::Point2,
mint::Point2,
Context,
};
use libosu::timing::TimingPointKind;
@ -16,8 +16,8 @@ impl Game {
let line = Mesh::new_line(
ctx,
&[
Point2::new(BOUNDS.x, line_y),
Point2::new(BOUNDS.x + BOUNDS.w, line_y),
Point2::from([BOUNDS.x, line_y]),
Point2::from([BOUNDS.x + BOUNDS.w, line_y]),
],
1.0,
graphics::WHITE,
@ -39,8 +39,8 @@ impl Game {
let line = Mesh::new_line(
ctx,
&[
Point2::new(x, BOUNDS.y),
Point2::new(x, BOUNDS.y + BOUNDS.h),
Point2::from([x, BOUNDS.y]),
Point2::from([x, BOUNDS.y + BOUNDS.h]),
],
1.0,
color,
@ -53,8 +53,8 @@ impl Game {
let line = Mesh::new_line(
ctx,
&[
Point2::new(x, BOUNDS.y + 0.2 * BOUNDS.h),
Point2::new(x, BOUNDS.y + 0.8 * BOUNDS.h),
Point2::from([x, BOUNDS.y + 0.2 * BOUNDS.h]),
Point2::from([x, BOUNDS.y + 0.8 * BOUNDS.h]),
],
4.0,
graphics::WHITE,

View file

@ -4,7 +4,7 @@ use ggez::{
self, Canvas, Color, DrawMode, DrawParam, FillOptions, LineCap, LineJoin, Mesh, Rect,
StrokeOptions,
},
nalgebra::Point2,
mint::Point2,
Context,
};
use libosu::{

View file

@ -1,7 +1,7 @@
use anyhow::Result;
use ggez::{
graphics::{self, Color, DrawMode, DrawParam, LineCap, Mesh, Rect, StrokeOptions, WHITE},
nalgebra::Point2,
mint::Point2,
Context,
};
use libosu::{
@ -36,8 +36,8 @@ impl Game {
let current_line = Mesh::new_line(
ctx,
&[
Point2::new(timeline_current_line_x, BOUNDS.y),
Point2::new(timeline_current_line_x, BOUNDS.y + BOUNDS.h),
Point2::from([timeline_current_line_x, BOUNDS.y]),
Point2::from([timeline_current_line_x, BOUNDS.y + BOUNDS.h]),
],
2.0,
graphics::WHITE,
@ -115,7 +115,7 @@ impl Game {
let y1 = y2 - BOUNDS.h * 0.3 * height;
let tick = Mesh::new_line(
ctx,
&[Point2::new(x, y1), Point2::new(x, y2)],
&[Point2::from([x, y1]), Point2::from([x, y2])],
1.0,
*color,
)?;
@ -135,8 +135,8 @@ impl Game {
let bottom_line = Mesh::new_line(
ctx,
&[
Point2::new(BOUNDS.x, BOUNDS.y + BOUNDS.h),
Point2::new(BOUNDS.x + BOUNDS.w, BOUNDS.y + BOUNDS.h),
Point2::from([BOUNDS.x, BOUNDS.y + BOUNDS.h]),
Point2::from([BOUNDS.x + BOUNDS.w, BOUNDS.y + BOUNDS.h]),
],
2.0,
graphics::WHITE,
@ -189,7 +189,7 @@ impl Game {
.with_line_width(BOUNDS.h)
.with_line_cap(LineCap::Round),
),
&[Point2::new(head_x, body_y), Point2::new(tail_x, body_y)],
&[Point2::from([head_x, body_y]), Point2::from([tail_x, body_y])],
color,
)?;
graphics::draw(ctx, &body, DrawParam::default())?;

View file

@ -62,7 +62,5 @@ fn main() -> Result<()> {
game.jump_to_time(start_time)?;
}
event::run(&mut ctx, &mut event_loop, &mut game)?;
Ok(())
event::run(ctx, event_loop, game)
}

View file

@ -1,7 +1,6 @@
use anyhow::Result;
use ggez::{
graphics::{self, DrawParam, Image},
nalgebra::Point2,
Context,
};
@ -95,7 +94,7 @@ impl Texture {
image,
param
.scale([x_scale, y_scale])
.offset(Point2::new(0.5, 0.5)),
.offset([0.5, 0.5]),
)?;
Ok(())
}