+static boolean player_out_of_window(GdGame *game, int player_x, int player_y)
+{
+ // if not yet born, we treat as visible. so cave will run.
+ // the user is unable to control an unborn player, so this is the right behaviour.
+ if (game->cave->player_state == GD_PL_NOT_YET)
+ return FALSE;
+
+ // check if active player is outside drawing area. if yes, we should wait for scrolling
+ if ((player_x * cell_size) < scroll_x ||
+ (player_x * cell_size + cell_size - 1) > scroll_x + play_area_w)
+ {
+ // but only do the wait, if the player SHOULD BE visible, ie. he is inside
+ // the defined visible area of the cave
+ if (game->cave->player_x >= game->cave->x1 &&
+ game->cave->player_x <= game->cave->x2)
+ return TRUE;
+ }
+
+ if ((player_y * cell_size) < scroll_y ||
+ (player_y * cell_size + cell_size - 1) > scroll_y + play_area_h)
+ {
+ // but only do the wait, if the player SHOULD BE visible, ie. he is inside
+ // the defined visible area of the cave
+ if (game->cave->player_y >= game->cave->y1 &&
+ game->cave->player_y <= game->cave->y2)
+ return TRUE;
+ }
+
+ // player is inside visible window
+ return FALSE;
+}
+