-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
43 lines (37 loc) · 829 Bytes
/
Copy pathcamera.cpp
File metadata and controls
43 lines (37 loc) · 829 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
#include "camera.h"
int Camera::getItsOffsetX()
{
return itsOffsetX;
}
int Camera::getItsOffsetY() const
{
return itsOffsetY;
}
Camera::Camera(int widthBlockMap,int heightBlockMap)
{
itsWidthBlockMap = widthBlockMap;
itsHeightBlockMap = heightBlockMap;
itsOffsetX = 0;
itsOffsetY = 0;
}
void Camera::follow(PhysicalObject object)
{
itsOffsetX = -(object.getItsX() -500);
itsOffsetY = -(object.getItsY()-200);
if(-itsOffsetX < 0)
{
itsOffsetX =0;
}
else if(1200 >= itsWidthBlockMap*sizeBlock+itsOffsetX )
{
itsOffsetX = -(sizeBlock*itsWidthBlockMap) + 1200;
}
if(-itsOffsetY < 0)
{
itsOffsetY =0;
}
else if(399 >= itsHeightBlockMap*sizeBlock+itsOffsetY )
{
itsOffsetY = -(sizeBlock*itsHeightBlockMap) + 399;
}
}