There are 3 classes: TWolf, TRabbit, TBall
TBall - created in the class method TRabbit. TBall objects are moved to TWolf objects. It is necessary to make sure that when these objects collide, both are deleted.
I want it to be processed in the TWolf class, but I have no idea how to implement it. Tell me please
- What is the difficulty? You need to pass an array of TBall objects to each TWolf and check if any of the TBalls is in the hitbox (affected area) TWolf. - Alex Krass
- @AlexKrass TBall objects are created every half a second, and TWolf objects are more than 10. It seems to me that the system will "bend" a bit - andrew
- It should not, even if you have 10,000 balls per 100 wolves, it’s only 1,000,000 iterations, which for C ++ should be fast enough to consider a simple collision check (intersection of circles or intersection of rectangles). At least 60 FPS will do this perfectly well and will not even choke; it will take more time to draw this very graphic. - Alex Krass
- @AlexKrass And if objects of TBall are created in a method of object TRabbit? - andrew
- No matter where they are created. Here the question is that you have to take some objects and second objects, comparing their properties. So you need to think about how to get them, because you should have access to them. I would actually start some object manager and store global collections in it. Although I do not know how it will be right. - Alex Krass
|