X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.h;h=39d658b9ec08ad4bb34bee37afc38183fa4b0978;hb=ee6972038331a3c26a2a6a0bdb2baca25475b1d2;hp=8f481237c0e6f2afc034d00a1beb6d3186adffda;hpb=43ae91e84ae574464a2ff634daa8a16e253b47fa;p=supertux.git diff --git a/src/collision.h b/src/collision.h index 8f481237c..39d658b9e 100644 --- a/src/collision.h +++ b/src/collision.h @@ -1,34 +1,56 @@ -// C Interface: collision -// -// Description: -// -// -// Author: Tobias Glaesser , (C) 2004 -// -// Copyright: See COPYING file that comes with this distribution +// $Id$ +// +// SuperTux +// Copyright (C) 2004 Tobias Glaesser // +// 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 -#include "type.h" +#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); -/* Collision objects */ -enum -{ - CO_BULLET, - CO_BADGUY, - CO_BSOD, - CO_PLAYER -}; +/** Return a pointer to the tile at the given x/y coordinates */ +const Tile* gettile(float x, float y); -int rectcollision(base_type* one, base_type* two); -int rectcollision_offset(base_type* one, base_type* two, float off_x, float off_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); -/* Checks for all possible collisions. - And calls the collision_handlers, which the collision_objects provide for this case (or not). */ -void collision_handler(); +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*/