-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjeto.hpp
More file actions
95 lines (67 loc) · 2.83 KB
/
Copy pathObjeto.hpp
File metadata and controls
95 lines (67 loc) · 2.83 KB
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
//
// Created by patri on 10/04/2021.
//
#ifndef ALLEGRO5TUTORIAL_OBJETO_HPP
#define ALLEGRO5TUTORIAL_OBJETO_HPP
class Objeto {
protected:
float x, y; // display coordinates
float xRespectCube, yRespectCube;
ALLEGRO_BITMAP *draw; // sprite
int sourceX = 0, sourceY = 0;
int sourceI = 0, sourceJ = 0; // en que fila y columna del sprite se coloca
int sizePixelsX, sizePixelsY;
protected:
int timer = 0;
public:
virtual void drawBitmap(){
al_draw_bitmap_region(getDraw(), getSourceX() + (sourceJ * sizePixelsX),
getSourceY() + (sourceI * sizePixelsY), sizePixelsX, sizePixelsY,
getX(), getY(), 0);
}
virtual void resize(Piramide *piramide) {
setX(piramide->map[0][0].x+this->xRespectCube);
setY(piramide->map[0][0].y+this->yRespectCube);
}
virtual void destroy() {
al_destroy_bitmap(getDraw());
}
virtual void movement() {timer++;}
void playOnce(ALLEGRO_SAMPLE *sound){
al_play_sample(sound, 1.0, 0, 1, ALLEGRO_PLAYMODE_ONCE, 0);
}
void timerplusplus(){ Objeto::timer++; }
/*************************
* GETTER'S AND SETTER'S *
*************************/
int getSourceX() const { return sourceX; }
void setSourceX(int _sourceX) { Objeto::sourceX = _sourceX; }
int getSourceY() const { return sourceY; }
void setSourceY(int _sourceY) { Objeto::sourceY = _sourceY; }
float getXRespectCube() const { return xRespectCube; }
void setXRespectCube(float _xRespectCube) { Objeto::xRespectCube = _xRespectCube; }
float getYRespectCube() const { return yRespectCube; }
void setYRespectCube(float _yRespectCube) { Objeto::yRespectCube = _yRespectCube; }
float getX() const { return x; }
void setX(float _x) { Objeto::x = _x; }
float getY() const { return y; }
void setY(float _y) { Objeto::y = _y; }
virtual ALLEGRO_BITMAP *getDraw() const { return draw; }
void setDraw(ALLEGRO_BITMAP *_draw) { Objeto::draw = _draw; }
int getTimer() const { return timer; }
void setTimer(int _timer) { Objeto::timer = _timer; }
int getSourceI() const { return sourceI; }
void setSourceI(int _sourceI) { Objeto::sourceI = _sourceI; }
int getSourceJ() const { return sourceJ; }
void setSourceJ(int _sourceJ) { Objeto::sourceJ = _sourceJ; }
int getSizePixelsX() const { return sizePixelsX; }
void setSizePixelsX(int sizePixelsX) { Objeto::sizePixelsX = sizePixelsX; }
int getSizePixelsY() const { return sizePixelsY; }
void setSizePixelsY(int sizePixelsY) { Objeto::sizePixelsY = sizePixelsY; }
void must_init(bool test, const char *description) {
if (test) return;
printf("No se ha podido inicializar: %s\n", description);
exit(1);
}
};
#endif //ALLEGRO5TUTORIAL_OBJETO_HPP