Entity Type Collisions in (sdltutorials.com SDL Framework)

Anything related to SDL

Entity Type Collisions in (sdltutorials.com SDL Framework)

Postby Aaru » Sun Jul 01, 2012 8:00 pm

What is the best way to make specific entities ignore certain entities in terms of collision.
For instance, If I have entity A (type Player). I want him to ignore entity B ( type ally), but if ally were to collide with any other type of entity it will send a collision.

Has anyone come to this point ? I have figured out how to make entities ignore their own type but that is as far as I have come.
User avatar
Aaru
 
Posts: 72
Joined: Fri Sep 10, 2010 3:56 am
Location: California

Re: Entity Type Collisions in (sdltutorials.com SDL Framework)

Postby rday » Mon Jul 09, 2012 3:11 am

Just spit balling here but could you not change the

Code: Select all
bool Entity::posValidEntity(Entity* entity, int newX, int newY)
{
**Check for collision code**
}


To something along the lines of

Code: Select all
bool Entity::posValidEntity(Entity* entity, int newX, int newY)
{
    if(type is ENTITY_TYPE_PLAYER && entity->type is ENTITY_TYPE_ALLY)
    {
        return false;
    }
   else **Check for collision here**
}
rday
 
Posts: 4
Joined: Mon Dec 19, 2011 1:27 pm


Return to SDL

Who is online

Users browsing this forum: No registered users and 0 guests

cron