File: entity.h

package info (click to toggle)
epiphany 0.7.0+0-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 7,532 kB
  • sloc: cpp: 6,404; ansic: 141; makefile: 78; sh: 7
file content (129 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/***************************************************************************
                          entity.h  -  description
                             -------------------
    begin                : Wed Aug 15 2001
    copyright            : (C) 2001 by Giuseppe D'Aqu�
    email                : kumber@tiscalinet.it
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License, Version 2, as published by  *
 *   the Free Software Foundation.                                   *
 *                                                                         *
 ***************************************************************************/

#include "dephine.h"
#include "direction.h"
#include "entity_type.h"
#include "level.h"
#include "surface_manager.h"
#include "sprite.h"

#ifndef ENTITY_H
#define ENTITY_H

/*
 * Abstract class Entity is the base for creating game objects
*/
class Entity
{
private:

	void m_set_position_x(Uint32 x);
	
	void m_set_position_y(Uint32 y);
	
protected:

	bool m_just_checked;

	Entity_Handle m_id;
	
	Entity_Type m_type;
	
	Uint32 m_position_x;
	
	Uint32 m_position_y;
	
	Uint32 m_speed;
	
	Sprite m_sprite;
	
	
		
	//True if an entity exists - not used
	bool m_exists;
	
	Level* current_level;
public:

	Entity();	

	Entity_Handle get_id();
	
	void set_id(Entity_Handle handle);

	Uint32 get_position_x();
	
	Uint32 get_position_y();
	
	Entity_Type get_type()
  {return m_type;};

	Sprite& get_sprite()
  {
	  return m_sprite;
	
  }
	
	void set_speed(Uint32 speed);
	
	void set_checked(bool check){m_just_checked=check;};
	
		
	void set_type(Entity_Type type);

	//moving function: calls the correct move_<dir>() function
	void move(Direction direction);	
	
	bool set_position(Uint32 x, Uint32 y);

	bool set_initial_position(Uint32 x, Uint32 y);
	// Moving functions - one for every direction
	
	void move_up();
	
	void move_down();
	
	void move_right();
	
	void move_left();
	
	bool exists(){return m_exists;};
	
	void kill();
		
	// Virtual functions
	
	// this function need to be overloaded in the derivative classes.
	//It is called by Game::move_all() for every existing object
	//and generally it contains some checks and calling to moving_functions
		virtual void check_and_do()=0;
	//	virtual bool pass_on_me(Direction d=STOP)=0;
		virtual bool player_pressing_up(Entity_Handle down_entity);
		virtual bool player_pressing_left(Entity_Handle right_entity);
		virtual bool player_pressing_right(Entity_Handle left_entity);
		virtual bool player_pressing_down(Entity_Handle up_entity);
		virtual bool hit_from_up(Entity_Handle ntt)=0;
		virtual bool explode()=0;
		virtual bool roll_on_me()=0;
		
		virtual ~Entity(){}
};
	



#endif //ENTITY_H