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

Function worldToScreen

engine/src/utils.cpp:16–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include <vector>
15
16Point 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
25Vector2 screenToWorld(Point screen_point, Camera camera, ScreenRect screen) {
26 float x = (float)(((screen_point.x * camera.size.x) / screen.w) +

Callers

nothing calls this directly

Calls 1

PointClass · 0.85

Tested by

no test coverage detected