diff --git a/Day01-15/10.图形用户界面和游戏开发.md b/Day01-15/10.图形用户界面和游戏开发.md index ae65624..05d4bc6 100644 --- a/Day01-15/10.图形用户界面和游戏开发.md +++ b/Day01-15/10.图形用户界面和游戏开发.md @@ -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): """吃其他球"""