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?
2D Collision Detection
-
- Posts: 340
- Joined: Wed Sep 28, 2005 4:38 pm
- Location: Canada, Eh!
re:
The rect container has methods allowing for collision, check out isPointInide(), and isRectCollided() here: http://irrlicht.sourceforge.net/docu/cl ... 1rect.html
-
- Posts: 518
- Joined: Tue Mar 29, 2005 9:02 pm
- Location: Alex,Egypt
- Contact:
Hi
wait till next release of Magic 2D library for Irrlicht,i have made it .
this is the proto type of it
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
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);
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
Magic 2d Library For Irrlicht : http://www.freewebs.com/bcxgl/index.htm
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/
http://www.freewebs.com/bcxdx/index.htm
http://groups.yahoo.com/group/bcxdxc/