A Smoll game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 rivejä
1.4 KiB

using Raylib_cs;
namespace Smoll.Ex2
{
class RaylibAssetManagerModule : IEngineModule {
string path;
Dictionary<string, Image> images;
Dictionary<string, Texture2D> textures;
Dictionary<string, Sound> sounds;
public RaylibAssetManagerModule(string path = "./assets") {
this.path = path;
images = new Dictionary<string, Image>();
textures = new Dictionary<string, Texture2D>();
sounds = new Dictionary<string, Sound>();
}
public Image GetImage(string name) {
Image image;
if(! images.TryGetValue(name, out image)) {
image = Raylib.LoadImage(path+"/"+name);
images.Add(name, 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) {
Sound sound;
if(! sounds.TryGetValue(name, out sound)) {
sound = Raylib.LoadSound(path+"/"+name);
sounds.Add(name, sound);
}
return sound;
}
}
}