-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjects.h
63 lines (44 loc) · 1.26 KB
/
Objects.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
#include <string>
#include <vector>
#define OBJECT_PLAYER 0
#define OBJECT_BOX 1
#define OBJECT_FLOOR 2
#define GLOBAL_PHYSICS_GRAVITY 0.2
#define GLOBAL_PHYSICS_DRAG 0.2
#define GLOBAL_PHYSICS_MAX_VELOCITY 20
int getPolarity(int velocityQuestion);
bool isCollidingY(SDL_Rect *OBJA, SDL_Rect *OBJB);
bool isCollidingX(SDL_Rect *OBJA, SDL_Rect *OBJB);
double getPhysicsGravity(double velY);
double getPhysicsDrag(double velN);
class cObject {
public:
cObject();
~cObject();
int refIndex;
bool bCanMove;
bool bGrounded;
SDL_Rect boundRect;
double velX;
double velY;
Uint8 cRed;
Uint8 cGreen;
Uint8 cBlue;
Uint8 cAlpha;
void setColor(Uint8 pRed, Uint8 pGreen, Uint8 pBlue, Uint8 pAlpha);
void setBoundRect(int iX, int iY, int iW, int iH);
void renderObject(SDL_Renderer *pRenderer);
void changeVelocityX(double nVelX);
void changeVelocityY(double nVelY);
void checkBoundRect();
private:
};
class cObjectPool {
public:
std::vector <cObject> Objects;
void addObject(cObject *pObject);
void updateAllObjects();
void renderAllObjects(SDL_Renderer *pRenderer);
cObject *getObjectRefIndex(int iRefIndex);
};
void getSuperBoundRect(SDL_Rect *pRect, cObject *pObject);