python pygame.sprite.spritecollide中的一段碰撞检测
ifpygame.sprite.spritecollide(paddle,ballGroup,False):p_tl_y_min_x=paddle.rect.toplef...
if pygame.sprite.spritecollide(paddle, ballGroup, False):
p_tl_y_min_x = paddle.rect.topleft[1] - paddle.rect.topleft[0]
p_tr_y_plus_x = paddle.rect.topright[1] + paddle.rect.topright[0]
b_br_y_min_x = myBall.rect.bottomright[1] - myBall.rect.bottomright[0]
b_bl_y_plus_x = myBall.rect.bottomleft[1] + myBall.rect.bottomleft[0]
这一段是在检测什么 那些topleft,topright是什么意思
if (b_br_y_min_x > p_tl_y_min_x or b_bl_y_plus_x > p_tr_y_plus_x):
# "beside" the paddle, so bounce x
myBall.speed[0] = -myBall.speed[0]
else:
# "above" the paddle, so bounce y
myBall.speed[1] = -myBall.speed[1] 展开
p_tl_y_min_x = paddle.rect.topleft[1] - paddle.rect.topleft[0]
p_tr_y_plus_x = paddle.rect.topright[1] + paddle.rect.topright[0]
b_br_y_min_x = myBall.rect.bottomright[1] - myBall.rect.bottomright[0]
b_bl_y_plus_x = myBall.rect.bottomleft[1] + myBall.rect.bottomleft[0]
这一段是在检测什么 那些topleft,topright是什么意思
if (b_br_y_min_x > p_tl_y_min_x or b_bl_y_plus_x > p_tr_y_plus_x):
# "beside" the paddle, so bounce x
myBall.speed[0] = -myBall.speed[0]
else:
# "above" the paddle, so bounce y
myBall.speed[1] = -myBall.speed[1] 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询