| 17 | |
| 18 | |
| 19 | class Ball(): |
| 20 | def __init__(self, x, y, r, graph_elem, *args, **kwargs): |
| 21 | mass = 10 |
| 22 | # Create a Body with mass and moment |
| 23 | self.body = pymunk.Body( |
| 24 | mass, pymunk.moment_for_circle(mass, 0, r, (0, 0))) |
| 25 | self.body.position = x, y |
| 26 | # Create a box shape and attach to body |
| 27 | self.shape = pymunk.Circle(self.body, r, offset=(0, 0)) |
| 28 | self.shape.elasticity = 0.99999 |
| 29 | self.shape.friction = 0.8 |
| 30 | self.gui_circle_figure = None |
| 31 | self.graph_elem = graph_elem |
| 32 | |
| 33 | def move(self): |
| 34 | self.graph_elem.RelocateFigure( |
| 35 | self.gui_circle_figure, self.body.position[0], ball.body.position[1]) |
| 36 | |
| 37 | |
| 38 | class Playfield(): |