Python Forum
Infinite generating tilemap pygame - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: Infinite generating tilemap pygame (/thread-27618.html)



Infinite generating tilemap pygame - Kolterdyx - Jun-13-2020

I am trying to get an infinite generating 2D world algorithm to work.

  1. I first get an area that gives me 36 chunk positions around the player

  2. Then I check if any of those positions has a generated chunk

  3. If not, I generate it, and add it to a dictionary with the position as key, and a chain of characters as content. (I represent each tile as a character)

  4. Then I load the chunks in the area. I iterate through the content of each chunk in the area. Then I add that chunk to the loaded chunks list

  5. I create a 'bundle' with one tuple for each tile, wich has (tile, x, y) where tile is a char, and x and y are the position of said tile.

  6. I iterate through each bundle to generate each chunk around the player.

  7. Then I iterate through the loaded chunks list and look for those that are not in the area around the player. Each tile stores in its atributes the chunk they are in, so I look for all tiles that are in said chunks, and kill them.

This algorithm looks like something that should work, but I have coded it and it doesn't. I get a weird bug that I'll show in the following video:

https://www.reddit.com/r/pygame/comments/h8c0xe/infinite_world_generation_algorithm/

Link to my code

https://github.com/Kolterdyx/VoidShips

I found out the bug just happened on the negative side of the plane, so I have restricted the player movement to the positive side


RE: Infinite generating tilemap pygame - pyzyx3qwerty - Jun-14-2020

Please, post your script in this forum itself - no need to give links which send us to other sites to get access to your script. See BBCode to know more


RE: Infinite generating tilemap pygame - buran - Jun-14-2020

Please, post the fulltraceback in error tags, here on the forum.
Same for your code - post here, in python tags. If the code is too longs, depends on resources like image files, etc. - create a repo on a service like github or bitbucket. Not many would download a zip file from untrusted source.