Android 2d game collision detection

Viewed 1575

I developed a 2d game in android studio using SurfaceView, it's not complex in context of collision, just need to check collision between a moving-point and some static circles, for detect collision for one circle, I simply check if X of the point is between circle minX and maxX && point Y is between minY and maxY of circle.

So for checking collision in whole of the game, I repeat to check above code for all circles in each frame.

Game work so good when I have for example 10 circles, but if I add 30 circles, its FPS decrease so much and I face so much lag!

What should I do for this problem? should I use Box 2d physics ? what does it do for collision detection that games doesn't face lag problem even if there is so much objects which collide together?

Please help me with more detail, because I was wonder how a game engine work and decided to make a simple one, not only wanted to make and release a game(otherwise I could use a ready game engine).

Thanks in advance

2 Answers
Related