-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentity.h
executable file
·83 lines (65 loc) · 1.67 KB
/
entity.h
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
#ifndef ENTITY_H
#define ENTITY_H
#include <iostream>
#include <vector>
#include "Const.h"
#include "coord.h"
class C_Board;
class C_Entity
{
public:
C_Entity(C_Board* board_, int posX_=0, int posY_=0);
virtual bool move(int, int);
virtual bool push(int x_, int y_) { return move(x_, y_); }
int getPosX() const { return pos.x; }
int getPosY() const { return pos.y; }
C_Coord getPos() const { return this->pos; }
C_Coord getPrevPos() const { return this->prevPos; }
virtual int getId() = 0;
virtual char* getImage() = 0;
virtual char getChar() = 0;
protected:
C_Coord pos;
C_Coord prevPos;
C_Board* board;
};
class C_Player : public C_Entity
{
public:
C_Player(C_Board* board_, int posX_=0, int posY_=0);
bool move(int, int);
bool canGoOver(int id);
void sleep() { sleeping = true; }
void wakeUp() { sleeping = false; }
bool isSleeping() { return sleeping; }
int getId() { return EID_PLAYER; }
char* getImage() { return "tiles/player.png"; };
char getChar() { return '@'; }
private:
bool sleeping;
};
class C_Block : public C_Entity
{
public:
C_Block(C_Board*, int, int);
int getId() { return EID_BLOCK; }
char* getImage() { return "tiles/block.png"; };
char getChar() { return 'x'; }
};
class C_Goal : public C_Entity
{
public:
C_Goal(C_Board*, int, int);
int getId() { return EID_GOAL; }
char* getImage() { return "tiles/goal.png"; };
char getChar() { return 'G'; }
};
class C_Ball : public C_Entity
{
public:
C_Ball(C_Board*, int, int);
int getId() { return EID_BALL; }
char* getImage() { return "tiles/ball.png"; };
char getChar() { return '0'; }
};
#endif