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 /demos | |
parent | c8fdef3b8f9b2eaab5fdccc9f8a9888d12972cc5 (diff) |
Implement camera clipping for ortho maps
Diffstat (limited to 'demos')
-rw-r--r-- | demos/checkerboard/checkerboard.c | 2 | ||||
-rw-r--r-- | demos/isomap/isomap.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/demos/checkerboard/checkerboard.c b/demos/checkerboard/checkerboard.c index 243f7a8..f9631d8 100644 --- a/demos/checkerboard/checkerboard.c +++ b/demos/checkerboard/checkerboard.c | |||
@@ -137,7 +137,7 @@ static void render(const GfxApp* app, GfxAppState* state) { | |||
137 | 137 | ||
138 | Gfx2d* iso = state->gfx; | 138 | Gfx2d* iso = state->gfx; |
139 | 139 | ||
140 | gfx2d_render(iso); | 140 | gfx2d_render(iso, 0, 0); |
141 | 141 | ||
142 | if ((state->xpick != -1) && (state->ypick != -1)) { | 142 | if ((state->xpick != -1) && (state->ypick != -1)) { |
143 | gfx2d_draw_tile(iso, state->xpick, state->ypick, state->red); | 143 | gfx2d_draw_tile(iso, state->xpick, state->ypick, state->red); |
diff --git a/demos/isomap/isomap.c b/demos/isomap/isomap.c index 471ef57..e66d14d 100644 --- a/demos/isomap/isomap.c +++ b/demos/isomap/isomap.c | |||
@@ -47,7 +47,7 @@ static bool init(GfxApp* app, GfxAppState* state, int argc, const char** argv) { | |||
47 | Gfx2d* iso = state->gfx; | 47 | Gfx2d* iso = state->gfx; |
48 | 48 | ||
49 | if (!gfx2d_load_map( | 49 | if (!gfx2d_load_map( |
50 | iso, "/home/jeanne/Nextcloud/assets/tilemaps/scrabling1.tm")) { | 50 | iso, "/home/jeanne/Nextcloud/assets/tilemaps/desert1.tm")) { |
51 | return false; | 51 | return false; |
52 | } | 52 | } |
53 | 53 | ||
@@ -100,9 +100,9 @@ static void update(GfxApp* app, GfxAppState* state, double t, double dt) { | |||
100 | assert(state); | 100 | assert(state); |
101 | 101 | ||
102 | state->camera = vec2_add(state->camera, get_camera_movement(app, (R)dt)); | 102 | state->camera = vec2_add(state->camera, get_camera_movement(app, (R)dt)); |
103 | gfx2d_clip_camera(state->gfx, &state->camera.x, &state->camera.y); | ||
103 | 104 | ||
104 | Gfx2d* iso = state->gfx; | 105 | Gfx2d* iso = state->gfx; |
105 | gfx2d_set_camera(iso, (int)state->camera.x, (int)state->camera.y); | ||
106 | gfx2d_update(iso, t); | 106 | gfx2d_update(iso, t); |
107 | } | 107 | } |
108 | 108 | ||
@@ -111,7 +111,7 @@ static void render(const GfxApp* app, GfxAppState* state) { | |||
111 | assert(state); | 111 | assert(state); |
112 | 112 | ||
113 | Gfx2d* iso = state->gfx; | 113 | Gfx2d* iso = state->gfx; |
114 | gfx2d_render(iso); | 114 | gfx2d_render(iso, (int)state->camera.x, (int)state->camera.y); |
115 | gfx2d_backend_render(state->backend, iso); | 115 | gfx2d_backend_render(state->backend, iso); |
116 | } | 116 | } |
117 | 117 | ||