I'm developing a simple game engine for practise purpose, and I used codes like this to do collision detection (fake code):
bool PhysicalObject.isCollideWith(rect: PhysicalObject) => x + width >= rect.x && rect.y <= y + height && x <= rect.x + rect.width && y <= rect.y + rect.height
But this treats all objects as a rectangle.
What I want is to detect collision when two objects are overlapping on pixel level (I used
java.awt.Graphics to draw my game objects).
What's the best way of doing that? Can I create a two-dimension array that represent each pixel and store the pointer to the game object that the corresponding pixel belongs to?