cloud-sweeper
cloud-sweeper copied to clipboard
refactor: make it so more than one bird can appear at once
currently, the bird is a singleton of sorts because of how the ticks work (meaning multiple birds couldn't be flapping at different intervals). fix this so we can have as many birds as we want.
I'd love to help with this issue. Do you have any guidance on how to start?
This is definitely one of the more challenging of the currently open issues. There are several others, like the localstorage for best scores one, that would be a lot easier to get started with.
That said, here's what I currently know about the issue and is where I'd start, in working on it:
- The clouds system is obvs built to have multiple clouds out at once, so each cloud's individual state (like where it is, size, etc) is stored with the cloud object returned from
getCloud(..). - But with the bird, the state (aka, the tick count that represents the flapping of wings) is stored in the module instead of with a bird object.
- The whole notion of
Bird.tick(..)need to be refactored, probably so that function takes a bird object and updates state on it instead of keeping state internal in theBirdmodule. - The game cloud exploding stuff is kinda a model for how I'd approach that.
- Also, when we make this change, we'll need the bird objects to have the same pool re-use logic that clouds have, so we aren't creating a new object and then throwing it away every time (lots of GC).
Again, this change is pretty challenging -- but doable I think with the above in mind. Just giving heads up if you're trying to just dip your toe in and not get too deep to start.
I think I'll take your advice and start with an easier issue to start to get a feel of it. Then I would definitely like to tackle this!
@getify I went ahead and attempted an implementation for a new Birds module. I would till need to implement it in the Game module. Let me know what you think so far, commit 4d51882...