-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObject.cpp
More file actions
47 lines (45 loc) · 879 Bytes
/
Object.cpp
File metadata and controls
47 lines (45 loc) · 879 Bytes
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
#include "Texture.hpp"
#include "Object.hpp"
void Object::initObject(const char *filename, int x, int y)
{
objTexture = texture::loadTexture(filename);
xpos = x;
ypos = y;
dstRect.x = x;
dstRect.y = y;
dstRect.w = 32;
dstRect.h = 32;
}
void Object::setSource(int x, int y, int w, int h)
{
srcRect.h = h;
srcRect.w = w;
srcRect.x = x;
srcRect.y = y;
}
void Object::setSource(int x, int y)
{
srcRect.x = x;
srcRect.y = y;
}
void Object::setDest(int x, int y, int w, int h)
{
dstRect.x = x;
dstRect.y = y;
dstRect.w = w;
dstRect.h = h;
}
void Object::setDest(int x, int y)
{
dstRect.x = x;
dstRect.y = y;
}
void Object::Render()
{
tmpRect = dstRect;
tmpRect.y -= 24;
tmpRect.x -= 8;
tmpRect.w = 48;
tmpRect.h = 48;
SDL_RenderCopy(Game::renderer, objTexture, &srcRect, &tmpRect);
}