[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] RLEACCEL error.



Hi,

Been playing about and trying ot get my first PyGame routine sorted. I've hit some hurdles, manged to scramble my way over them but this one has got me totally stumped!

When I run my program I'm getting the following error...

NameError: global name 'RLEACCEL' is not defined

I can't seem to see any reference to this anywhere, my code is...

import os,sys
import pygame
import random

def load_image(name, colorkey=None):
    fullname = os.path.join('', name)
    try:
        image = pygame.image.load(fullname)
    except pygame.error, message:
        print 'Cannot load image:', name
        raise SystemExit, message
    image = image.convert()
    if colorkey is not None:
        if colorkey is -1:
            colorkey = image.get_at((0,0))
        image.set_colorkey(colorkey, RLEACCEL)
    return image, image.get_rect()


class block(pygame.sprite.Sprite): blockImage=None

    def __init__(self):
        pygame.sprite.Sprite.__init__(self)

        if block.blockImage is None:
            block.image, block.rect=load_image("block2.jpg",-1)

    def update(self):
        self.rect.move(1,1)


def main(): pygame.init() screen=pygame.display.set_mode((640,480)) background=pygame.Surface(screen.get_size()).convert_alpha()

    a=block()
    allsprites=pygame.sprite.RenderPlain((block))



    while True:
        allsprites.update()
        screen.blit(background,(0,0))
        allsprites.draw(screen)
        pygame.display.flip()


if __name__=="__main__": main()


IF there are any other bugs in there, please don't tell me as I'm trying to learn from my mistakes, but the RLEACCEL has had me baffled for hours now.


TIA