summaryrefslogtreecommitdiffstats
path: root/examples/ggez/main.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-04 11:09:57 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-09-04 11:09:57 +0200
commitc583a2174d28878a6b1a31288e80b96fac62e799 (patch)
tree36c80d9a0565980d6bbee62c548c8db142555ba2 /examples/ggez/main.rs
parent2c35103035e47485f2fb049f86b3c00feb4b99d2 (diff)
downloadiced-c583a2174d28878a6b1a31288e80b96fac62e799.tar.gz
iced-c583a2174d28878a6b1a31288e80b96fac62e799.tar.bz2
iced-c583a2174d28878a6b1a31288e80b96fac62e799.zip
Improve tour example
Diffstat (limited to 'examples/ggez/main.rs')
-rw-r--r--examples/ggez/main.rs21
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/ggez/main.rs b/examples/ggez/main.rs
index 329bde81..0a6a2005 100644
--- a/examples/ggez/main.rs
+++ b/examples/ggez/main.rs
@@ -16,8 +16,8 @@ pub fn main() -> ggez::GameResult {
let (context, event_loop) = {
&mut ggez::ContextBuilder::new("iced", "ggez")
.window_mode(ggez::conf::WindowMode {
- width: 1280.0,
- height: 1024.0,
+ width: 850.0,
+ height: 850.0,
..ggez::conf::WindowMode::default()
})
.build()?
@@ -39,6 +39,7 @@ pub fn main() -> ggez::GameResult {
struct Game {
spritesheet: graphics::Image,
+ font: graphics::Font,
tour: Tour,
events: Vec<iced::Event>,
@@ -51,7 +52,8 @@ impl Game {
Ok(Game {
spritesheet: graphics::Image::new(context, "/ui.png").unwrap(),
- tour: Tour::new(),
+ font: graphics::Font::new(context, "/Roboto-Regular.ttf").unwrap(),
+ tour: Tour::new(context),
events: Vec::new(),
cache: Some(iced::Cache::default()),
@@ -126,7 +128,7 @@ impl event::EventHandler for Game {
}
fn draw(&mut self, context: &mut ggez::Context) -> ggez::GameResult {
- graphics::clear(context, [0.3, 0.3, 0.6, 1.0].into());
+ graphics::clear(context, graphics::WHITE);
let screen = graphics::screen_coordinates(context);
@@ -134,14 +136,17 @@ impl event::EventHandler for Game {
let layout = self.tour.layout();
let content = Column::new()
- .width(screen.w as u32)
- .height(screen.h as u32)
+ .width(screen.w as u16)
+ .height(screen.h as u16)
.align_items(iced::Align::Center)
.justify_content(iced::Justify::Center)
.push(layout);
- let renderer =
- &mut Renderer::new(context, self.spritesheet.clone());
+ let renderer = &mut Renderer::new(
+ context,
+ self.spritesheet.clone(),
+ self.font,
+ );
let mut ui = iced::UserInterface::build(
content,