+use std::collections::HashMap;
+
+use sdl2::image::LoadTexture;
+use sdl2::render::Texture;
+use sdl2::render::TextureCreator;
+use sdl2::video::WindowContext;
+
+pub struct SpriteManager<'canvas> {
+ texture_creator: &'canvas TextureCreator<WindowContext>, // can't make the lifetimes work when this is owned instead of borrowed
+ textures: HashMap<&'static str, Texture<'canvas>>,
+}
+
+impl<'canvas> SpriteManager<'canvas> {
+ pub fn new(texture_creator: &'canvas TextureCreator<WindowContext>) -> SpriteManager<'canvas> {
+ SpriteManager {
+ texture_creator,
+ textures: HashMap::new(),
+ }
+ }
+
+ pub fn load(&mut self, name: &'static str, file: &str) {
+ self.textures.insert(name, self.texture_creator.load_texture(file).unwrap());
+ }
+
+ pub fn get(&self, name: &str) -> &Texture {
+ self.textures.get(name).expect(format!("The sprite '{}' was not found", name).as_str())
+ }
+}