|
@ -6,11 +6,13 @@ namespace Smoll.Ex2 |
|
|
string path; |
|
|
string path; |
|
|
|
|
|
|
|
|
Dictionary<string, Image> images; |
|
|
Dictionary<string, Image> images; |
|
|
|
|
|
Dictionary<string, Texture2D> textures; |
|
|
Dictionary<string, Sound> sounds; |
|
|
Dictionary<string, Sound> sounds; |
|
|
|
|
|
|
|
|
public RaylibAssetManagerModule(string path = "./assets") { |
|
|
public RaylibAssetManagerModule(string path = "./assets") { |
|
|
this.path = path; |
|
|
this.path = path; |
|
|
images = new Dictionary<string, Image>(); |
|
|
images = new Dictionary<string, Image>(); |
|
|
|
|
|
textures = new Dictionary<string, Texture2D>(); |
|
|
sounds = new Dictionary<string, Sound>(); |
|
|
sounds = new Dictionary<string, Sound>(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -23,6 +25,16 @@ namespace Smoll.Ex2 |
|
|
return image; |
|
|
return image; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Texture2D GetTexture(string name) { |
|
|
|
|
|
Texture2D texture; |
|
|
|
|
|
if(! textures.TryGetValue(name, out texture)) { |
|
|
|
|
|
Image image = GetImage(name); |
|
|
|
|
|
texture = Raylib.LoadTextureFromImage(image); |
|
|
|
|
|
textures.Add(name, texture); |
|
|
|
|
|
} |
|
|
|
|
|
return texture; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public Sound GetSound(string name) { |
|
|
public Sound GetSound(string name) { |
|
|
Sound sound; |
|
|
Sound sound; |
|
|
if(! sounds.TryGetValue(name, out sound)) { |
|
|
if(! sounds.TryGetValue(name, out sound)) { |
|
|