Has anyone tried using pygame?

Home Forums Forums General discussion Has anyone tried using pygame?

Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2646
    jonn.blanchard
    Participant

    I’m trying to run a python script that uses pygame but as soon as it initialises the screen it just goes white. Anyone else tried anything similar?

    #2663
    Mark Williams
    Keymaster

    Try this code, I just tested it and it worked.


    import pygame, sys, os
    from pygame.locals import *
    os.putenv('SDL_FBDEV', '/dev/fb1')
    pygame.init()
    # set up the window
    DISPLAYSURF = pygame.display.set_mode((480, 320))
    # set up the colors
    BLACK = ( 0, 0, 0)
    WHITE = (255, 255, 255)
    RED = (255, 0, 0)
    GREEN = ( 0, 255, 0)
    BLUE = ( 0, 0, 255)

    # draw on the surface object
    DISPLAYSURF.fill(WHITE)
    pygame.draw.polygon(DISPLAYSURF, GREEN, ((146, 0), (291, 106), (236, 277), (56, 277), (0, 106)))
    pygame.draw.line(DISPLAYSURF, BLUE, (60, 60), (120, 60), 4)
    pygame.draw.line(DISPLAYSURF, BLUE, (120, 60), (60, 120))
    pygame.draw.line(DISPLAYSURF, BLUE, (60, 120), (120, 120), 4)
    pygame.draw.circle(DISPLAYSURF, BLUE, (300, 50), 20, 0)
    pygame.draw.ellipse(DISPLAYSURF, RED, (300, 200, 40, 80), 1)
    pygame.draw.rect(DISPLAYSURF, RED, (200, 150, 100, 50))

    pixObj = pygame.PixelArray(DISPLAYSURF)
    pixObj[380][280] = BLACK
    pixObj[382][282] = BLACK
    pixObj[384][284] = BLACK
    pixObj[386][286] = BLACK
    pixObj[388][288] = BLACK
    del pixObj
    # run the game loop
    while True:
    for event in pygame.event.get():
    if event.type == QUIT:
    pygame.quit()
    sys.exit()
    pygame.display.update()

    Mark --OzzMaker.com --

    #2666
    jonn.blanchard
    Participant

    I’ll give it a try when I get home, cheers Mark

    #2689
    Mark Williams
    Keymaster

    BTW: the code above is all one file. I have no idea why the forum separated it like that.

    Mark --OzzMaker.com --

    #2697
    jonn.blanchard
    Participant

    Turns out I was accidentally using an old buggy version of my code, it works perfectly – cheers Mark

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Blip, blop, bloop…