summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2019-08-16 16:15:47 +0200
committerRay <[email protected]>2019-08-16 16:15:47 +0200
commitce8d7042c625d45e28755d80f9b39beb1d2a6c5a (patch)
treec43b6b10d118a9de136492f7fa8b445af278e327
parentd8b8c0f3fc8ab3872c65bcfefd258bd6ad4ece51 (diff)
downloadraylib-ce8d7042c625d45e28755d80f9b39beb1d2a6c5a.tar.gz
raylib-ce8d7042c625d45e28755d80f9b39beb1d2a6c5a.zip
PR formatting review
-rw-r--r--examples/core/core_2d_camera.c14
-rw-r--r--src/core.c20
2 files changed, 15 insertions, 19 deletions
diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c
index ba432f46..d6c85079 100644
--- a/examples/core/core_2d_camera.c
+++ b/examples/core/core_2d_camera.c
@@ -42,7 +42,7 @@ int main(void)
Camera2D camera = { 0 };
camera.target = (Vector2){ player.x + 20, player.y + 20 };
- camera.offset = (Vector2){ screenWidth / 2, screenHeight / 2 };
+ camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
@@ -54,14 +54,10 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
- if (IsKeyDown(KEY_RIGHT))
- {
- player.x += 2; // Player movement
- }
- else if (IsKeyDown(KEY_LEFT))
- {
- player.x -= 2; // Player movement
- }
+
+ // Player movement
+ if (IsKeyDown(KEY_RIGHT)) player.x += 2;
+ else if (IsKeyDown(KEY_LEFT)) player.x -= 2;
// Camera target follows player
camera.target = (Vector2){ player.x + 20, player.y + 20 };
diff --git a/src/core.c b/src/core.c
index 81bed607..d4df605f 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1251,20 +1251,20 @@ void BeginMode2D(Camera2D camera)
rlLoadIdentity(); // Reset current matrix (MODELVIEW)
rlMultMatrixf(MatrixToFloat(screenScaling)); // Apply screen scaling if required
- //The camera in world-space is set by
- //1. Move it to target
- //2. Rotate by -rotation and scale by (1/zoom)
+ // The camera in world-space is set by
+ // 1. Move it to target
+ // 2. Rotate by -rotation and scale by (1/zoom)
// When setting higher scale, it's more intuitive for the world to become bigger (= camera become smaller),
// not for the camera getting bigger, hence the invert. Same deal with rotation.
- //3. Move it by (-offset);
+ // 3. Move it by (-offset);
// Offset defines target transform relative to screen, but since we're effectively "moving" screen (camera)
// we need to do it into opposite direction (inverse transform)
- //
- //Having camera transform in world-space, inverse of it gives the modelview transform.
- //Since (A*B*C)' = C'*B'*A', the modelview is
- //1. Move to offset
- //2. Rotate and Scale
- //3. Move by -target
+
+ // Having camera transform in world-space, inverse of it gives the modelview transform.
+ // Since (A*B*C)' = C'*B'*A', the modelview is
+ // 1. Move to offset
+ // 2. Rotate and Scale
+ // 3. Move by -target
Matrix matOrigin = MatrixTranslate(-camera.target.x, -camera.target.y, 0.0f);
Matrix matRotation = MatrixRotate((Vector3){ 0.0f, 0.0f, 1.0f }, camera.rotation*DEG2RAD);
Matrix matScale = MatrixScale(camera.zoom, camera.zoom, 1.0f);