c.viewport_x = viewport_x;
c.viewport_y = viewport_y;
- c.zoom = 2;
+ c.zoom = 1;
return c;
}
lrts_bool t_camera_is_visible_screen(struct t_camera *c, i32 x, i32 y) {
lrts_assert(c);
lrts_assert(c->zoom);
- return u_point_in_rect(x, y, c->x, c->y, c->viewport_x / c->zoom, c->viewport_y / c->zoom);
+ return u_point_in_rect(x, y, c->x, c->y, c->viewport_x, c->viewport_y);
}
return n * t_camera_zoom_factor(c);
}
+struct u_vec2 t_camera_zoom_vec2(struct t_camera *c, struct u_vec2 v) {
+ struct u_vec2 r;
+ r.x = t_camera_zoom(c, v.x);
+ r.y = t_camera_zoom(c, v.y);
+ return r;
+}
+
i32 t_camera_zoom_factor(struct t_camera *c) {
lrts_assert(c);
lrts_assert(c->zoom);
#define T_CAMERA_H__
#include "u_defs.h"
+#include "u_math.h"
struct t_camera {
i32 x;
/* multiplies by zoom factor */
i32 t_camera_zoom(struct t_camera *c, i32 n);
+struct u_vec2 t_camera_zoom_vec2(struct t_camera *c, struct u_vec2 v);
+
i32 t_camera_zoom_factor(struct t_camera *c);