我正在用python制作破砖游戏,并且试图弄清楚如何使球反弹。 (我不能使用pygame)
它不是从桨上弹起,而是从应该桨上的边界弹起(如果有意义)。
#brick collision
for i in range (numRects):
if allRectInfo[i][2] == True:
rect (allRectInfo[i][0], allRectInfo[i][1], rectW, rectH)
if allRectInfo[i][1]-25 <= y <= allRectInfo[i][1]+74 and
allRectInfo[i][0]-5.5 <= x <= allRectInfo[i][0]+150:
incry = incry * (-1)
#paddle collision
if x >= RectX + RectWidth >= x:
incrx = incrx * (-1)
if y <= RectY - RectHeight <= y:
incry = incry * (-1)