diff options
author | Tom Barrett <tom@tombarrett.xyz> | 2021-01-31 18:15:31 +0100 |
---|---|---|
committer | Tom Barrett <tom@tombarrett.xyz> | 2021-01-31 18:15:31 +0100 |
commit | 802a5650ed5d33363c53a7032a58eb1d574a81bf (patch) | |
tree | 249e3b2f066cbc5a7655e43d8df6fdb4e2be41a1 /src | |
parent | 66350ac2db1deaf3453987d8af9b83a02953ba83 (diff) |
background added
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 42595ad..edbb973 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use rand::{ Rng, }; -pub const TILE_SCALE: f32 = 2.0; +pub const TILE_SCALE: f32 = 3.0; pub const TILE_HEIGHT: f32 = 16.0; pub const TILE_WIDTH: f32 = 16.0; pub const BORDER_SIZE: f32 = 3.0; @@ -140,10 +140,14 @@ struct Game { selected: Option<(usize, usize)>, spritebatch: SpriteBatch, grid: Vec<Vec<Cell>>, + background: Image, } impl Game { fn new(context: &mut Context) -> GameResult<Game> { + let mut background = Image::new(context, "/background.png")?; + background.set_filter(FilterMode::Nearest); + let mut image = Image::new(context, "/gem.png")?; image.set_filter(FilterMode::Nearest); image.set_wrap(WrapMode::Mirror, WrapMode::Mirror); @@ -190,6 +194,7 @@ impl Game { grid, selected: None, spritebatch: SpriteBatch::new(image), + background, }) } } @@ -275,7 +280,8 @@ impl EventHandler for Game { } fn draw(&mut self, context: &mut Context) -> GameResult { - graphics::clear(context, [0.1, 0.2, 0.3, 1.0].into()); + graphics::clear(context, [0.0, 0.0, 0.0, 1.0].into()); + graphics::draw(context, &self.background, DrawParam::default())?; for row in self.grid.iter() { for cell in row.iter() { |