I'm having a hard time implementing the player moving around my world of 2048x2048 tiles that is generated using a noise function. I'm in it for weeks, and I can not, I mess around with the coordinates, and there's always a bug. I was trying like this:
1 - I paint the map around the player (I'm using a tilemap) I paint a 64x64 area, with the player positioned in the center
2 - create a rectangle and center it in the player, the rectangle has an equivalent size of 32x32, and each frame creates another rectangle that is compared with the old one, so I take the area that has not yet been painted, so I can paint.
The problem is that when I reach the extremes of the map, when x = 0 or x = 2048 for example, I need that "x" equals 2048, and equals 0, respectively, as if the world had "turned" and I'm not sure how to deal with the world's data and the coordinates of the tilemap, because when I start by painting the map around the player, it will be in a position that would be 32.32, and the rectangle 16.16, I can not understand what I have to do it, I mess up everything with the coordinates, in this question, it helped me, I'm using the mod:
it works, but what I am not able to do is pass the x and y correct, there are always bugs of this type, where I struggle with the numbers, but no use, if I fix the floor to one side the bug appears on the other:
here was to be water, and it has a land line for example.
I'm using Godot 3.
I'm not sure, but it seems everything is going very well, what I was wrong was forgetting that, for example, a 64x64 array starts from 0 to 63, I was really dumb. The image below shows what it would look like in a 64x64 world:
As I solved it was just doing this "map_size - 1" and decreasing and adding values to the left or right, 0, +31, respectively, since the rectangle starts at position 16, 16.
but when I do this now, there is another problem when this happens:
which occurs because of the "map_size - 1", but without it it is still more messy.
** Up 2: **
I was able to fix the up 1 error, I was calling the wrong mod function, without adding the + x and + y, so it arrived at 33 and it is no more than the verification "map_size - 1", now it is working in the horizontal and vertical movements, however I'm still wrong to move diagonally.
I think I got it, the problem if I was not mistaken was in the "stairs", so it works:
# LEFT-UP # RIGHT-UP # DOWN-LEFT # DOWN-RIGHT
But I still have to hit the pieces of map that are behind, but I think it's in the "turn them off" function. I confess that I do not quite understand why this works, I would like to understand.
Note 1: Still the rare cases that the map generates wrong, but actually abusing the keys, quickly clicking for all meaningless directions, such as varying up and down, pressing low, a very strange movement, but the failure happens.