codi-hacks / space-race

Love2D-based Spaceship Racing Game
Other
3 stars 0 forks source link

Fixtures not unloading properly #53

Closed SuperShadowPlay closed 2 years ago

SuperShadowPlay commented 2 years ago

Load the test map, then load no planets. If you smash yourself into the wall right below you and go right, you're stopped by the wall that was loaded in on the test map.

Jon suggests it means the fixtures aren't being deleted, so I'll start by explicitly destroying fixtures and then go from there. https://love2d.org/wiki/Body:getFixtures -- for reference later.

jaythomas commented 2 years ago

Without looking too deeply into it myself I recall that we're storing entities in the Entity service and exposing them via Entity.list, however the map itself (active_map) contains an exhaustive list of ALL entities, sorted by the layer they belong in (active_map.layers). Go look at map.draw() to see what I'm talking about. Don't hold my memory to this, but Entity.list is just a convenient way of sorting the entities we care about into a nice, easy single iterable list that doesn't include things we'll never want to pass through the Systems. You might want to consider merging the Entity and Map service in addition to this fix to avoid the confusion of having the same data exist in two different services.