2D Collision Detection

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Gambler
Posts: 10
Joined: Sun Nov 06, 2005 9:53 pm
Location: Germany

2D Collision Detection

Post by Gambler »

Hi everybody
I have a question that's not completly related to Irrlicht, like the header says ;)
We have a slight problem with our collision detection for our 2D game (dropdown view).
At the moment we store our levels in an array-like field, and check if there's a number 1 in it, then the player can't pass it.
This works fine with just walls, but now we're stuck at collision with other NPC objects (static, not to speak of moving at the moment).
My thought is to define a rectangle box around the player and around an NPC for example, but how do I implement a collision detection between those?
Conquistador
Posts: 340
Joined: Wed Sep 28, 2005 4:38 pm
Location: Canada, Eh!

re:

Post by Conquistador »

The rect container has methods allowing for collision, check out isPointInide(), and isRectCollided() here: http://irrlicht.sourceforge.net/docu/cl ... 1rect.html
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi

wait till next release of Magic 2D library for Irrlicht,i have made it .

this is the proto type of it

Code: Select all

bool  CheckCollide(SMaterial Image1,f32 x1,f32 y1, SMaterial Image2,f32 x2,f32 y2,f32 ratio1=1.0,f32 ratio2=1.0);
bool  CheckCollide(TAnimImage Image1,f32 x1,f32 y1, TAnimImage Image2,f32 x2,f32 y2,f32 ratio1=1.0,f32 ratio2=1.0);
x1 ,y1 are the coords of first Image
x2, y2 are the coords of second Image
ratio1 , ratio2 allows you to chech collision for part of image ,some Image has a vrey big transparent part so if you test for entire image size your work will not be like a real things ,so i suggest using( 0.7 to 0.9) ratio

first function will test SMaterial Vs SMaterial type
second one will test animated Image Vs animated Image

i will add a function for SMaterial Vs animated Image and one for Gif animation

for more info about Magic Library see this
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=9666
Gambler
Posts: 10
Joined: Sun Nov 06, 2005 9:53 pm
Location: Germany

Post by Gambler »

Thanks for your answers, we have now box based collisions and so far it works well :)
Post Reply