   [pygame] Getting a sprite drawn
  My code is as followsimport os, sysimport tracebackimport pygame as pgdef main():    succes = pg.init()    if not succes == (6,0):   print success    screen = pg.display.set_mode((640, 480))    player = Player()    group = pg.sprite.Group(player)    running = True    while running:   group.draw(screen)   pg.display.flip()   for ev in pg.event.get():  if ev.type == pg.QUIT: running = Falseclass Player(pg.sprite.Sprite):    def __init__(self):   pg.sprite.Sprite.__init__(self)   self.image = pg.Surface((200, 200))   self.image.fill((128, 128, 128))   self.rect = self.image.get_rect()if __name__ == '__main__':    try:   main()    except Exception, e:   tb = sys.exc_info()[2]   traceback.print_exception(e.__class__, e, tb)    pg.quit();It is supposed to create a player, put the player in a group and draw the group including the player. The player.image consist of a gray surface.However, when I run this nothing is shown.[Edited by - Somelauw on January 20, 2010 6:05:08 PM]
  You need to define where you want the sprite to be drawn:class Player(pg.sprite.Sprite):    def __init__(self):   pg.sprite.Sprite.__init__(self)   self.image = pg.Surface((200, 200))   self.image.fill((128, 128, 128))   self.rect = self.image.get_rect()   self.x = 100   # set the x attribute  self.y = 100   # set the y attribute   self.rect.center = (self.x, self.y) # sets the rect (and thus the sprite) at position self.x, self.y;  I tried it and it worked.Then I commented out the lines and it still worked.The problem might be that I put the class Player in a seperate file and used an import. For some reasons imported modules don't get compiled automatically when you draw one and you haven't restarted the idle.I'm using pyscripter.   ;  Right, once an imported module is compiled, the script will use the compiled version.   ;Quote:Original post by EsysRight, once an imported module is compiled, the script will use the compiled version.Is there a simple way to force reloading or a code editor which forces it?I think that for anything big, being able to split your code over multiple files without having to restart your editor is a must.   ;  you could try py_compile.compile;py_compile.compile(file[, cfile[, dfile[, doraise]]]) Compile a source file to byte-code and write out the byte-code cache file. The source code is loaded from the file name file. The byte-code is written to cfile, which defaults to file + 'c' ('o' if optimization is enabled in the current interpreter). If dfile is specified, it is used as the name of the source file in error messages instead of file. If doraise is true, a PyCompileError is raised when an error is encountered while compiling file. If doraise is false (the default), an error string is written to sys.stderr, but no exception is raised.;Quote:Original post by Esysyou could try py_compile.compile;py_compile.compile(file[, cfile[, dfile[, doraise]]]) Compile a source file to byte-code and write out the byte-code cache file. The source code is loaded from the file name file. The byte-code is written to cfile, which defaults to file + 'c' ('o' if optimization is enabled in the current interpreter). If dfile is specified, it is used as the name of the source file in error messages instead of file. If doraise is true, a PyCompileError is raised when an error is encountered while compiling file. If doraise is false (the default), an error string is written to sys.stderr, but no exception is raised.Is this the most convienent way to do it? Is this also the way professionals handle this problem?Do you put py_compile.compile inside your source code or do you call this function manually from the console each time before running?   ;  No - professionals probably aren't running Python from within the IDE, or they're using a more advanced IDE that doesn't cache the interpreter state between execution runs.   ;Quote:Original post by KylotanNo - professionals probably aren't running Python from within the IDE, or they're using a more advanced IDE that doesn't cache the interpreter state between execution runs.So what do they use instead?Does netbeans work?   ;  I just use a plain text editor. Other names I've heard people use are Wing, Komodo, and Eclipse.   