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

Function screenToWorld

engine/src/utils.cpp:25–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25Vector2 screenToWorld(Point screen_point, Camera camera, ScreenRect screen) {
26 float x = (float)(((screen_point.x * camera.size.x) / screen.w) +
27 camera.position.x);
28 float y =
29 (float)(((screen_point.y - screen.h) / screen.h) * -1 * +camera.size.y +
30 camera.position.y);
31 return Vector2(x, y);
32}
33
34Point worldToTile(Vector2 position, Vector2 size) {
35 return Point((int)(position.x / size.x), (int)(position.y / size.y));

Callers

nothing calls this directly

Calls 1

Vector2Class · 0.85

Tested by

no test coverage detected