Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update global_map.py #6

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def local_to_global(r: int, c: int, map_n: int):
map_x,
map_y,
) = MAP_DATA[map_n]["coordinates"]
return r + map_y, c + map_x
gy = r + map_y
gx = c + map_x
if 0 > gy >= GLOBAL_MAP_SHAPE[0] or 0 > gx >= GLOBAL_MAP_SHAPE[1]:
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({r}, {c}, {map_n})")
return 0, 0
return gy, gx
except KeyError:
print(f"Map id {map_n} not found in map_data.json.")
return r + 0, c + 0
except IndexError:
print(f"Coord {map_x}, {map_y} out of bounds for map id {map_n}.")
return 0, 0
Loading