-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Should Game::load
receive &mut Window
? (not a duplicate of #130)
#137
Comments
Here is a quick example of something I want to do that needs Game::load to have a mutable window. I'm adding in ECS, specifically Specs. My rendering system needs a value put into the ECS world object that the render function can draw to. That value should be initialised in the load function. I was going to use Batch. To create a batch you need an image and to create an image you need a gpu.
EDIT Ok, I seemed to have figured out how to do this. It still feels kinda hacky to me though and would be simplified by Game::load getting a mut window. This is my new Game::load function:
Is this an abuse of the task system or more or less the intended use? EDIT 2 |
So this may be a dumb question as it is very similar to #130 (I copied the title and tweaked it slightly even).
I'm having some trouble understanding Tasks, so this may just be stemming from that.
I have this code that does not work because Game::load receives an immutable window ref.
The issue is, I want to load this image now then pass it into the MyGame object at the end of the load function. But Task::run function needs gpu and the Window::gpu function wants a mutable Window which load doesn't get.
In #103 you said it is by design that Game::update doesn't get a mutable window because only game logic should happen there and you don't want it to be changing the window itself, but I assume the same doesn't apply to Game::load, or am I wrong?
This is likely me just being confused about Tasks. When do Tasks actually get run? From the looks of it, it seems whatever calls Game::load runs the task(s), but if I have 100 images to load and I'm only supposed to return a Task<Game> from load how am I supposed to load all those images?
Also, down the road I want to have an AssetDatabase struct that holds lookup tables for all loaded assets (sprite sheets, dialogue trees, etc). And I want to load those assets after the main menu when the player selects one of the campaigns to play. That means it won't be happening in Game::load. But I also don't want some 'if' statement stuck in my Game::draw function being checked every tick. Should it go in Game::interact? (i've yet to mess with interact and input so I'm not sure)
Finally, thanks for making and maintaining this project. It's been very nice to work with so far.
The text was updated successfully, but these errors were encountered: