示例#1
0
文件: camera.py 项目: MrGecko/pyguane
 def update(self, *args, **kwargs):
     self._updateQuadGroupFromRect(self._frame)
     #tick = kwargs["tick"]
     quadgroup = SpriteFactory().quadgroup
     if (self._last_frame != self._frame) and (quadgroup is not None):
         for spr in quadgroup.sprites():
             spr.rect.move_ip(self._dx + spr.position.left - spr.rect.left,
                              self._dy + spr.position.top - spr.rect.top)
             spr.dirty = 1
     
     quadgroup.dontSeekDirtiesNextTime()           
     self._last_frame = self._frame.copy()
示例#2
0
 def _makeSpriteFromData(self, data, x, y, layer=0):
     if data is None:
         raise Exception("Error: the data is None (maybe the symbol is wrong)")
     
     if data.has_key("layer"):
         layer = data["layer"]
         
     new_sprite = SpriteFactory().fromFile(data["kind"], data["filename"], data["ppa"], (x, y), data["area"], layer)
     if data["colorkey"] is not None:
         new_sprite.setColorKey(data["colorkey"])
         
     self._bindAnimationsFromData(data, new_sprite)
     
     return new_sprite
示例#3
0
文件: game.py 项目: MrGecko/pyguane
class Game(object):
    def __init__(self, width, height):
        self._egg = Egg(width, height,)
        self.clock = self._egg.clock
        
        self.physic_world = PhysicWorld(Rect(-width, -height, width * 3, height * 3))
        self.state_manager = StateManager()
        
        self.sprite_factory = SpriteFactory()
        self._go_librarian = Librarian()
        Window().bgd = "grey"
        
        @self.renderer(Window().surface)
        def renderGame(surface):
            
            if self.physic_world.debug:
                color = self.physic_world.DEBUG_COLOR
                for b in self.physic_world.world:
                    x, y = b.position
                    for fixture in b:
                        vertices = [(vx + x, vy + y) for vx, vy in fixture.shape.vertices]
                        polygon(surface, vertices, color)
                displayFlip()
                
            return self.sprite_factory.draw(surface, Window().bgd)
    
    
    def getObjects(self, path="*"): return self._go_librarian.get(path)
    def delObjects(self, path): self._go_librarian.delete(path)
    def addObjects(self, path, objs): self._go_librarian.add(path, objs)
    def updateObjects(self, *args, **kargs): self._go_librarian.update(*args, **kargs)
    def getObjectsKeys(self): return self._go_librarian.keys         
    
    def renderer(self, *args):
        return self._egg.Renderer(*args)
    
    def updateWorld(self, *args):
        self._egg.updateWorld(*args)
    
    def observeKeyboard(self, *args):
        self._egg.observeKeyboard(*args)
    
    def unobserveKeyboard(self, *args):
        self._egg.unobserveKeyboard(*args)
    
    def observeMouse(self, *args):
        self._egg.observeMouse(*args)
    
    def unobserveMouse(self, *args):
        self._egg.unobserveMouse(*args)
    
    def hatch(self, *args):
        self._egg.run(*args)
        
    def stop(self):
        self._egg.continue_pyguane = False
示例#4
0
文件: game.py 项目: MrGecko/pyguane
 def __init__(self, width, height):
     self._egg = Egg(width, height,)
     self.clock = self._egg.clock
     
     self.physic_world = PhysicWorld(Rect(-width, -height, width * 3, height * 3))
     self.state_manager = StateManager()
     
     self.sprite_factory = SpriteFactory()
     self._go_librarian = Librarian()
     Window().bgd = "grey"
     
     @self.renderer(Window().surface)
     def renderGame(surface):
         
         if self.physic_world.debug:
             color = self.physic_world.DEBUG_COLOR
             for b in self.physic_world.world:
                 x, y = b.position
                 for fixture in b:
                     vertices = [(vx + x, vy + y) for vx, vy in fixture.shape.vertices]
                     polygon(surface, vertices, color)
             displayFlip()
             
         return self.sprite_factory.draw(surface, Window().bgd)