It is given: one-image tile map. It is necessary to: implement an algorithm for displaying tiles (sprites) from this image by coordinates.

I do not know if it is clear or not that I asked a question. For example, we make an application tag. In which we load any picture. This picture is displayed as a result in the form of mixed tiles.

Is it possible to implement an algorithm for creating instances of tiles by standard modules so that the output is an instance of a tile from the overall picture. How for example can this be implemented in tkinter or pygame?

Can there be specialized modules for this?

I have an idea just to make instances of tiles using PILL, literally slicing the image into coordinates.

  • It is logical to use PIL - insolor
  • You can use the standard tools pygame. First, the entire image is loaded main_image = pygame.image.load ("path / to / image"), then the images you need are cut from the main_image by specifying the coordinates (the beginning and end of the section that is cut) x_end, igryk_end), second_image = main_image.subsurface (... etc. - Alex Osinny
  • Hmm ... Correction - not (X_start, play_start, X_end, play_ end), but - (X_start, play_ start, width, height) - Alex Osinny

0