4 // Copyright (C) 2006 Matthias Braun <matze@braunis.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 02111-1307, USA.
19 #ifndef SUPERTUX_MOVING_OBJECT_H
20 #define SUPERTUX_MOVING_OBJECT_H
24 #include "game_object.hpp"
25 #include "collision_hit.hpp"
26 #include "math/vector.hpp"
27 #include "math/rect.hpp"
35 // moving object but don't collide against other moving objects
36 COLGROUP_MOVING_ONLY_STATIC,
38 COLGROUP_MOVINGSTATIC,
41 COLGROUP_TILEMAP /* not really used at the moment */
45 * Base class for all dynamic/moving game objects. This class contains things
46 * for handling the bounding boxes and collision feedback.
48 class MovingObject : public GameObject
52 virtual ~MovingObject();
54 /** this function is called when the object collided with any other object
56 virtual HitResponse collision(GameObject& other,
57 const CollisionHit& hit) = 0;
58 /** called when tiles with special attributes have been touched */
59 virtual void collision_tile(uint32_t tile_attributes)
61 (void) tile_attributes;
64 const Vector& get_pos() const
69 /** returns the bounding box of the Object */
70 const Rect& get_bbox() const
75 const Vector& get_movement() const
80 /** places the moving object at a specific position. Be carefull when
81 * using this function. There are no collision detection checks performed
82 * here so bad things could happen.
84 virtual void set_pos(const Vector& pos)
89 CollisionGroup get_group() const
94 void set_group(CollisionGroup group)
101 friend class CollisionGrid;
102 friend class Platform;
104 /** The bounding box of the object (as used for collision detection, this
105 * isn't necessarily the bounding box for graphics)
108 /** The movement that will happen till next frame
111 /** The collision group */
112 CollisionGroup group;
115 // this is only here for internal collision detection use