JacksEscape/camera.h

39 lines
1.0 KiB
C
Raw Permalink Normal View History

2024-03-07 10:05:32 +08:00
#pragma once
#include "player.h"
#include "types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _App App;
typedef struct {
App *super;
Component_Player *player;
2024-04-15 14:18:12 +08:00
Box2 screen; // Screen box, e.g. 1280x720 origin (0,0)
Box2 cam, *target; // Current & target camera
double speed; // Fraction of distance between cam & target to be covered in 1 sec
2024-03-07 10:05:32 +08:00
} System_Camera;
System_Camera *camera_NewSystem(App *super);
void camera_DeleteSystem(System_Camera *sys);
2024-03-08 14:51:29 +08:00
void camera_AddEntity(System_Camera *sys, Entity *e);
void camera_DeleteEntity(System_Camera *sys, uintptr_t id);
2024-03-07 10:05:32 +08:00
void camera_Advance(System_Camera *sys, Duration deltaTime);
2024-03-19 11:59:09 +08:00
Vec2 camera_TransformVec2(System_Camera *sys, Vec2 world); // Transform a Point, accounted for offset
Box2 camera_TransformBox2(System_Camera *sys, Box2 world); // Transform a Rect, accounted for offset & zoom
Vec2 camera_TransformSize(System_Camera *sys, Vec2 worldSize); // Transform a certain size, accounted for only zoom
2024-03-08 14:51:29 +08:00
2024-03-07 10:05:32 +08:00
#ifdef __cplusplus
}
#endif