4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #ifndef SUPERTUX_COLLISION_H
22 #define SUPERTUX_COLLISION_H
24 #include "math/rectangle.h"
26 using namespace SuperTux;
29 bool rectcollision(const base_type& one, const base_type& two);
30 bool rectcollision_offset(const base_type& one, const base_type& two, float off_x, float off_y);
32 void collision_swept_object_map(base_type* old, base_type* current);
33 bool collision_object_map(const base_type& object);
34 bool collision_object_map(const Rectangle& rect);
36 /** Return a pointer to the tile at the given x/y coordinates */
37 const Tile* gettile(float x, float y);
39 // Some little helper function to check for tile properties
40 bool issolid(float x, float y);
41 bool isbrick(float x, float y);
42 bool isice(float x, float y);
43 bool isspike(float x, float y);
44 bool isfullbox(float x, float y);
46 typedef void* (*tiletestfunction)(const Tile* tile);
47 /** invokes the function for each tile the baserectangle collides with. The
48 * function aborts and returns true as soon as the tiletestfunction returns
49 * != 0 then this value is returned. returns 0 if all tests failed.
51 void* collision_func(const base_type& base, tiletestfunction* function);
52 const Tile* collision_goal(const Rectangle& rect);
55 #endif /*SUPERTUX_COLLISION_H*/