Skip to content

Commit

Permalink
chore: Update dependencies
Browse files Browse the repository at this point in the history
Changelog:
- Updates specs to 0.16.0

NOTE: Could not update to 0.17.0, there was a problem
with the crate component_group macro.
  • Loading branch information
EverWinter23 committed Nov 17, 2021
1 parent e4f4c92 commit 899aba3
Show file tree
Hide file tree
Showing 47 changed files with 1,448 additions and 1,122 deletions.
512 changes: 130 additions & 382 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ authors = ["Sunjay Varma <[email protected]>"]
edition = "2018"

[dependencies]
specs = "*"
specs-derive = "*"
shred = "*"
shred-derive = "*"
specs = { version = "0.16.0", features=["specs-derive", "shred-derive"] }
rand = "0.7"
base64 = "0.13"
lazy_static = "1.4"
colored = "2.0"
rayon = "1.5"
component_group = "1.0"
component_group = "3.0.0"
rusttype = "0.7"

[dependencies.sdl2]
Expand Down
27 changes: 17 additions & 10 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod texture_manager;
mod sprite_manager;
mod sprite;
mod sprite_manager;
mod texture_manager;

pub use self::texture_manager::*;
pub use self::sprite_manager::*;
pub use self::sprite::*;
pub use self::sprite_manager::*;
pub use self::texture_manager::*;

use sdl2::render::TextureCreator;

Expand All @@ -25,16 +25,25 @@ pub struct AssetManager<'a, T> {
}

impl<'a, T> AssetManager<'a, T> {
pub fn load(texture_creator: &'a TextureCreator<T>, fps: usize, tile_size: u32) -> Result<Self, SDLError> {
pub fn load(
texture_creator: &'a TextureCreator<T>,
fps: usize,
tile_size: u32,
) -> Result<Self, SDLError> {
let mut textures = TextureManager::new(&texture_creator);
let mut sprites = SpriteManager::default();

let map_texture = textures.create_png_texture("assets/dungeon.png")?;
let map_sprites = MapSprites::from_dungeon_spritesheet(map_texture, &mut sprites, tile_size);
let map_sprites =
MapSprites::from_dungeon_spritesheet(map_texture, &mut sprites, tile_size);

let mut character_animations = |path| {
let texture = textures.create_png_texture(path)?;
Ok(AnimationManager::standard_character_animations(fps, texture, &mut sprites))
Ok(AnimationManager::standard_character_animations(
fps,
texture,
&mut sprites,
))
};

let player_animations = character_animations("assets/hero.png")?;
Expand All @@ -44,9 +53,7 @@ impl<'a, T> AssetManager<'a, T> {
textures,
map_sprites,
player_animations,
enemy_animations: EnemyAnimations {
rat,
},
enemy_animations: EnemyAnimations { rat },
sprites,
})
}
Expand Down
17 changes: 6 additions & 11 deletions src/assets/sprite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,17 @@ impl SpriteImage {
// Each of these calculations is calculating the anchor point on dest and then offsetting
// by the width and height of the sprite to get the top left corner of the result rectangle
let top_left = match self.anchor {
Anchor::N => Point::new(center.x(), dest.top()).offset(-width/2, 0),
Anchor::N => Point::new(center.x(), dest.top()).offset(-width / 2, 0),
Anchor::NE => dest.top_right().offset(-width, 0),
Anchor::E => Point::new(dest.right(), center.y()).offset(-width, -height/2),
Anchor::E => Point::new(dest.right(), center.y()).offset(-width, -height / 2),
Anchor::SE => dest.bottom_right().offset(-width, -height),
Anchor::S => Point::new(center.x(), dest.bottom()).offset(-width/2, -height),
Anchor::S => Point::new(center.x(), dest.bottom()).offset(-width / 2, -height),
Anchor::SW => dest.bottom_left().offset(0, -height),
Anchor::W => Point::new(dest.left(), center.y()).offset(0, -height/2),
Anchor::W => Point::new(dest.left(), center.y()).offset(0, -height / 2),
Anchor::NW => dest.top_left(),
Anchor::Center => center.offset(-width/2, -height/2),
Anchor::Center => center.offset(-width / 2, -height / 2),
};

Rect::new(
top_left.x(),
top_left.y(),
width as u32,
height as u32,
)
Rect::new(top_left.x(), top_left.y(), width as u32, height as u32)
}
}
10 changes: 7 additions & 3 deletions src/assets/texture_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::{
path::{Path, PathBuf},
};

use sdl2::{image::LoadTexture, render::{TextureCreator, Texture}};
use sdl2::{
image::LoadTexture,
render::{Texture, TextureCreator},
};

use crate::ui::SDLError;

Expand Down Expand Up @@ -39,13 +42,14 @@ impl<'a, T> TextureManager<'a, T> {
pub fn create_png_texture<P: AsRef<Path>>(&mut self, path: P) -> Result<TextureId, SDLError> {
let path = path.as_ref();
if self.path_textures.contains_key(path) {
return Ok(self.path_textures[path])
return Ok(self.path_textures[path]);
}

let texture = self.texture_creator.load_texture(path).map_err(SDLError)?;
self.textures.push(texture);
let id = TextureId(self.textures.len() - 1);
let path = path.canonicalize()
let path = path
.canonicalize()
.expect("Failed to canonicalize path for loaded texture");
self.path_textures.insert(path, id);

Expand Down
12 changes: 6 additions & 6 deletions src/components.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod physics;
mod character;
mod entrance;
mod graphics;
mod stairs;
mod item;
mod entrance;
mod physics;
mod stairs;

pub use self::physics::*;
pub use self::character::*;
pub use self::entrance::*;
pub use self::graphics::*;
pub use self::stairs::*;
pub use self::item::*;
pub use self::entrance::*;
pub use self::physics::*;
pub use self::stairs::*;
2 changes: 1 addition & 1 deletion src/components/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use component_group::ComponentGroup;

use specs::{Component, VecStorage, HashMapStorage, NullStorage};
use specs::{Component, HashMapStorage, NullStorage, VecStorage};

/// All the components of a player. Grouped together so they can be easily copied to and from
/// worlds. The reason this struct exists is because specs doesn't provide a way to copy all the
Expand Down
Loading

0 comments on commit 899aba3

Please sign in to comment.