checkSwitchContact(bullet);
- if ((checkTrainContact(bullet, 0)) || (checkObstacleContact(bullet, 0)))
+ if ((checkTrainContact(bullet, DIR_XY)) || (checkObstacleContact(bullet, DIR_XY)))
{
if (bullet->flags & ENT_BOUNCES)
bounceBullet(bullet, dx, dy);
PAK_TAGS
};
+/* ######### miscellaneous ############## */
+
+#define DIR_X 1
+#define DIR_Y 2
+#define DIR_XY 3
+
/* ############# debug ################## */
#if DEBUG
if (ent->dx != 0)
{
- if ((checkBrickContactX(ent)) || (checkObstacleContact(ent, 0)) || (checkTrainContact(ent, 0)))
+ if ((checkBrickContactX(ent)) || (checkObstacleContact(ent, DIR_X)) || (checkTrainContact(ent, DIR_X)))
{
ent->dx = 0;
}
if (ent->dy != 0)
{
- if ((checkBrickContactY(ent)) || (checkObstacleContact(ent, 1)) || (checkTrainContact(ent, 1)))
+ if ((checkBrickContactY(ent)) || (checkObstacleContact(ent, DIR_Y)) || (checkTrainContact(ent, DIR_Y)))
{
if ((ent->flags & ENT_BOUNCES) && (ent->dy >= 3))
{
continue;
}
- if (dir == 0)
+ if (dir == DIR_X)
{
collision = Collision::collision(ent->x + ent->dx, ent->y, ent->width, ent->height - 1, obstacle->x, obstacle->y, obstacle->width, obstacle->height);
}
- else
+ else if (dir == DIR_Y)
{
collision = Collision::collision(ent->x, ent->y + ent->dy, ent->width, ent->height - 1, obstacle->x, obstacle->y, obstacle->width, obstacle->height);
}
+ else
+ {
+ collision = Collision::collision(ent->x + ent->dx, ent->y + ent->dy, ent->width, ent->height - 1, obstacle->x, obstacle->y, obstacle->width, obstacle->height);
+ }
if (collision)
{
- if (dir == 0)
+ if (dir & DIR_X)
{
if ((ent->y + ent->height == obstacle->y + obstacle->height) || ((ent->flags & ENT_BULLET) && (ent->owner == &player)))
{
}
}
- if (dir == 1)
+ if (dir & DIR_Y)
{
ent->falling = false;
ent->dy = 0;
if ((ent->flags & ENT_BULLET) && (!(ent->flags & ENT_BOUNCES)))
{
- if (dir == 0)
+ if (dir & DIR_X)
{
if (ent->dx < 0) ent->x = train->x + train->sprite->image[0]->w;
if (ent->dx > 0) ent->x = train->x - ent->width;
}
}
- if (dir == 1)
+ if (dir & DIR_Y)
{
if ((ent->dy >= 0) && (train->type >= TR_SLIDEDOOR))
{
{
train = (Train*)train->next;
- if (dir == 0)
+ if (dir == DIR_X)
{
collision = (Collision::collision(ent->x + ent->dx, ent->y, ent->width, ent->height - 1, train->x, train->y, train->width, train->height));
}
- else
+ else if (dir == DIR_Y)
{
collision = (Collision::collision(ent->x, ent->y + ent->dy, ent->width, ent->height - 1, train->x, train->y, train->width, train->height));
}
+ else
+ {
+ collision = (Collision::collision(ent->x + ent->dx, ent->y + ent->dy, ent->width, ent->height - 1, train->x, train->y, train->width, train->height));
+ }
if (collision)
{
openDoor(train);
}
- if (dir == 1)
+ if (dir & DIR_Y)
{
ent->dy = 0;
ent->falling = false;