June 2015
Beginner
348 pages
8h 44m
English
In this section, we will tile a small image to fill the game screen.
array2d() function copies pixels into a two-dimensional array (and there is a similar function for three-dimensional arrays). Copy the pixels from the avatar image into an array:pixels = pygame.surfarray.array2d(img)
X = pixels.shape[0] * 7 Y = pixels.shape[1] * 7 screen = pygame.display.set_mode((X, Y))
tile() function. The data needs to be converted into integer values, because Pygame defines colors as integers:new_pixels = ...
Read now
Unlock full access