X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgame%2Fcamera.h;h=2b167eb6c0b5188435b97984ad928185f305478a;hb=016bee583aa3145b41d4b9718f017d64eb5d37fa;hp=1a9c6b4e33c8cb7dd9df60f900a99c7da9cfa2da;hpb=884fa38b7a33f3de97085a231a1093922035fa1e;p=nothing.git diff --git a/src/game/camera.h b/src/game/camera.h index 1a9c6b4e..2b167eb6 100644 --- a/src/game/camera.h +++ b/src/game/camera.h @@ -1,72 +1,109 @@ #ifndef CAMERA_H_ #define CAMERA_H_ +#include + #include "color.h" #include "game/sprite_font.h" -#include "math/point.h" +#include "math/vec.h" #include "math/rect.h" #include "math/triangle.h" -typedef struct Camera Camera; +typedef struct { + bool debug_mode; + bool blackwhite_mode; + Vec2f position; + float scale; + SDL_Renderer *renderer; + Sprite_font *font; +} Camera; -Camera *create_camera(SDL_Renderer *renderer, - Sprite_font *font); -void destroy_camera(Camera *camera); +Camera create_camera(SDL_Renderer *renderer, + Sprite_font *font); -int camera_clear_background(Camera *camera, +int camera_clear_background(const Camera *camera, Color color); -int camera_fill_rect(Camera *camera, +int camera_fill_rect(const Camera *camera, Rect rect, Color color); -int camera_draw_rect(Camera * camera, +int camera_draw_rect(const Camera *camera, Rect rect, Color color); +int camera_draw_rect_screen(const Camera *camera, + Rect rect, + Color color); + +int camera_draw_thicc_rect_screen(const Camera *camera, + Rect rect, + Color color, + float thiccness); + +int camera_draw_line(const Camera *camera, + Vec2f begin, Vec2f end, + Color color); + int camera_draw_triangle(Camera *camera, Triangle t, Color color); -int camera_fill_triangle(Camera *camera, +int camera_fill_triangle(const Camera *camera, Triangle t, Color color); -int camera_render_text(Camera *camera, +int camera_render_text(const Camera *camera, const char *text, - Vec size, + Vec2f size, Color color, - Vec position); + Vec2f position); -int camera_render_debug_text(Camera *camera, +int camera_render_text_screen(const Camera *camera, + const char *text, + Vec2f size, + Color color, + Vec2f position); + +Rect camera_text_boundary_box(const Camera *camera, + Vec2f position, + Vec2f scale, + const char *text); + +int camera_render_debug_text(const Camera *camera, const char *text, - Vec position); + Vec2f position); -int camera_render_debug_rect(Camera *camera, +int camera_render_debug_rect(const Camera *camera, Rect rect, Color color); -void camera_center_at(Camera *camera, Point position); +void camera_center_at(Camera *camera, Vec2f position); void camera_scale(Camera *came, float scale); void camera_toggle_debug_mode(Camera *camera); void camera_disable_debug_mode(Camera *camera); -void camera_toggle_blackwhite_mode(Camera *camera); - -int camera_is_point_visible(const Camera *camera, Point p); +int camera_is_point_visible(const Camera *camera, Vec2f p); int camera_is_text_visible(const Camera *camera, - Vec size, - Vec position, + Vec2f size, + Vec2f position, const char *text); Rect camera_view_port(const Camera *camera); -Vec camera_map_screen(const Camera *camera, +Rect camera_view_port_screen(const Camera *camera); + +Vec2f camera_map_screen(const Camera *camera, Sint32 x, Sint32 y); -int camera_fill_rect_screen(Camera *camera, +Vec2f camera_point(const Camera *camera, const Vec2f p); +Rect camera_rect(const Camera *camera, const Rect rect); + +int camera_fill_rect_screen(const Camera *camera, Rect rect, Color color); +const Sprite_font *camera_font(const Camera *camera); + #endif // CAMERA_H_