Example #1
0
            # rotate head
            #torso_vector = (me.bodies[me.bodies_enum["HEAD"]].position - me.bodies[me.bodies_enum["TORSO"]].position)
            #torso_rotate_angle = torso_vector.angle
            #elif event.key == pygame.K_q:
            #    me.rotate(CHARACTER_ANGULAR_VELOCITY_LIMIT, "TORSO")
            #elif event.key == pygame.K_e:
            #    me.rotate(-CHARACTER_ANGULAR_VELOCITY_LIMIT, "TORSO")

        elif event.type == pygame.MOUSEMOTION:
            # update location of pointer
            pointer_body.position = pygame_util.get_mouse_pos(screen)
            # update angle of pointer
            pointer_body.angle = (pointer_body.position - me.gun.body.position).angle

        elif event.type == pygame.MOUSEBUTTONDOWN:
            me.shoot_gun(space)

    for c in [c for c in space.characters if c.cid != PLAYER_ID]:  # eliminate player
        #print c.cid, "running basic ai"
        c.basic_ai(space)

    # prune a bullet if the bullet is outside the screen or has stopped moving
    for b in space.bullets[:]:  # iterate over a copy of the list
        if fabs(b.body.position.x - SCREEN_SIZE) > SCREEN_SIZE or \
           fabs(b.body.position.y - SCREEN_SIZE) > SCREEN_SIZE:
            space.remove_bullet(b)

        #print b.body.velocity.length
        if b.body.velocity.length < BULLET_PRUNING_VELOCITY:
            space.remove_bullet(b)