예제 #1
0
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(GATHERER_SIZE,GATHERER_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = GATHERER_SPEED
        self.stateMachine = StateMachine(self, Search())

        self.goody = None
예제 #2
0
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(ENEMY_SIZE, ENEMY_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = ENEMY_SPEED
        self.stateMachine = StateMachine(self, Sneak())

        self.health = ENEMY_HEALTH
예제 #3
0
class Gatherer(pygame.sprite.Sprite):
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(GATHERER_SIZE,GATHERER_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = GATHERER_SPEED
        self.stateMachine = StateMachine(self, Search())

        self.goody = None
        
    def update(self):
        self.stateMachine.update()
        width, height = self.world.screen.get_size()
        angle = N.arctan2(self.heading[1],self.heading[0])*180.0/N.pi
        self.frame = int((angle % 360)/10.0)
        self.image = self.images[self.frame]
        self.pos += self.heading*self.speed
        if self.pos[0] < 0:
            self.pos[0] = 0
            self.heading[0] = -self.heading[0]
        if self.pos[0] > width:
            self.pos[0] = width
            self.heading[0] = -self.heading[0]
        if self.pos[1] < 0:
            self.pos[1] = 0
            self.heading[1] = - self.heading[1]
        if self.pos[1] > height:
            self.pos[1] = height
            self.heading[1] = - self.heading[1]

        self.rect.center = self.pos
예제 #4
0
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(ENEMY_SIZE, ENEMY_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = ENEMY_SPEED
        self.stateMachine = StateMachine(self, Sneak())

        self.health = ENEMY_HEALTH
예제 #5
0
class Enemy(pygame.sprite.Sprite):
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(ENEMY_SIZE, ENEMY_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = ENEMY_SPEED
        self.stateMachine = StateMachine(self, Sneak())

        self.health = ENEMY_HEALTH
        
    def update(self):
        self.stateMachine.update()
        self.pos += self.speed*self.heading
        self.rect.center = self.pos
        angle = N.arctan2(self.heading[1],self.heading[0])*180.0/N.pi
        self.frame = int((angle % 360)/10.0)
        self.image = self.images[self.frame]
예제 #6
0
class Enemy(pygame.sprite.Sprite):
    def __init__(self, pos, world, *groups):
        pygame.sprite.Sprite.__init__(self, *groups)
        self.images = GM.makeimage.rotating_arrow(ENEMY_SIZE, ENEMY_COLOR)
        self.frame = 0
        self.image = self.images[self.frame]
        self.rect = self.image.get_rect()
        self.pos = vector(pos)
        self.rect.center = self.pos
        self.world = world

        self.heading = randomNormalVector()
        self.speed = ENEMY_SPEED
        self.stateMachine = StateMachine(self, Sneak())

        self.health = ENEMY_HEALTH

    def update(self):
        self.stateMachine.update()
        self.pos += self.speed * self.heading
        self.rect.center = self.pos
        angle = N.arctan2(self.heading[1], self.heading[0]) * 180.0 / N.pi
        self.frame = int((angle % 360) / 10.0)
        self.image = self.images[self.frame]