Commit d866f7ab authored by gem2578's avatar gem2578 Committed by gem2578

Fix collision

parent 6460a0cd
......@@ -46,7 +46,7 @@ class Ball_Sprite(rs.Round):
self.rect.move_ip(self.force)
while self.collide():
back = (self.force * - 1).normalize()
self.rect.move_ip(back)
self.rect.move_ip(self.round_vector2(back))
self.force = pygame.math.Vector2(0,0)
def reset(self):
......
......@@ -33,7 +33,7 @@ class Player(rs.Round):
self.rect.move_ip(move)
while self.collide():
back = (move * - 1).normalize()
self.rect.move_ip(back)
self.rect.move_ip(self.round_vector2(back))
def collide(self):
for player in self.self_team:
......
......@@ -10,3 +10,8 @@ class Round(pygame.sprite.Sprite):
self.radius = int(diameter/2)
pygame.draw.circle(self.image, colour, self.rect.center , self.radius, 0)
self.mask = pygame.mask.from_surface(self.image)
def round_vector2(self, vect):
x = round(vect[0])
y = round(vect[1])
return pygame.math.Vector2(x,y)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment