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

Re: [pygame] Sprite troubles



RenderPlain?  What's that?  It's not mentioned here:  http://www.pygame.org/docs/ref/sprite.html
I found it mentioned in some 2002 documentation.  I think it might be obsolete.   Not sure.

I've been using pygame.sprite.OrderedUpdates.

Dave


On Sat, Apr 30, 2011 at 3:53 PM, Nathan BIAGINI <nathan.open@xxxxxxxxx> wrote:
Hi everyone,

it sounds like a stupid question but i have written a really simple program where i just want to add a sprite to a sprite group and then draw the containing of this group.

Here is the main code :


import pygame
from sprites import Node

pygame.init()

screen = pygame.display.set_mode((640, 480))
node_group = pygame.sprite.RenderPlain()

node = Node((156, 234), 0)
node_group.add(node)

while 1:
        node_group.update()
        node_group.draw(screen)

        pygame.display.flip()

And here is my sprite class :

import pygame
from pygame.locals import *
from loads import loadImage

class Node(pygame.sprite.Sprite):
        '''
        Node class represent the sprite of each node of the
        map. So, one instance of Node is created for each
        node.
        '''

        def __init__(self, pos, node_type):
                pygame.sprite.Sprite.__init__(self)

                self.pos = pos
                self.node_type = node_type

                if self.node_type == 0:
                        self.image, self.rect = loadImage('ground.bmp', -1)

                elif self.node_type == 1:
                        self.image, self.rect = loadImage('wall.bmp', -1)

                elif self.node_type == 2:
                        self.image, self.rect = loadImage('hole.bmp', -1)

                self.rect.topleft = pos

        def update(self):
                pass

I maybe a bit tired but i can't see what i m doing wrong...

Thanks for your help.



--
“If anyone thinks the words ‘government’ and ‘efficiency’ belong in the same sentence, we  have counseling available.”
- Sen. Paul Tsongas (D-MA)