Ze engine... She's alive!
Well everything thus far is just dandy, but there's something I'll need to consider later on - collision detection.
Can someone explain to me algorithmically how this is best done at it's simplest - I.E. in a 2D engine?
Ze engine... She's alive!
Well everything thus far is just dandy, but there's something I'll need to consider later on - collision detection.
Can someone explain to me algorithmically how this is best done at it's simplest - I.E. in a 2D engine?
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
You using vectors or sprites?
For sprites the simplest method is bounding box collision detection. You have a box for the width and height of an object and then you go through every object checking to see if it overlaps with the one you're testing
If you get an overlap go through every pixel of box sprite and if a pixel of box sprite is in the same position as a pixel of test sprite you have a collision.Code:bool overlap(Rectangle box, Rectangle test) { if (box.x + box.w > test.x && box.x < test.x + test.w && box.y + box.h > test.y && box.y < test.y + test.h) return true; else return false; }
Sprites.
Cheers that helped a lot
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry