X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.h;h=d4f58825a5f3e2a0afdccc4a4f0170b35ab32c57;hb=5ca889b8fa8d14bcf1f215aeef105d798d15adbd;hp=39d658b9ec08ad4bb34bee37afc38183fa4b0978;hpb=d46c78c842ab4090a3f46e560c891234167f124b;p=supertux.git diff --git a/src/collision.h b/src/collision.h index 39d658b9e..d4f58825a 100644 --- a/src/collision.h +++ b/src/collision.h @@ -1,7 +1,7 @@ // $Id$ // // SuperTux -// Copyright (C) 2004 Tobias Glaesser +// 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 @@ -18,39 +18,29 @@ // 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__ + +class Vector; +class Rect; +class AATriangle; +class CollisionHit; + +class Collision +{ +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); + + /** 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); +}; -#include "math/rectangle.h" - -using namespace SuperTux; - -#if 0 -bool rectcollision(const base_type& one, const base_type& two); -bool rectcollision_offset(const base_type& one, const base_type& two, float off_x, float off_y); - -void collision_swept_object_map(base_type* old, base_type* current); -bool collision_object_map(const base_type& object); -bool collision_object_map(const Rectangle& rect); - -/** Return a pointer to the tile at the given x/y coordinates */ -const Tile* gettile(float x, float y); - -// Some little helper function to check for tile properties -bool issolid(float x, float y); -bool isbrick(float x, float y); -bool isice(float x, float y); -bool isspike(float x, float y); -bool isfullbox(float x, float y); - -typedef void* (*tiletestfunction)(const Tile* tile); -/** invokes the function for each tile the baserectangle collides with. The - * function aborts and returns true as soon as the tiletestfunction returns - * != 0 then this value is returned. returns 0 if all tests failed. - */ -void* collision_func(const base_type& base, tiletestfunction* function); -const Tile* collision_goal(const Rectangle& rect); #endif -#endif /*SUPERTUX_COLLISION_H*/ -