-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrectangle.cpp
More file actions
39 lines (32 loc) · 832 Bytes
/
Copy pathrectangle.cpp
File metadata and controls
39 lines (32 loc) · 832 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
#include "rectangle.h"
#include "textureManager.h"
Rectangle::Rectangle(const char* filename, SDL_Renderer* ren, int bRow, int bColumn)
{
xPosition = yPosition = 0;
renderer = ren;
objectTexture = TextureManager::LoadTexture(filename, ren);
boardRow = bRow;
boardColumn = bColumn;
}
Rectangle::~Rectangle() {}
void Rectangle::calculateXY()
{
xPosition = (boardColumn - 1) * (PIECES_X_DISTANCE - 1) + 43;
yPosition = 600 - 33 - boardRow * PIECES_Y_DISTANCE;
}
void Rectangle::update()
{
calculateXY();
sourceRect.h = 69;
sourceRect.w = 91;
sourceRect.x = 0;
sourceRect.y = 0;
destinationRect.x = xPosition;
destinationRect.y = yPosition;
destinationRect.w = sourceRect.w;
destinationRect.h = sourceRect.h;
}
void Rectangle::render()
{
SDL_RenderCopy(renderer, objectTexture, &sourceRect, &destinationRect);
}