Compare commits
No commits in common. "2978a661d53aeb02ecda7e42ede31002acd1d0d4" and "e105053e81856da393c2338989fc83db8e7bd6ba" have entirely different histories.
2978a661d5
...
e105053e81
@ -1,4 +1,4 @@
|
|||||||
use iced::widget::canvas::{self, Path, Stroke, Text};
|
use iced::widget::canvas::{self, Path};
|
||||||
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,
|
||||||
@ -66,7 +66,7 @@ impl Application for Tetris {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.blocks.piece_currently_active() {
|
if self.blocks.piece_currently_active() {
|
||||||
if self.ticks % 10 == 0 && !self.paused {
|
if self.ticks % 10 == 0 {
|
||||||
self.blocks.move_active_piece(MoveDirection::SoftDrop);
|
self.blocks.move_active_piece(MoveDirection::SoftDrop);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -129,43 +129,8 @@ impl<'a> canvas::Program<Message> for Tetris {
|
|||||||
);
|
);
|
||||||
let block = Path::rectangle(point, block_size);
|
let block = Path::rectangle(point, block_size);
|
||||||
let color = tetronimo.color();
|
let color = tetronimo.color();
|
||||||
let fill_color = Color::from_rgb8(color.0, color.1, color.2);
|
let color = Color::from_rgb8(color.0, color.1, color.2);
|
||||||
frame.fill(&block, fill_color);
|
frame.fill(&block, color);
|
||||||
|
|
||||||
let stroke_color = Color::from_rgb8(
|
|
||||||
color.0.checked_sub(20).unwrap_or(0),
|
|
||||||
color.1.checked_sub(20).unwrap_or(0),
|
|
||||||
color.2.checked_sub(20).unwrap_or(0),
|
|
||||||
);
|
|
||||||
let stroke = Stroke {
|
|
||||||
width: 3.0,
|
|
||||||
color: stroke_color,
|
|
||||||
..Stroke::default()
|
|
||||||
};
|
|
||||||
frame.stroke(&block, stroke);
|
|
||||||
}
|
|
||||||
|
|
||||||
let text_color = Color::from_rgb8(255, 30, 30);
|
|
||||||
let text_size = 32.0;
|
|
||||||
let score = Text {
|
|
||||||
content: format!("Lines removed: {}", self.lines_removed),
|
|
||||||
position: Point::new(10.0, 30.0),
|
|
||||||
color: text_color,
|
|
||||||
size: text_size,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
frame.fill_text(score);
|
|
||||||
|
|
||||||
if self.paused {
|
|
||||||
let paused = Text {
|
|
||||||
content: format!("PAUSED"),
|
|
||||||
position: Point::new(10.0, 60.0),
|
|
||||||
color: text_color,
|
|
||||||
size: text_size,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
frame.fill_text(paused);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec![background, frame.into_geometry()]
|
vec![background, frame.into_geometry()]
|
||||||
|
Loading…
Reference in New Issue
Block a user