- 1,748
- Posts
- 15
- Years
- Age 28
- Nearby my feet.
- Seen Apr 18, 2021
@ IceGod
This is simple, first we divide the grid up into X amount of blocks:
Now we can get the position on the map
This is the code I would use for things that requires a specific block.
This is simple, first we divide the grid up into X amount of blocks:
Code:
x_blocks = map_width / world_map_width #(world_map_width = amount of tiles on the map)
y_blocks = map_height / world_map_height #(same as above except with height instead)
Code:
x_pos = (player_x / x_blocks).round
y_pos = (player_y / y_blocks).round
This is the code I would use for things that requires a specific block.