From 64de5fb732533454a7124e6b7ddd93671a04bab2 Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 8 Sep 2023 22:48:13 -0500 Subject: [PATCH] feat: texture manager, texture loading --- src/textures.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/textures.rs diff --git a/src/textures.rs b/src/textures.rs new file mode 100644 index 0000000..9479bc1 --- /dev/null +++ b/src/textures.rs @@ -0,0 +1,29 @@ + +use sdl2::{ + image::LoadTexture, + render::{Texture, TextureCreator}, + video::WindowContext, +}; + +pub struct TextureManager<'a> { + pub map: Texture<'a>, + pub pacman: Texture<'a>, +} + +impl<'a> TextureManager<'a> { + pub fn new(texture_creator: &'a TextureCreator) -> Self { + let map_texture = texture_creator + .load_texture("assets/map.png") + .expect("Could not load pacman texture"); + + let pacman_atlas = texture_creator + .load_texture("assets/pacman.png") + .expect("Could not load pacman texture"); + + + TextureManager { + map: map_texture, + pacman: pacman_atlas, + } + } +} \ No newline at end of file