public static void LoadAssets(Engine engine) // Perche Static? { var startLevel = new SpriteAsset("../../Assets/StartLevel.png"); engine.LoadAsset("startLevel", new SpriteAsset("../../Assets/StartLevel.png", 0, 0, startLevel.Width, startLevel.Height)); //Load Asset Player int tileWidth; int tileHeight; SpriteAsset playerAsset = new SpriteAsset("../../Assets/player.png"); tileWidth = playerAsset.Width / 22; tileHeight = playerAsset.Height; for (int i = 0; i < 22; i++) { engine.LoadAsset($"Player_{i}", new SpriteAsset("../../Assets/player.png", i * tileWidth, 0, tileWidth, tileHeight)); engine.LoadAsset($"PlayerRight_{i}", new SpriteAsset("../../Assets/playerRight.png", i * tileWidth, 0, tileWidth, tileHeight)); } }
public void LoadAssets(Engine engine) { SpriteAsset image = new SpriteAsset("../../assets/bar.png"); int tileWidth = image.Width / rows; int tileHeight = image.Height / cols; for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { engine.LoadAsset($"bar_{x}_{y}", new SpriteAsset("../../assets/bar.png", x * tileWidth, y * tileHeight, tileWidth, tileHeight)); } } }
public static void LoadAssets(Engine engine, string assetName, string pathName, int rows, int cols) { SpriteAsset spriteAsset = new SpriteAsset(pathName); int width = spriteAsset.Width / cols; int height = spriteAsset.Height / rows; for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { engine.LoadAsset(assetName + "_" + x + "_" + y, new SpriteAsset(pathName, x * width, y * height, width, height)); } } }
public static void LoadAnimation(Engine engine, string name, string fileName, int xLen, int yLen) { var spriteAsset = new SpriteAsset(fileName); var blockSizeOnWall = new Vector2(spriteAsset.Width/(float) xLen, spriteAsset.Height/(float) yLen); for (var posX = 0; posX < xLen; posX++) for (var posY = 0; posY < yLen; posY++) { var animName = $"{name}_{posY}_{posX}"; Debug.WriteLine("Loaded animations: " + animName); engine.LoadAsset(animName, new SpriteAsset(fileName, (int) (posX*blockSizeOnWall.X), (int) (posY*blockSizeOnWall.Y), (int) blockSizeOnWall.X, (int) blockSizeOnWall.Y)); } }
private void LoadAsset(Engine engine) { int tileWidth; int tileHeight; SpriteAsset jdComplete = new SpriteAsset("../../Assets/jd.png"); // carica la sprite completa tileWidth = jdComplete.Width / 3; // lunghezza della sprite = lunghezza sprite completa/ le colonne tileHeight = jdComplete.Height / 5; // altezza della sprite = altezza sprite completa / le righe //ciclo for per caricare ad ogni chiave la propria sprite for (int i = 0; i < 3; i++) { for (int j = 0; j < 5; j++) { engine.LoadAsset($"jd_{j}_{i}", new SpriteAsset("../../Assets/jd.png", i * tileWidth, j * tileHeight, tileWidth, tileHeight)); //load asset = metodo che torna dictonary } } }