change Camera2D behavior (#945)

This commit is contained in:
arvyy 2019-08-16 17:09:50 +03:00 committed by Ray
parent c387bc586d
commit d8b8c0f3fc
2 changed files with 17 additions and 6 deletions

View file

@ -42,7 +42,7 @@ int main(void)
Camera2D camera = { 0 };
camera.target = (Vector2){ player.x + 20, player.y + 20 };
camera.offset = (Vector2){ 0, 0 };
camera.offset = (Vector2){ screenWidth / 2, screenHeight / 2 };
camera.rotation = 0.0f;
camera.zoom = 1.0f;
@ -57,12 +57,10 @@ int main(void)
if (IsKeyDown(KEY_RIGHT))
{
player.x += 2; // Player movement
camera.offset.x -= 2; // Camera displacement with player movement
}
else if (IsKeyDown(KEY_LEFT))
{
player.x -= 2; // Player movement
camera.offset.x += 2; // Camera displacement with player movement
}
// Camera target follows player
@ -135,4 +133,4 @@ int main(void)
//--------------------------------------------------------------------------------------
return 0;
}
}