diff --git a/src/GameEngine.c b/src/GameEngine.c index 7e0fa14..023c4d8 100644 --- a/src/GameEngine.c +++ b/src/GameEngine.c @@ -225,13 +225,23 @@ void fill_rectangle(RenderRect rect, SDL_Color color) { } void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest) { + if (!dest) { + return; + } + WindowDrawingArea area = get_window_drawing_area(); // If the rectangle is completely out of bounds, set its width and height to 0 if (dest->x > area.x + area.width || dest->x + dest->width < area.x || dest->y > area.y + area.height || dest->y + dest->height < area.y) { - src->width = 0.0f; - src->height = 0.0f; + if (src) { + src->width = 0.0f; + src->height = 0.0f; + } + + dest->width = 0.0f; + dest->height = 0.0f; + return; }