diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/field_map_obj.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 0d04c4063..caf43ce6a 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -764,3 +764,24 @@ void RemoveFieldObjectsOutsideView(void) } } } + +void RemoveFieldObjectIfOutsideView(struct MapObject *mapObject) +{ + s16 left; + s16 right; + s16 top; + s16 bottom; + + left = gSaveBlock1Ptr->pos.x - 2; + right = gSaveBlock1Ptr->pos.x + 17; + top = gSaveBlock1Ptr->pos.y; + bottom = gSaveBlock1Ptr->pos.y + 16; + + if (mapObject->coords2.x >= left && mapObject->coords2.x <= right + && mapObject->coords2.y >= top && mapObject->coords2.y <= bottom) + return; + if (mapObject->coords1.x >= left && mapObject->coords1.x <= right + && mapObject->coords1.y >= top && mapObject->coords1.y <= bottom) + return; + RemoveFieldObject(mapObject); +} |