diff --git a/src/level-loader.js b/src/level-loader.js new file mode 100644 index 0000000..edf510a --- /dev/null +++ b/src/level-loader.js @@ -0,0 +1,22 @@ +class Level { + constructor({ image, layer }) { + this.image = image; + this.layer = layer; + } +} + +export default class LevelLoader { + /** + * Loads a level on memory from the specified source and layer. + * + * @return {Promise} A Promise that resolves with the loaded level. + */ + static load({ source, layer }) { + return new Promise((resolve, reject) => { + const image = new Image(); + image.src = source; + image.onload = () => resolve(new Level({ image, layer })); + image.onerror = reject; + }); + } +} diff --git a/src/resource-loader.js b/src/resource-loader.js deleted file mode 100644 index 4b86564..0000000 --- a/src/resource-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -export default class ResourceLoader { -/** - * Loads an image from the specified URL. - * - * @return {Promise} A Promise that resolves with the loaded image. - */ - static load(url) { - return new Promise((resolve, reject) => { - const image = new Image(); - image.src = url; - image.onload = () => resolve(image) - image.onerror = reject; - }); - } -}