Skip to content

Commit

Permalink
更新:支持地图边界判断
Browse files Browse the repository at this point in the history
  • Loading branch information
park671 committed Jun 5, 2023
1 parent 6fe34b5 commit 3eaf8b1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/src/main/cpp/logic/render_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ bool MapRender::processKey(byte directKey, byte functionKey) {
}

bool MapRender::checkOutOfMap(Character *player, int targetX, int targetY) {
int map_height = map_size[mapId * 2];
int map_width = map_size[mapId * 2 + 1];
if (targetX < 0
|| targetY < 0
|| targetX > map_width
|| targetY > map_height) {
byte startX = movable_offset[mapId*2];
byte startY = movable_offset[mapId*2+1];
byte endX = startX+movable_size[mapId*2];
byte endY = startY+movable_size[mapId*2+1];
if (targetX < startX
|| targetY < startY
|| targetX > endX
|| targetY > endY) {
entranceAnimation = ANIMATION_DURATION;
pthread_mutex_lock(&changeMapMutex);
--lastPosStackTop;
Expand Down

0 comments on commit 3eaf8b1

Please sign in to comment.