0
\$\begingroup\$

I am building a matrix out of addressable pixels and it will be run by a Pi (over the ethernet bus). The matrix will be 75 pixels wide and 20 pixels tall. As a side project, I thought it would be neat to run pong on it. I've seen some python based pong tutorials for Pi, but the problem is that they want to pass the data out to a screen via pygame.display function.

I have access to pass pixel information using a memory map block, so is there anyway to do that with pygame instead of passing it out the video port?

In case anyone is curious, this was the pong tutorial I was looking at: Pong Tutorial

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Pygame uses a memory map and pygame.display.flip() and pygame.display.update() are the functions that update the display itself.

You just have to call pygame.display.get_surface(), to get the screen map as a surface.

\$\endgroup\$
4
  • \$\begingroup\$ Thanks. So instead of doing something like pygame.display.update(). I could do something like screen = pygame.display.get_surface(), draw my screens like normal, and then pass the "screen" to my memory map reading app, right? \$\endgroup\$
    – toozie21
    Commented Jun 6, 2014 at 18:06
  • \$\begingroup\$ Yes that should work. You also have screen.get_view() and screen.get_buffer() functions in case you need to access raw pixel data. \$\endgroup\$
    – pmoleri
    Commented Jun 6, 2014 at 18:16
  • \$\begingroup\$ So the raw pixels are the RGB values for each individual pixel? That would be great if so because an RGB triplet is ultamately what I need to pass along I think. \$\endgroup\$
    – toozie21
    Commented Jun 6, 2014 at 18:51
  • \$\begingroup\$ Yes, it's byte data so you have to figure out how every color is stored. You also have other options like: pygame.org/docs/ref/pixelcopy.html to obtain a 3D array (row, column, color). \$\endgroup\$
    – pmoleri
    Commented Jun 6, 2014 at 23:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .