tags:

views:

63

answers:

2

hi, I am writing a program for an Android phone (Which uses Java as the programming language)

I am writing a game that needs objects to - move around - other objects. For example: if an object was to move from point A to point B and there was another game object in the way, it would move around it.

I also need to detect collisions with object, for example if an object hits another object.

Any good resources for this stuff?

A: 

It's been a long time since I studied this, but pathfinding with potential fields might be useful.

Seth
+1  A: 

as for collision detection, theres some points you might consider according to your specific needs:

  • simplest is a bounding box collision. Every object has an invisible bounding box which you use to check if it intersects with the box of an enemy.
  • If needed you can use collections of bounding boxes to define the collision region of an object.
  • Apart from bounding boxes you could also use circle or elipse shapes
  • If you have loads and loads of objects you need some kind of partitioning scheme. If you are going to test is object A collides with all other objects it might just take too long. Simplest to do is to split your scene in a grid and in each cell only check the collisions of other objects ion this cell (and perhaps neighboring cells). More advanced ways of partitioning you might look into are quad-trees.
  • Don't use pixel perfect collision methods. Although it sounds cool, they are hardly ever useful. This is due to the fact that most probably your object will animate, and you don't want every animation frame to have different collision characteristics.
Toad
I am looking the fastest methods with is probably Bounding box or the Grid method. On occasions there may be 50+ objects that need to detect collisions which is going to batter the phones CPU.
jax