MCPcopy Create free account
hub / github.com/atraczyk/2d-engine / update

Method update

engine/src/camera.cpp:65–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void Camera::update(WorldRect* pconstraints)
66{
67 if (isTargeting)
68 {
69 velocity = (((pTarget->position + pTarget->size * 0.5f) - size * 0.5f -
70 position) *
71 0.25f);
72
73 if (abs(velocity.x) < 1.0f)
74 velocity.x = 0.0f;
75 if (abs(velocity.y) < 1.0f)
76 velocity.y = 0.0f;
77 }
78 else
79 {
80 if (toMove.x == 0)
81 {
82 if (velocity.x < 0.0f)
83 {
84 velocity.x += DECELERATION;
85 if (velocity.x > 0.0f)
86 velocity.x = 0.0f;
87 }
88 else if (velocity.x > 0.0f)
89 {
90 velocity.x -= DECELERATION;
91 if (velocity.x < 0.0f)
92 velocity.x = 0.0f;
93 }
94 }
95 else
96 {
97 if (velocity.x * toMove.x < 0)
98 velocity.x += DECELERATION * toMove.x;
99 else
100 velocity.x += ACCELERATION * toMove.x;
101 if (velocity.x < -VELOCITY_MAX)
102 velocity.x = -VELOCITY_MAX;
103 else if (velocity.x > VELOCITY_MAX)
104 velocity.x = VELOCITY_MAX;
105 }
106
107 if (toMove.y == 0)
108 {
109 if (velocity.y < 0.0f)
110 {
111 velocity.y += DECELERATION;
112 if (velocity.y > 0.0f)
113 velocity.y = 0.0f;
114 }
115 else if (velocity.y > 0.0f)
116 {
117 velocity.y -= DECELERATION;
118 if (velocity.y < 0.0f)
119 velocity.y = 0.0f;
120 }
121 }
122 else

Callers

nothing calls this directly

Calls 5

IntegerMethod · 0.80
fLeftMethod · 0.80
fRightMethod · 0.80
fTopMethod · 0.80
fBottomMethod · 0.80

Tested by

no test coverage detected