cue.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:pool 作者: max-kov 项目源码 文件源码
def update_cue(self, game_state, initial_mouse_dist, events):
        # updates cue position
        current_mouse_pos = events["mouse_pos"]
        displacement_from_ball_to_mouse = self.target_ball.ball.pos - current_mouse_pos
        self.update_cue_displacement(current_mouse_pos, initial_mouse_dist)
        prev_angle = self.angle
        # hack to avoid div by zero
        if not displacement_from_ball_to_mouse[0] == 0:
            self.angle = 0.5 * math.pi - math.atan(
                displacement_from_ball_to_mouse[1] / displacement_from_ball_to_mouse[0])
            if displacement_from_ball_to_mouse[0] > 0:
                self.angle -= math.pi

        game_state.redraw_all(update=False)
        self.draw_lines(game_state, self.target_ball, prev_angle +
                        math.pi, config.table_color)
        self.draw_lines(game_state, self.target_ball, self.angle +
                        math.pi, (255, 255, 255))
        pygame.display.flip()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号