- beginnings of a wingling
[supertux.git] / src / collision.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
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.
10 //
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.
15 // 
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
19 //  02111-1307, USA.
20
21 #ifndef SUPERTUX_COLLISION_H
22 #define SUPERTUX_COLLISION_H
23
24 #include "type.h"
25
26 class Tile;
27 class World;
28
29 /* Collision objects */
30 enum
31 {
32   CO_BULLET,
33   CO_BADGUY,
34   CO_PLAYER,
35   CO_TRAMPOLINE,
36   CO_FLYING_PLATFORM
37 };
38
39 enum CollisionType {
40     COLLISION_NORMAL,
41     COLLISION_BUMP,
42     COLLISION_SQUISH
43 };
44
45 bool rectcollision(const base_type& one, const base_type& two);
46 bool rectcollision_offset(const base_type& one, const base_type& two, float off_x, float off_y);
47
48 void collision_swept_object_map(base_type* old, base_type* current);
49 bool collision_object_map(const base_type& object);
50
51 /** Return a pointer to the tile at the given x/y coordinates */
52 Tile* gettile(float x, float y);
53
54 // Some little helper function to check for tile properties
55 bool  issolid(float x, float y);
56 bool  isbrick(float x, float y);
57 bool  isice(float x, float y);
58 bool  isspike(float x, float y);
59 bool  isfullbox(float x, float y);
60
61 typedef void* (*tiletestfunction)(Tile* tile);
62 /** invokes the function for each tile the baserectangle collides with. The
63  * function aborts and returns true as soon as the tiletestfunction returns
64  * != 0 then this value is returned. returns 0 if all tests failed.
65  */
66 void* collision_func(const base_type& base, tiletestfunction* function);
67
68 Tile* collision_goal(const base_type& base);
69
70 #endif /*SUPERTUX_COLLISION_H*/
71