-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCCamera.cpp
70 lines (56 loc) · 1.53 KB
/
CCamera.cpp
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
64
65
66
67
68
69
70
//==============================================================================
#include "CCamera.h"
//==============================================================================
CCamera CCamera::CameraControl;
//==============================================================================
CCamera::CCamera()
{
X = Y = 0;
TargetX = TargetY = NULL;
TargetMode = TARGET_MODE_NORMAL;
}
//==============================================================================
void CCamera::OnMove(int MoveX, int MoveY)
{
X += MoveX;
Y += MoveY;
}
//==============================================================================
const int CCamera::GetX()
{
if(TargetX != NULL)
{
if(TargetMode == TARGET_MODE_CENTER)
{
return *TargetX - (WWIDTH / 2);
}
return *TargetX;
}
return X;
}
//------------------------------------------------------------------------------
const int CCamera::GetY()
{
if(TargetY != NULL)
{
if(TargetMode == TARGET_MODE_CENTER)
{
return *TargetY - (WHEIGHT / 2);
}
return *TargetY;
}
return Y;
}
//==============================================================================
void CCamera::SetPos(int X, int Y)
{
this->X = X;
this->Y = Y;
}
//------------------------------------------------------------------------------
void CCamera::SetTarget(float* X, float* Y)
{
TargetX = X;
TargetY = Y;
}
//==============================================================================