2021-06-30 23:16:45 +00:00
|
|
|
import botonJugarImg from "./assets/boton_jugar.png";
|
2021-07-01 22:33:51 +00:00
|
|
|
import flechaImg from "./assets/flecha.png";
|
2021-07-01 20:45:37 +00:00
|
|
|
import larretaImg from "./assets/Larreta.png";
|
|
|
|
import millonarioMaloPng from "./assets/Millonario Malo.png";
|
2021-07-01 21:08:19 +00:00
|
|
|
import cieloRioCalleImg from "./assets/CieloRioCalle.png";
|
|
|
|
import cieloImg from "./assets/Cielo.png";
|
|
|
|
import rioImg from "./assets/Rio.png";
|
|
|
|
import parquePublicoRioImg from "./assets/Parque publico con rio.png";
|
|
|
|
import parquePublicoImg from "./assets/Parque publico.png";
|
2021-06-30 23:16:45 +00:00
|
|
|
import edificiosImg from "./assets/Edificios.png";
|
|
|
|
import jugadorxImg from "./assets/ProtagonistaCorriendo_1.png";
|
|
|
|
import baldosaImg from "./assets/Baldosa.png";
|
|
|
|
import semillaImg from "./assets/Semilla.png";
|
|
|
|
import arbol1Img from "./assets/Árbol 1.png";
|
|
|
|
import arbol2Img from "./assets/Árbol 2.png";
|
2021-07-02 18:17:35 +00:00
|
|
|
import ciudadanx1Img from "./assets/Firma 1.png";
|
|
|
|
import ciudadanx2Img from "./assets/Firma 2.png";
|
|
|
|
import ciudadanx3Img from "./assets/Firma 3.png";
|
2021-06-28 20:28:26 +00:00
|
|
|
|
|
|
|
function loadImage(url: string): Promise<HTMLImageElement> {
|
2021-06-30 23:16:45 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
let img = new Image();
|
|
|
|
img.onload = () => resolve(img);
|
|
|
|
img.onerror = (e) => reject(e);
|
|
|
|
img.src = url;
|
|
|
|
});
|
2021-06-28 20:28:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export const assetUrls = {
|
2021-06-30 23:16:45 +00:00
|
|
|
botonJugar: botonJugarImg,
|
2021-07-01 22:33:51 +00:00
|
|
|
flecha: flechaImg,
|
2021-06-30 23:16:45 +00:00
|
|
|
larreta: larretaImg,
|
2021-07-01 20:45:37 +00:00
|
|
|
millonarioMalo: millonarioMaloPng,
|
2021-07-01 21:08:19 +00:00
|
|
|
cieloRioCalle: cieloRioCalleImg,
|
|
|
|
cielo: cieloImg,
|
|
|
|
rio: rioImg,
|
|
|
|
parquePublicoRio: parquePublicoRioImg,
|
|
|
|
parquePublico: parquePublicoImg,
|
2021-06-30 23:16:45 +00:00
|
|
|
edificios: edificiosImg,
|
|
|
|
jugadorx: jugadorxImg,
|
|
|
|
baldosa: baldosaImg,
|
|
|
|
semilla: semillaImg,
|
|
|
|
arbol1: arbol1Img,
|
|
|
|
arbol2: arbol2Img,
|
2021-07-02 18:17:35 +00:00
|
|
|
ciudadanx1: ciudadanx1Img,
|
|
|
|
ciudadanx2: ciudadanx2Img,
|
|
|
|
ciudadanx3: ciudadanx3Img,
|
2021-06-30 23:16:45 +00:00
|
|
|
};
|
|
|
|
export type Assets = { [key in keyof typeof assetUrls]: HTMLImageElement };
|
2021-06-28 20:28:26 +00:00
|
|
|
|
2021-06-30 23:16:45 +00:00
|
|
|
const assets = Object.fromEntries(
|
|
|
|
Object.entries(assetUrls).map(([name, url]) => [name, loadImage(url)])
|
|
|
|
);
|
2021-06-28 20:28:26 +00:00
|
|
|
|
|
|
|
export async function loadAssets() {
|
2021-06-30 23:16:45 +00:00
|
|
|
const imgs = await Promise.all(Object.values(assets));
|
|
|
|
return Object.fromEntries(
|
|
|
|
imgs.map((img, i) => [Object.keys(assetUrls)[i], img])
|
|
|
|
) as Assets;
|
2021-06-28 20:28:26 +00:00
|
|
|
}
|