Start updating
This commit is contained in:
parent
ea7fcae065
commit
bdd464bde2
3858
iced-tetris/Cargo.lock
generated
3858
iced-tetris/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,13 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "iced-tetris"
|
name = "iced-tetris"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2018"
|
edition = "2021"
|
||||||
resolver = "2"
|
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 = { git = "https://github.com/hecrj/iced", rev = "099981cfc2f61a1f37e84100592d65babb94fb82", features = ["tokio", "canvas"] }
|
iced = "0.13.1"
|
||||||
iced_native = { git = "https://github.com/hecrj/iced", rev = "099981cfc2f61a1f37e84100592d65babb94fb82"}
|
|
||||||
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" }
|
||||||
|
@ -1,17 +1,47 @@
|
|||||||
|
/*
|
||||||
use iced::widget::canvas::{self, Path, Stroke, Text};
|
use iced::widget::canvas::{self, Path, Stroke, Text};
|
||||||
use iced::{
|
use iced::{
|
||||||
executor, keyboard, time, Application, Color, Command, Element, Length, Point, Rectangle,
|
executor, keyboard, time, Application, Color, Command, Element, Length, Point, Rectangle,
|
||||||
Settings, Size, Subscription,
|
Settings, Size, Subscription,
|
||||||
};
|
};
|
||||||
use iced_native::{event, subscription, Event};
|
|
||||||
use tetris_logic::{BlockGrid, MoveDirection, Tetromino};
|
use tetris_logic::{BlockGrid, MoveDirection, Tetromino};
|
||||||
|
*/
|
||||||
|
|
||||||
|
use iced::{widget::{button, text}, Element, Task};
|
||||||
|
use tetris_logic::BlockGrid;
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
Tetris::run(Settings::default())
|
//Tetris::run(Settings::default())
|
||||||
|
iced::application(Tetris::title, update, view).run_with(|| (Tetris::new(), Task::none()))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
enum Message {
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Left,
|
||||||
|
Right,
|
||||||
|
Pause,
|
||||||
|
Tick(chrono::DateTime<chrono::Local>),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(_state: &mut Tetris, message: Message) {
|
||||||
|
match message {
|
||||||
|
Message::Up => todo!(),
|
||||||
|
Message::Down => todo!(),
|
||||||
|
Message::Left => todo!(),
|
||||||
|
Message::Right => todo!(),
|
||||||
|
Message::Pause => todo!(),
|
||||||
|
Message::Tick(_) => todo!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(_state: &Tetris) -> Element<Message> {
|
||||||
|
button(text("FOO")).on_press(Message::Up).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Tetris {
|
struct Tetris {
|
||||||
background_cache: canvas::Cache,
|
//background_cache: canvas::Cache,
|
||||||
blocks: BlockGrid,
|
blocks: BlockGrid,
|
||||||
ticks: usize,
|
ticks: usize,
|
||||||
paused: bool,
|
paused: bool,
|
||||||
@ -19,9 +49,13 @@ struct Tetris {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Tetris {
|
impl Tetris {
|
||||||
|
fn title(&self) -> String {
|
||||||
|
String::from("Tetris - Iced")
|
||||||
|
}
|
||||||
|
|
||||||
fn new() -> Tetris {
|
fn new() -> Tetris {
|
||||||
Tetris {
|
Tetris {
|
||||||
background_cache: canvas::Cache::default(),
|
//background_cache: canvas::Cache::default(),
|
||||||
blocks: BlockGrid::new(),
|
blocks: BlockGrid::new(),
|
||||||
ticks: 0,
|
ticks: 0,
|
||||||
paused: false,
|
paused: false,
|
||||||
@ -30,6 +64,7 @@ impl Tetris {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
impl Application for Tetris {
|
impl Application for Tetris {
|
||||||
type Executor = executor::Default;
|
type Executor = executor::Default;
|
||||||
type Message = Message;
|
type Message = Message;
|
||||||
@ -105,7 +140,9 @@ impl Application for Tetris {
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
impl<'a> canvas::Program<Message> for Tetris {
|
impl<'a> canvas::Program<Message> for Tetris {
|
||||||
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;
|
||||||
@ -171,7 +208,9 @@ 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> {
|
||||||
use keyboard::KeyCode;
|
use keyboard::KeyCode;
|
||||||
|
|
||||||
@ -184,13 +223,5 @@ fn handle_keypress(key_code: keyboard::KeyCode) -> Option<Message> {
|
|||||||
_ => return None,
|
_ => return None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum Message {
|
|
||||||
Up,
|
|
||||||
Down,
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Pause,
|
|
||||||
Tick(chrono::DateTime<chrono::Local>),
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user