Check ([ ] -> [x]) all that apply, then describe the issue below:
[x] I have searched the tracker for similar issues (including closed ones)
[x] I have provided a detailed example for how this feature should work
[x] I have provided a use case for this feature, e.g. short description/share link of a game you're making and how you'd use the feature in that game, other things you've tried, edge cases, etc. (if applicable)
I wanted to add support for using full resolution images / spritesheets. A simple way to get this working was to support loading and drawing from a URL like this:
I based the load_images command on how custom_font currently works, and I special-cased the canvas drawImage command to use the images you loaded earlier (currently any drawImage command fails with an error because the image argument is passed as a string).
The main downside of this approach is that you have to host the images online somewhere. If you try to load them from a local file, Chrome will give you a CORS error (anecdotally, Safari seems to be less picky). One solution is to upload the images to a GitHub repo, or you also could try running a local server which sets the right CORS headers for images (Python's simple HTTP server does not set these headers, so it doesn't work).
So the workflow is a bit annoying, but it does work :)
An different approach might be to have PuzzleScript pop up a file dialog where you can import your image, and it would be saved to localstorage. Then when you export the game, it would be written back out to an image file next to the html file. This would be a lot harder to implement, though.
Check ([ ] -> [x]) all that apply, then describe the issue below:
I wanted to add support for using full resolution images / spritesheets. A simple way to get this working was to support loading and drawing from a URL like this:
I based the
load_images
command on howcustom_font
currently works, and I special-cased the canvasdrawImage
command to use the images you loaded earlier (currently any drawImage command fails with an error because the image argument is passed as a string).The main downside of this approach is that you have to host the images online somewhere. If you try to load them from a local file, Chrome will give you a CORS error (anecdotally, Safari seems to be less picky). One solution is to upload the images to a GitHub repo, or you also could try running a local server which sets the right CORS headers for images (Python's simple HTTP server does not set these headers, so it doesn't work).
So the workflow is a bit annoying, but it does work :)
An different approach might be to have PuzzleScript pop up a file dialog where you can import your image, and it would be saved to localstorage. Then when you export the game, it would be written back out to an image file next to the html file. This would be a lot harder to implement, though.