I'm trying to render a numpy array, that is, its content to a screen in pygame. However, pygame text renderer only supports Unicode.
I tried to convert my array to chararray, but it wasn't a solution.
Are there any function in numpy that converts an array to a string, while maintaining the shape. Another approach was parsing the numpy array to string; albeit it worked, the array lost its shape.
Here's my code.
import pygame import numpy as np pygame.init() pygame.font.init() screen = pygame.display.set_mode((400, 400)) b = np.array([[1, 2, 3, 4], [3, 5, 6, 5]]) print(b) running = True font = pygame.font.SysFont("Arial", 20) while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False text = font.render(b, False, (255, 255, 255)) screen.blit(text, (30, 30)) pygame.display.flip() pygame.quit() quit()