summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-09-06 10:50:07 -0700
committer3gg <3gg@shellblade.net>2025-09-06 10:50:07 -0700
commitf46c66485b758385417431d290e1a2958dececea (patch)
tree1ff44a03edfa6d8237a7a0ac962ab4344a0477e0 /include
parentc8fdef3b8f9b2eaab5fdccc9f8a9888d12972cc5 (diff)
Implement camera clipping for ortho maps
Diffstat (limited to 'include')
-rw-r--r--include/isogfx/gfx2d.h19
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.
111void gfx2d_update(Gfx2d*, double t); 111void 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.
118void gfx2d_set_camera(Gfx2d*, int x, int y);
119
120/// Render the world. 113/// Render the world.
121void gfx2d_render(Gfx2d*); 114void 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().
128void gfx2d_draw_tile(Gfx2d*, int x, int y, Tile); 121void 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.
131void gfx2d_clip_camera(const Gfx2d*, float* x, float* y);
132
130/// Get the virtual screen's dimensions. 133/// Get the virtual screen's dimensions.
131void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height); 134void gfx2d_get_screen_size(const Gfx2d*, int* width, int* height);
132 135