btco / qx82

Tiny Javascript engine for retro games
MIT License
421 stars 19 forks source link

Is there a way to modify the project to be able to use APNG or GIF as images? #7

Open nomehagasmuchocaso opened 9 months ago

nomehagasmuchocaso commented 9 months ago

I'm developing a small choose-your-own-adventure example to learn how to use qx82 and the only way I've gotten animated images is by using 90 to 100 separate frames for a simple background animation using qx.frame.

Is there a way to load animated images that are not JPG or PNG?

btco commented 9 months ago

Ah! For now only JPG and PNG are supported, but there is qx.drawImageRect() that allows you to draw a part of an image (you can see it in action in example-puzzle).

So in theory you could lay out your animation frames side by side in a single image like a sprite sheet, and then cycle through them using qx.frame(), drawing a different rectangle each time. That will be a lot faster than loading 100 separate images.

But I'll look into supporting animations in a more straightforward way in the future. I'd love to see your choose-your-own-adventure game when it's ready!

Thanks!

nomehagasmuchocaso commented 9 months ago

Thank you very much for the response, I will investigate the puzzle example and will be on the lookout for future updates.