-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.cpp
More file actions
51 lines (46 loc) · 1.23 KB
/
GameObject.cpp
File metadata and controls
51 lines (46 loc) · 1.23 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
#include "GameObject.h"
GameObject::GameObject(const char* texturesheet, int x, int y) {
objTexture = TextureManager::loadTexture(texturesheet);
xPos = x;
yPos = y;
srcRect.h = 640;
srcRect.w = 800;
srcRect.x = 0;
srcRect.y = 0;
destRect.x = xPos;
destRect.y = yPos;
destRect.w = srcRect.w;
destRect.h = srcRect.h;
offSet = true;
}
GameObject::GameObject(const char* texturesheet, int x, int y, bool off) {
objTexture = TextureManager::loadTexture(texturesheet);
xPos = x;
yPos = y;
srcRect.h = 640;
srcRect.w = 800;
srcRect.x = 0;
srcRect.y = 0;
destRect.x = xPos;
destRect.y = yPos;
destRect.w = srcRect.w;
destRect.h = srcRect.h;
offSet = off;
}
GameObject::~GameObject() {
}
void GameObject::Render(int offSetx, int offSety) {
if ((((destRect.x + offSetx + destRect.w > 0) && (destRect.y + offSety + destRect.h > 0) && (destRect.y + offSety < 864) && (destRect.x + offSetx < 1536)) || offSet == false)) {
if (offSet == true) {
destRect.x += offSetx;
destRect.y += offSety;
}
SDL_RenderCopy(rendererStorage::renderer, objTexture, &srcRect, &destRect);
if (offSet == true) {
destRect.x -= offSetx;
destRect.y -= offSety;
}
}
}
void GameObject::update() {
}