Python Forum
Infinite generating tilemap pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinite generating tilemap pygame
#1
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...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
Reply
#2
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
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply
#3
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Tilemap 3 squares too tall michael1789 2 2,281 May-27-2019, 08:57 PM
Last Post: michael1789

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020