# Pygame?

New Member Posts: 12
I got my Up Board up and running with no problems - wow, this thing is FAST. I own a very large number of other Linux based SBC's and this one is amazing so far.

I installed the latest ubilinux image and I am having some problems with Pygame. I have run apt-get update and apt-get dist-upgrade. I installed pygame with "sudo apt-get install python-pygame". However, when running a simple script that plots Sierpinski's triangle the screen simply goes blank. I know this script works as I have run it on a lot of different computers. In fact, it is one of the scripts I use to get my students interested in Python programming.

The script appears below. Any help would be appreciated.
```#Simple Python 2 script by David Culp (dwculp@gmail.com) that uses a chaos algorithm to plot Sierpinski's triangle

import pygame, random, sys

#change these to suit your screen
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600

num_iterations = int(raw_input("How many iterations do you want? "))

pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
screen.fill( (0,0,0) )

ax = 0
ay = SCREEN_HEIGHT
bx = SCREEN_WIDTH
by = SCREEN_HEIGHT
cx = SCREEN_WIDTH/2
cy = 0

px = ax
py = ay

for n in range(1, num_iterations+1):

vx = random.randrange(0,3)
if vx == 0:
px = (px + ax) / 2
py = (py + ay) / 2
red = 255
green = 0
blue = 0
elif vx == 1:
px = (px + bx) / 2
py = (py + by) / 2
red = 0
green = 0
blue = 255
else:
px = (px + cx) / 2
py = (py + cy) / 2
red = 0
green = 255
blue = 0

screen.set_at( (px, py), (red,green,blue) )
if n%10000 == 0: sys.stdout.write('.')
if n%100000 == 0: print '|'+str(n)+'\n'
pygame.display.update()

print "\nDone!"

while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
pygame.quit()
sys.exit()
```

Hi daveculp,

About the pygame, could you try to change the resolution to 1920x1080 on the following section?

#change these to suit your screen
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
• New Member Posts: 12
It doesn't work, the screen still blanks. The actual problem is in the call to pygame.init() which doesn't set a screen resolution, it only initializes pygame.

I will see if I can compile pygame from source this weekend instead of installing it from the repo and see if that fixes it.
• New Member Posts: 12
I compiled Pygame from source and installed and I get the same thing - a black screen.

Anyone willing to give pygame a try? Install pygame with:
```sudo apt-get install python-pygame
```

Then fire up python and try the following at the python prompt:
```>>>import pygame
>>>pygame.init()
```

See if the screen blanks.
• New Member Posts: 4
i get this.
```:~\$ python
Python 2.7.9 (default, Mar  1 2015, 12:57:24)
[GCC 4.9.2] on linux2
>>> import pygame
>>> pygame.init()
(6, 0)
>>>
```

hope it helps
• New Member Posts: 12
Thanks. So no screen blanking then?

I actually get the same output except my screen goes blank and the monitor loses signal. I can then press ESC and blindly type "quit()" into the python command prompt. I get my monitor signal back and the exact same output you have. The return of "(6, 0)" indicates that pygame was able to init 6 subsystems and failed on 0. Although now that I think about it, I wonder if my output was (0,6).

My next steps to figure this out are:

1. Swap in a different monitor. I didn't think pygame.init() actually did anything at all with switching resolution and I know pygame works with some other Linux systems I have with this monitor but you never know.
2. Reinstall Ubilinux.
3. Try Ubuntu
• New Member Posts: 4
Without Blanking.
• New Member Posts: 12
Solved.

It was the monitor. I swapped out with a newer model and it works great.