Dragonfly  4.3
A text-based game engine
EventCollision.h
1 ///
2 /// A "collision" event
3 ///
4 
5 #ifndef __EVENT_COLLISION_H__
6 #define __EVENT_COLLISION_H__
7 
8 #include "Event.h"
9 #include "Object.h"
10 
11 namespace df {
12 
13 const std::string COLLISION_EVENT = "df::collision";
14 
15 class EventCollision : public Event {
16 
17  private:
18  Vector m_pos; ///< Where collision occurred.
19  Object *m_p_obj1; ///< Object moving, causing collision.
20  Object *m_p_obj2; ///< Object being collided with.
21 
22  public:
23  /// Create collision event at (0,0) with o1 and o2 NULL.
25 
26  /// Create collision event between o1 and o2 at position p.
27  /// Object o1 "caused" collision by moving into object o2.
28  EventCollision(Object *p_o1, Object *p_o2, Vector p);
29 
30  /// Set object that caused collision.
31  void setObject1(Object *p_new_o1);
32 
33  /// Return object that caused collision.
34  Object *getObject1() const;
35 
36  /// Set object that was collided with.
37  void setObject2(Object *p_new_o2);
38 
39  /// Return object that was collided with.
40  Object *getObject2() const;
41 
42  /// Set position of collision.
43  void setPosition(Vector new_pos);
44 
45  /// Return position of collision.
46  Vector getPosition() const;
47 };
48 
49 } // end of namespace df
50 #endif // __EVENT_COLLISION_H__
Object * getObject1() const
Return object that caused collision.
Object * getObject2() const
Return object that was collided with.
Object * m_p_obj1
Object moving, causing collision.
Definition: EventCollision.h:19
Definition: Event.h:15
A 2-d bounding box.
Definition: Box.h:10
Vector getPosition() const
Return position of collision.
void setPosition(Vector new_pos)
Set position of collision.
Vector m_pos
Where collision occurred.
Definition: EventCollision.h:18
Definition: Object.h:59
Definition: EventCollision.h:15
void setObject1(Object *p_new_o1)
Set object that caused collision.
Object * m_p_obj2
Object being collided with.
Definition: EventCollision.h:20
void setObject2(Object *p_new_o2)
Set object that was collided with.
EventCollision()
Create collision event at (0,0) with o1 and o2 NULL.
Definition: Vector.h:10