diff options
author | 3gg <3gg@shellblade.net> | 2025-09-06 10:50:07 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-09-06 10:50:07 -0700 |
commit | f46c66485b758385417431d290e1a2958dececea (patch) | |
tree | 1ff44a03edfa6d8237a7a0ac962ab4344a0477e0 /include | |
parent | c8fdef3b8f9b2eaab5fdccc9f8a9888d12972cc5 (diff) |
Implement camera clipping for ortho maps
Diffstat (limited to 'include')
-rw-r--r-- | include/isogfx/gfx2d.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/include/isogfx/gfx2d.h b/include/isogfx/gfx2d.h index a3ddbb6..33a4591 100644 --- a/include/isogfx/gfx2d.h +++ b/include/isogfx/gfx2d.h | |||
@@ -110,15 +110,8 @@ void gfx2d_set_sprite_animation(Gfx2d*, Sprite, int animation); | |||
110 | /// Currently, this updates the sprite animations. | 110 | /// Currently, this updates the sprite animations. |
111 | void gfx2d_update(Gfx2d*, double t); | 111 | void gfx2d_update(Gfx2d*, double t); |
112 | 112 | ||
113 | // TODO: Do we really need to store the camera in the library? It's not used | ||
114 | // for anything other than to render, so we could remove library state and | ||
115 | // take a camera argument in render() instead. | ||
116 | |||
117 | /// Set the camera. | ||
118 | void gfx2d_set_camera(Gfx2d*, int x, int y); | ||
119 | |||
120 | /// Render the world. | 113 | /// Render the world. |
121 | void gfx2d_render(Gfx2d*); | 114 | void gfx2d_render(Gfx2d*, int camera_x, int camera_y); |
122 | 115 | ||
123 | /// Draw/overlay a tile at position (x,y). | 116 | /// Draw/overlay a tile at position (x,y). |
124 | /// | 117 | /// |
@@ -127,6 +120,16 @@ void gfx2d_render(Gfx2d*); | |||
127 | /// position (x,y) instead, use gfx2d_set_tile(). | 120 | /// position (x,y) instead, use gfx2d_set_tile(). |
128 | void gfx2d_draw_tile(Gfx2d*, int x, int y, Tile); | 121 | void gfx2d_draw_tile(Gfx2d*, int x, int y, Tile); |
129 | 122 | ||
123 | /// Clip camera coordinates to the loaded map. | ||
124 | /// | ||
125 | /// This is useful for implementing camera movement, in which you typically | ||
126 | /// want the camera to stay within the map's bounds. | ||
127 | /// | ||
128 | /// (x,y) are the top-left coordinates of the camera. | ||
129 | /// | ||
130 | /// A map must have previously been loaded. | ||
131 | void gfx2d_clip_camera(const Gfx2d*, float* x, float* y); | ||
132 | |||
130 | /// Get the virtual screen's dimensions. | 133 | /// Get the virtual screen's dimensions. |
131 | void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height); | 134 | void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height); |
132 | 135 | ||