Continuing update

This commit is contained in:
Greg Shuflin 2024-10-03 18:51:02 -07:00
parent d030563e49
commit 73b7af9777
3 changed files with 82 additions and 8 deletions

61
iced-tetris/Cargo.lock generated
View File

@ -1028,6 +1028,12 @@ dependencies = [
"miniz_oxide", "miniz_oxide",
] ]
[[package]]
name = "float_next_after"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8"
[[package]] [[package]]
name = "font-types" name = "font-types"
version = "0.6.0" version = "0.6.0"
@ -1509,6 +1515,7 @@ dependencies = [
"iced_core", "iced_core",
"iced_futures", "iced_futures",
"log", "log",
"lyon_path",
"once_cell", "once_cell",
"raw-window-handle", "raw-window-handle",
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
@ -1572,6 +1579,7 @@ dependencies = [
"iced_glyphon", "iced_glyphon",
"iced_graphics", "iced_graphics",
"log", "log",
"lyon",
"once_cell", "once_cell",
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
"thiserror", "thiserror",
@ -1786,6 +1794,58 @@ version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904" checksum = "37ee39891760e7d94734f6f63fedc29a2e4a152f836120753a72503f09fcf904"
[[package]]
name = "lyon"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e7f9cda98b5430809e63ca5197b06c7d191bf7e26dfc467d5a3f0290e2a74f"
dependencies = [
"lyon_algorithms",
"lyon_tessellation",
]
[[package]]
name = "lyon_algorithms"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3bca95f9a4955b3e4a821fbbcd5edfbd9be2a9a50bb5758173e5358bfb4c623"
dependencies = [
"lyon_path",
"num-traits",
]
[[package]]
name = "lyon_geom"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edecfb8d234a2b0be031ab02ebcdd9f3b9ee418fb35e265f7a540a48d197bff9"
dependencies = [
"arrayvec",
"euclid",
"num-traits",
]
[[package]]
name = "lyon_path"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c08a606c7a59638d6c6aa18ac91a06aa9fb5f765a7efb27e6a4da58700740d7"
dependencies = [
"lyon_geom",
"num-traits",
]
[[package]]
name = "lyon_tessellation"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579d42360a4b09846eff2feef28f538696c7d6c7439bfa65874ff3cbe0951b2c"
dependencies = [
"float_next_after",
"lyon_path",
"num-traits",
]
[[package]] [[package]]
name = "malloc_buf" name = "malloc_buf"
version = "0.0.6" version = "0.0.6"
@ -1923,6 +1983,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"libm",
] ]
[[package]] [[package]]

View File

@ -7,7 +7,7 @@ resolver = "2"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
iced = { version = "0.13.1", features = ["tokio"] } iced = { version = "0.13.1", features = ["tokio", "canvas"] }
chrono = "0.4.19" chrono = "0.4.19"
rand = "0.8.4" rand = "0.8.4"
tetris-logic = { path = "../tetris-logic" } tetris-logic = { path = "../tetris-logic" }

View File

@ -8,8 +8,8 @@ use tetris_logic::{BlockGrid, MoveDirection, Tetromino};
*/ */
use iced::{ use iced::{
widget::{button, text}, widget::{button, canvas, text},
Element, Subscription, Task, Element, Renderer, Subscription, Task, Theme,
}; };
use tetris_logic::{BlockGrid, MoveDirection, Tetromino}; use tetris_logic::{BlockGrid, MoveDirection, Tetromino};
@ -96,8 +96,8 @@ fn subscription(_state: &Tetris) -> Subscription<Message> {
Subscription::batch([time_subscription, keyboard_subscription]) Subscription::batch([time_subscription, keyboard_subscription])
} }
fn view(_state: &Tetris) -> Element<Message> { fn view(state: &Tetris) -> Element<Message> {
button(text("FOO")).on_press(Message::Up).into() canvas(state).into()
} }
struct Tetris { struct Tetris {
@ -202,8 +202,21 @@ impl Application for Tetris {
} }
*/ */
/* impl canvas::Program<Message> for Tetris {
impl<'a> canvas::Program<Message> for Tetris { type State = ();
fn draw(
&self,
state: &Self::State,
renderer: &Renderer,
theme: &Theme,
bounds: iced::Rectangle,
_cursor: iced::mouse::Cursor,
) -> Vec<canvas::Geometry<Renderer>> {
todo!()
}
/*
fn draw(&self, bounds: Rectangle, _cursor: canvas::Cursor) -> Vec<canvas::Geometry> { fn draw(&self, bounds: Rectangle, _cursor: canvas::Cursor) -> Vec<canvas::Geometry> {
let game_width = bounds.width / 3.0; let game_width = bounds.width / 3.0;
let block_length = game_width / 10.0; let block_length = game_width / 10.0;
@ -267,8 +280,8 @@ impl<'a> canvas::Program<Message> for Tetris {
vec![background, frame.into_geometry()] vec![background, frame.into_geometry()]
} }
*/
} }
*/
/* /*
fn handle_keypress(key_code: keyboard::KeyCode) -> Option<Message> { fn handle_keypress(key_code: keyboard::KeyCode) -> Option<Message> {