Esempio n. 1
0
class enemy_spawner(Entity):
    def __init__(self):
        Entity.__init__(self)
        # DEM TWEENS MAN, DEM TWEENS
        self.spawn_tween = NumTween(self.increase_chance)
        self.timer_reset = 1

        # set up the random sawn chances
        self.spawn_chance = [0.005, 0.003, 0.001]
        self.enemies = [enemies.one, enemies.two, enemies.three]

        self.difficulty = 2

        self.increase_chance()

    # Increase enemy spawn chance every second. slooooowly adds up.
    def increase_chance(self):
        for i in range(len(self.spawn_chance)):
            self.spawn_chance[i] += 0.00005
        self.spawn_tween.tween(0, 1, self.timer_reset)      

    def update(self):
        self.spawn_tween.updateTween()

        # Ok, i'm too tired now to bother explaining this beauty. work it out for yourself, damnit.
        for i in range(len(self.spawn_chance)):
            if random.random() <= self.spawn_chance[i]:
                self.world.add(self.enemies[i](self.difficulty))
                print "spawning %s - %s with a chance of %s" % (i,self.enemies[i],self.spawn_chance[i],)
Esempio n. 2
0
class three(enemy):
    def __init__(self, diff):
        enemy.__init__(self, 10, 10, Image('./assets/e_3.png'))
        self.switch_time = self.get_speed(diff)/2
        self.switch_tween = NumTween(self.switch)
        self.switch_tween.value = self.get_speed(diff)

        self.dspeed = self.get_speed(diff)*1.2

        self.points = 30

        self.switch()

    #uses a tween to determine when it should switch directions
    def switch(self):
        self.switch_tween.tween(self.switch_tween.value, -self.switch_tween.value, self.switch_time)

    def move(self):
        self.switch_tween.updateTween()

        self.distance -= self.dspeed
        self.angle += self.switch_tween.value