class CollisionGrid;
enum CollisionGroup {
+ /** Objects in DISABLED group are not tested for collisions */
COLGROUP_DISABLED,
+ /**
+ * "default" is moving object. MovingObjects get tested against all other
+ * objects and against other movingobjects
+ */
COLGROUP_MOVING,
- // moving object but don't collide against other moving objects
+ /**
+ * a Moving object, that is not tested against other MovingObjects (or other
+ * MovingOnlyStatic objects), but is tested against all other objects.
+ */
COLGROUP_MOVING_ONLY_STATIC,
+ /**
+ * Doesn't move and isn't explicitely checked for collisions with other
+ * objects (but other objects might check with this)
+ * The difference to COLGROUP_TOUCHABLE is that we can do multiple
+ * collision response tests in a row which is needed for static object
+ * that tux walks on. The results for collisions with STATIC objects
+ * are also sorted by time (so that the first hit gets handled first).
+ *
+ * Use this for static obstacles
+ */
COLGROUP_STATIC,
- COLGROUP_MOVINGSTATIC,
+ /**
+ * Isn't explicitely checked for collisions with other objects. But other
+ * objects might check with this object.
+ * Difference to COLGROUP_STATIC is that collisions with this object are
+ * only tested once and collision response is typically not handled
+ *
+ * Use this for touchable things like spikes/areas or collectibles like
+ * coins
+ */
COLGROUP_TOUCHABLE,
- COLGROUP_TILEMAP /* not really used at the moment */
+ /**
+ * Should be used for tilemaps
+ */
+ COLGROUP_TILEMAP
};
/**
BadGuy* badguy = dynamic_cast<BadGuy*> (&other);
if(badguy != NULL) {
- if(safe_timer.started())
+ if(safe_timer.started() || invincible_timer.started())
return FORCE_MOVE;
return CONTINUE;
if(dying || deactivated)
return;
- if(!completely &&
- (safe_timer.get_timeleft() > 0 || invincible_timer.get_timeleft() > 0))
+ if(!completely && safe_timer.started() || invincible_timer.started())
return;
sound_manager->play("sounds/hurt.wav");
void try_expose(GameObject* object);
void try_unexpose(GameObject* object);
- bool collision_static(MovingObject* object, const Vector& movement);
-
/** Checks for all possible collisions. And calls the
collision_handlers, which the collision_objects provide for this
case (or not). */
void handle_collisions();
-
+
+ /**
+ * Collision checks 2 objects against each other and does instant
+ * collision response handling in case of a collision
+ */
void collision_object(MovingObject* object1, MovingObject* object2) const;
+
+ /**
+ * Does collision detection of an object against all other static
+ * objects (and the tilemap) in the level. Collisions are sorted
+ * and collision response against the first hit is done.
+ *
+ * returns true if the collision detection should be aborted for this object
+ * (because of ABORT_MOVE in the collision response)
+ */
+ bool collision_static(MovingObject* object, const Vector& movement);
+
+
GameObject* parse_object(const std::string& name, const lisp::Lisp& lisp);
void fix_old_tiles();