Try to crash two balls together.
(self, ball)
| 95 | self.rad = radius |
| 96 | |
| 97 | def crash(self, ball): |
| 98 | 'Try to crash two balls together.' |
| 99 | p = ball.pos - self.pos |
| 100 | a = abs(p) |
| 101 | if a <= self.rad + ball.rad: |
| 102 | v = self.vel - ball.vel |
| 103 | s = _sub(_ang(p), _ang(v)) |
| 104 | if s < _PI_D_2: |
| 105 | e = p * (_math.cos(s) * abs(v) / a) |
| 106 | ball.err += e |
| 107 | self.err -= e |
| 108 | |
| 109 | def move(self, frames_per_second): |
| 110 | 'Update the ball\'s position.' |