File: entity.h

package info (click to toggle)
epiphany 0.5.1-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,540 kB
  • ctags: 593
  • sloc: cpp: 4,223; makefile: 80; sh: 11
file content (122 lines) | stat: -rw-r--r-- 2,801 bytes parent folder | download | duplicates (2)
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
/***************************************************************************
                          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 as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

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

#ifndef ENTITY_H
#define ENTITY_H

//Abstract class Entity is the base for creating whatever game object

class Entity
{
private:

	void m_set_position_x(unsigned int x);
	
	void m_set_position_y(unsigned int y);
	
protected:

	bool m_just_checked;

	int m_id;
	
	Entity_Type m_type;
	
	unsigned int m_position_x;
	
	unsigned int m_position_y;
	
	unsigned int m_speed;
	
	Sprite m_sprite;
	
	//true if player can pass it
//	bool m_is_passable;
		
	//True if an entity exists - not used
	bool m_exists;
	
	Level* current_level;
public:

	Entity();	

	int get_id();

	unsigned int get_position_x();
	
	unsigned int get_position_y();
	
	Entity_Type get_type()
  {return m_type;};

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

	//moving function: calls the correct move_<dir>() function
	void move(Direction direction);	
	
	bool set_position(unsigned int x, unsigned int 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 smash(Ntt_pointer&)=0;
		virtual bool explode()=0;
		virtual bool roll_on_me()=0;
};
	



#endif //ENTITY_H