- Jan 25, 2018
- 97
- 119
Long story short I am making a game where I want to allow users to create their own imagepacks in JavaScript using only localhost. This means no NodeJS is ever expected to run and no apache or whatever else config can be set up to make server directories discoverable.
Right now I am bruteforcing the first 200 namespaces of what I would expect (ex: if I have an image for "woman" I would try to load everything from woman(1).png to woman(200).png, same thing for a handful of other file extensions). This is what we in the development business call a hilariously bad solution for a hilariously terrible problem. It is, however, the only solution I've found so far that is both flexible and easy for users to add to.
The requirements I'm imposing myself are as follows:
- User-side must require, at most, adding a line to a txt or similar file to add a new imagepack directory full of images of various formats
- Strict naming conventions for image files are fine, no naming conventions for image files are better (would allow for multiple image packs to be loaded at once)
- Images are loaded up during startup so they can be randomized during the game
And before someone thinks to say it, I am extremely painfully aware that just about any other programming language would be not only easier but far more adequate for a project like this. I am also doing this to myself to learn JavaScript coming from Java, and I am actually really happy with the progress I'm making.
Right now I am bruteforcing the first 200 namespaces of what I would expect (ex: if I have an image for "woman" I would try to load everything from woman(1).png to woman(200).png, same thing for a handful of other file extensions). This is what we in the development business call a hilariously bad solution for a hilariously terrible problem. It is, however, the only solution I've found so far that is both flexible and easy for users to add to.
The requirements I'm imposing myself are as follows:
- User-side must require, at most, adding a line to a txt or similar file to add a new imagepack directory full of images of various formats
- Strict naming conventions for image files are fine, no naming conventions for image files are better (would allow for multiple image packs to be loaded at once)
- Images are loaded up during startup so they can be randomized during the game
And before someone thinks to say it, I am extremely painfully aware that just about any other programming language would be not only easier but far more adequate for a project like this. I am also doing this to myself to learn JavaScript coming from Java, and I am actually really happy with the progress I'm making.