| 14 | #include <vector> |
| 15 | |
| 16 | Point worldToScreen(Vector2 world_point, Camera camera, ScreenRect screen) { |
| 17 | int x = (int)(((world_point.x - camera.position.x) / camera.size.x) * |
| 18 | (float)screen.w); |
| 19 | int y = (int)(((world_point.y - camera.position.y) / camera.size.y) * -1 * |
| 20 | ((float)screen.h) + |
| 21 | (float)screen.h); |
| 22 | return Point(x, y); |
| 23 | } |
| 24 | |
| 25 | Vector2 screenToWorld(Point screen_point, Camera camera, ScreenRect screen) { |
| 26 | float x = (float)(((screen_point.x * camera.size.x) / screen.w) + |