I am trying to create a game map in pygame with Tiled but I don't know how to setup the collision for every tile. I successfully displayed the map on the screen, but how to verify the collisions? Here is the code:
import pytmx
import pygame
pygame.init()
display = pygame.display.set_mode((800,400))
clock = pygame.time.Clock()
gameMap = pytmx.load_pygame("map.tmx")
for layer in gameMap.visible_layers:
for x, y, gid in layer:
tile = gameMap.get_tile_image_by_gid(gid)
if(tile != None):
display.blit(tile, (x * gameMap.tilewidth, y * gameMap.tileheight))
while(True):
clock.tick(60)
keys = pygame.key.get_pressed()
if(keys[pygame.K_ESCAPE]):
quit()
for event in pygame.event.get():
if(event.type == pygame.QUIT):
quit()
pygame.display.update()
I didn't setup any collisions in Tiled because I don't know how.