Ejemplo n.º 1
0
 def __init__(self, animator, pos, vel=(0,0), accel=(0,0), radius=0):
     #Flags the object for removal from the game
     self.expired = False
     self.x, self.y = pos
     self.dx, self.dy = vel
     self.ddx, self.ddy = accel
     self.doNotDraw = False
     #radius defines the size of hit-circle for the purposes of collision detection
     self.radius = radius
     #animation will change based on which direction the entity is moving in
     self.curdir = vector.getDirectionPrefix(self.dx,self.dy)
     
     self.animator = animator
     if animator is not None: self.animator.setAnimation('i')
     self.opacity = 255
Ejemplo n.º 2
0
    def draw(self, frame, surface):
        '''Draw the current frame of animation to a give surface'''
        if self.opacity <= 0 or not self.animator or self.doNotDraw:
            return
        sprite = self.getCurrentSprite(frame)
        width, height = sprite.get_size()
        if self.opacity >= 255:
            surface.blit(sprite, (self.x-width/2, self.y-height/2))
        else:
            graphics.blit_alpha(surface, sprite, (self.x-width/2, self.y-height/2), self.opacity)

        
        newdir = vector.getDirectionPrefix(self.dx,self.dy)
            
        if self.curdir != newdir:
            self.curdir = newdir
            self.animator.setAnimation(newdir)