X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.h;h=d4f58825a5f3e2a0afdccc4a4f0170b35ab32c57;hb=1aa0de39a5f87bda1e74d0992848ad5142a850bc;hp=3836871dffe369b1de3ff4d0c8e50cbb72ebb199;hpb=2f395aba3974db45f45a8587ed423a3abeab4cd5;p=supertux.git diff --git a/src/collision.h b/src/collision.h index 3836871df..d4f58825a 100644 --- a/src/collision.h +++ b/src/collision.h @@ -1,34 +1,46 @@ -// C Interface: collision -// -// Description: -// -// -// Author: Tobias Glaesser , (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution +// $Id$ +// +// SuperTux +// Copyright (C) 2005 Matthias Braun // +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. // +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. -#ifndef SUPERTUX_COLLISION_H -#define SUPERTUX_COLLISION_H +#ifndef __COLLISION_H__ +#define __COLLISION_H__ -#include "type.h" +class Vector; +class Rect; +class AATriangle; +class CollisionHit; -/* Collision objects */ -enum +class Collision { - CO_BULLET, - CO_BADGUY, - CO_BSOD, - CO_PLAYER -}; - -int rectcollision(itop_type* one, itop_type* two); -int rectcollision_offset(itop_type* one, itop_type* two, float off_x, float off_y); +public: + /** does collision detection between 2 rectangles. Returns true in case of + * collision and fills in the hit structure then. + */ + static bool rectangle_rectangle(CollisionHit& hit, const Rect& r1, + const Vector& movement, const Rect& r2); -/* Checks for all possible collisions. - And calls the collision_handlers, which the collision_objects provide for this case (or not). */ -void collision_handler(); + /** does collision detection between a rectangle and an axis aligned triangle + * Returns true in case of a collision and fills in the hit structure then. + */ + static bool rectangle_aatriangle(CollisionHit& hit, const Rect& rect, + const Vector& movement, const AATriangle& triangle); +}; -#endif /*SUPERTUX_COLLISION_H*/ +#endif