Ejemplo n.º 1
0
    def __init__(self, position, image, aim=0, weight=1, thrust=3,
    maxSpeed=6, rotationspeed=0.02, weap=None):
        """Creates a new Boid

        aim - a Vector2D of the boid's initial aim in radians
        weight - the boid's weight
        image - a Surface representing the Boid
        rect - the rect representing the hitbox and position of the boid"""
        LocalSprite.__init__(self)
        assert(weap is not None)
        self.image = image
        self.originalimage = image
        self.radius = max(image.get_width()/3, image.get_height()/3)
        print "Radius = " + str(self.radius)
        self.rect = image.get_rect()
        self.position = position
        self.aim = aim
        self.momentum = Vector2D(0,0)
        self.weight = weight
        self.thrust = thrust
        self.iscontrolled = False #deprecate
        self.islocked = False
        self.maxSpeed = maxSpeed
        self.rotationspeed = rotationspeed
        self.statusEffects=[]
        self.weapon = weap
Ejemplo n.º 2
0
    def __init__(self, position=None, heading=None, image=None, size=1, 
                 route=None, lifetime=300, payload=None):
        """Creates a new shot.

        position - a Vector2D of the shot's position
        heading - a Vector2D of the boid's initial heading
        size - the size of the shot 
        route - a route object representing the shot's behavior
        lifetime - how long it takes the shot to expire
        payload - a function that takes a shot and a target"""
        assert(position is not None)
        assert(heading is not None)
        assert(payload is not None)
        assert(route is not None)
        LocalSprite.__init__(self, position)
        self.heading = heading # V2D
        self.position = position # V2D
        self.size = size
        self.age = 0.0
        self.lifetime=lifetime
        self.payload=payload

        if image == None: #TODO: crash here
            image = pygame.Surface((5* size, 5 * size))
            image.fill((0,255,0))
            image.convert()

        self.image = image
        self.rect = image.get_rect(center=(position.x,position.y))
        self.originalimage = image
        
        if route == None:
            self.route = advance()
        else:
            self.route = route