samedi 9 janvier 2021

How Mediator pattern should work in my stuation? [closed]

I have circles colliding on a canvas. I am currently creating circles in my main class and saving them in mediator class. My circle list is kept in mediator. I create circles and push mediator. Mediator calculates collisions and resolves collisions. And my mediator has update function. I call mediator. Update function and the new positions of all the circles in the list are calculated and drawn on the canvas.

Is this the right way to use mediator?

Or should I keep a mediator object in circle, keep my circle list in both my main class and mediator, and call each circle's update method in the main class? I'm a little confused about this?

Please do not give examples of flight and chat :)

Aucun commentaire:

Enregistrer un commentaire