Advertisement
Tkap1

Untitled

Nov 8th, 2023 (edited)
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. struct Camera
  2. {
  3.     float x;
  4.     float y;
  5.     float zoom = 1;
  6. };
  7. Camera camera = {};
  8.  
  9.  
  10. void update()
  11. {
  12.     float player_x = 0;
  13.     float player_y = 0;
  14.     float player_width = 32;
  15.     float player_height = 32;
  16.  
  17.     float new_x = player_x - camera.x;
  18.     float new_y = player_y - camera.y;
  19.     new_x *= camera.zoom;
  20.     new_y *= camera.zoom;
  21.  
  22.     draw_player(new_x, new_y, player_width * camera.zoom, player_height * camera.zoom);
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement