Exemplo n.º 1
0
 def on_setup(self, x, y, dx, dy):
     self.position = [x, y]
     self.speed = 100 + 100 * random.random()
     self.direction = [dx, dy]
     self.movement = normvec((dx, dy), self.speed)
     self.rotation = math.atan2(dx, dy) * 180 / math.pi - 90
     self.sprite = self.make_sprite()
Exemplo n.º 2
0
    def handle_input(self, dt):
        if self.keys[key.E]:
            self.enemies.add(self.create_entity(Enemy, *self.player.position))
        if self.keys[key.D]:
            import pdb; pdb.set_trace()

        if self.keys[key.SPACE]:
            bx, by = self.player.last_move
            if bx or by:
                bx, by = normvec((bx, by), 200)
                bx += (0.5 - random.random()) * 100
                by += (0.5 - random.random()) * 100
                x, y = self.player.position
                if self.player.face == 'up':     y += 10
                if self.player.face == 'down':   y -= 10
                if self.player.face == 'right':  x += 15
                if self.player.face == 'left':   x -= 15
                bullet = self.create_entity(Fireball, x, y+10, bx, by)