meth-meth-method / super-mario

Create a Super Mario game in vanilla JS from scratch.
http://bit.ly/2i7u5ks
653 stars 154 forks source link

all entity collisions are doubled #32

Closed mkrasuski closed 4 years ago

mkrasuski commented 5 years ago

on entity collider we have both subject.collides(candidate) and candidate.collides(subject) and entity nested loops cause every subject != candidate pair go to this. As result, on collision, for example mario.collides(goomba) is called with subject === mario and candidate == goomba and then with subject === goomba and candidate === mario.

With such a loop nesting calling only subject.collides(candidate) is enough.

pomle commented 4 years ago

Fixed in https://github.com/meth-meth-method/super-mario/commit/ab778dbcda3addf5a1f59956478f3453fe2751b8#diff-1ab87ddb118485cb1607a5f4d6f01820