大球吃小球BUG修改

球在边界附近半径增大时(吃掉小球),可能会使球在50ms内无法运动回边界内,导致球不断的在边界上改变速度(迷之抖动233)
pull/331/head
yucy207 2019-10-15 16:37:31 +08:00 committed by GitHub
parent 24048b2e1b
commit 507d8c4ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -249,12 +249,14 @@ class Ball(object):
"""移动"""
self.x += self.sx
self.y += self.sy
if self.x - self.radius <= 0 or \
self.x + self.radius >= screen.get_width():
self.sx = -self.sx
if self.y - self.radius <= 0 or \
self.y + self.radius >= screen.get_height():
self.sy = -self.sy
if self.x - self.radius <= 0:
self.sx = abs(self.sx)
if self.x + self.radius >= screen.get_width():
self.sx = -abs(self.sx)
if self.y - self.radius <= 0:
self.sy = abs(self.sy)
if self.y + self.radius >= screen.get_height():
self.sy = -abs(self.sy)
def eat(self, other):
"""吃其他球"""