In this video, I'll show you how to make a level editor for pygame.
You'll be able to design a game level in paint and convert it as a level in your python game.
#mapmaker #pygame #python
Please leave a LIKE and SUBSCRIBE for more content!
/ @codenull3755
Code:
level1 = list(imread('img.png', 1))#the image
for i in range(len(level1)):#foreach rows of pixels in the image
for j in range(len(level1[i])):#foreach pixel in the row
blue = list(level1[i][j])[0]
green = list(level1[i][j])[1]
red = list(level1[i][j])[2]
if blue == 255 and green == 255 and red == 255:
display.blit(dirt_img,(j*10,i*10))
elif blue == 0 and green == 255 and red == 0:
pass
else:
pass
#pygame.draw.rect(display, (10, 150, 200), pygame.Rect(j*10, i*10, 32, 32))
Sur cette page du site, vous pouvez voir la vidéo en ligne Level Editor / Map Maker | Python Pygame | Game Dev durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur codeNULL 01 juillet 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 2,498 fois et il a aimé 50 téléspectateurs. Bon visionnage!