大球吃小球BUG修改
球在边界附近半径增大时(吃掉小球),可能会使球在50ms内无法运动回边界内,导致球不断的在边界上改变速度(迷之抖动233)pull/331/head
parent
24048b2e1b
commit
507d8c4ff2
|
@ -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):
|
||||
"""吃其他球"""
|
||||
|
|
Loading…
Reference in New Issue