X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcollision.h;h=85b89d7bd71f9f907328c020aff3b5c22b16e86b;hb=6c61f312a1f5a768e202195ca18ed5a51974bdcc;hp=fa165d7134388a09fbc2ad88b95ee65630625065;hpb=945d6ee4488595f3a8f7180b66b53ff684ab94e4;p=supertux.git diff --git a/src/collision.h b/src/collision.h index fa165d713..85b89d7bd 100644 --- a/src/collision.h +++ b/src/collision.h @@ -1,18 +1,29 @@ -// 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 "special/base.h" + +using namespace SuperTux; class Tile; @@ -21,7 +32,9 @@ enum { CO_BULLET, CO_BADGUY, - CO_PLAYER + CO_PLAYER, + CO_TRAMPOLINE, + CO_FLYING_PLATFORM }; enum CollisionType { @@ -30,14 +43,11 @@ enum CollisionType { COLLISION_SQUISH }; -bool rectcollision(base_type* one, base_type* two); -bool rectcollision_offset(base_type* one, base_type* two, float off_x, float off_y); -void collision_swept_object_map(base_type* old, base_type* current); -bool collision_object_map(base_type* object); +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); -/* Checks for all possible collisions. - And calls the collision_handlers, which the collision_objects provide for this case (or not). */ -void collision_handler(); +void collision_swept_object_map(base_type* old, base_type* current); +bool collision_object_map(const base_type& object); /** Return a pointer to the tile at the given x/y coordinates */ Tile* gettile(float x, float y); @@ -46,7 +56,17 @@ Tile* gettile(float x, float y); 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)(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); + +Tile* collision_goal(const base_type& base); + #endif /*SUPERTUX_COLLISION_H*/