1 /*************************************************************************** 2 entity.h - description 3 ------------------- 4 begin : Wed Aug 15 2001 5 copyright : (C) 2001 by Giuseppe D'Aqu� 6 email : kumber@tiscalinet.it 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License, Version 2, as published by * 13 * the Free Software Foundation. * 14 * * 15 ***************************************************************************/ 16 17 #include "dephine.h" 18 #include "direction.h" 19 #include "entity_type.h" 20 #include "level.h" 21 #include "surface_manager.h" 22 #include "sprite.h" 23 24 #ifndef ENTITY_H 25 #define ENTITY_H 26 27 /* 28 * Abstract class Entity is the base for creating game objects 29 */ 30 class Entity 31 { 32 private: 33 34 void m_set_position_x(Uint32 x); 35 36 void m_set_position_y(Uint32 y); 37 38 protected: 39 40 bool m_just_checked; 41 42 Entity_Handle m_id; 43 44 Entity_Type m_type; 45 46 Uint32 m_position_x; 47 48 Uint32 m_position_y; 49 50 Uint32 m_speed; 51 52 Sprite m_sprite; 53 54 55 56 //True if an entity exists - not used 57 bool m_exists; 58 59 Level* current_level; 60 public: 61 62 Entity(); 63 64 Entity_Handle get_id(); 65 66 void set_id(Entity_Handle handle); 67 68 Uint32 get_position_x(); 69 70 Uint32 get_position_y(); 71 get_type()72 Entity_Type get_type() 73 {return m_type;}; 74 get_sprite()75 Sprite& get_sprite() 76 { 77 return m_sprite; 78 79 } 80 81 void set_speed(Uint32 speed); 82 set_checked(bool check)83 void set_checked(bool check){m_just_checked=check;}; 84 85 86 void set_type(Entity_Type type); 87 88 //moving function: calls the correct move_<dir>() function 89 void move(Direction direction); 90 91 bool set_position(Uint32 x, Uint32 y); 92 93 bool set_initial_position(Uint32 x, Uint32 y); 94 // Moving functions - one for every direction 95 96 void move_up(); 97 98 void move_down(); 99 100 void move_right(); 101 102 void move_left(); 103 exists()104 bool exists(){return m_exists;}; 105 106 void kill(); 107 108 // Virtual functions 109 110 // this function need to be overloaded in the derivative classes. 111 //It is called by Game::move_all() for every existing object 112 //and generally it contains some checks and calling to moving_functions 113 virtual void check_and_do()=0; 114 // virtual bool pass_on_me(Direction d=STOP)=0; 115 virtual bool player_pressing_up(Entity_Handle down_entity); 116 virtual bool player_pressing_left(Entity_Handle right_entity); 117 virtual bool player_pressing_right(Entity_Handle left_entity); 118 virtual bool player_pressing_down(Entity_Handle up_entity); 119 virtual bool hit_from_up(Entity_Handle ntt)=0; 120 virtual bool explode()=0; 121 virtual bool roll_on_me()=0; 122 ~Entity()123 virtual ~Entity(){} 124 }; 125 126 127 128 129 #endif //ENTITY_H 130