-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path800x80.py
47 lines (34 loc) · 969 Bytes
/
800x80.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#Thonny IDE
#Imported mode for py5 on
import pymunk as pm
space = pm.Space()
shapes = []
def settings():
size(800, 80)
def setup():
space.gravity = (0, 600)
shapes.extend((
pm.Segment(space.static_body, (0, 0), (800, 0), 1),
pm.Segment(space.static_body, (0, 0), (0, 80), 1),
pm.Segment(space.static_body, (0, 80), (800, 80), 1),
pm.Segment(space.static_body, (800, 0), (800, 800), 1)
))
for shp in shapes:
shp.elasticity = 0.8
space.add(shp)
def draw():
background(000)
mass = 10
moi = pm.moment_for_circle(mass, 0, 5)
body = pm.Body(mass, moi)
body.position = (1, 1)
shp = pm.Circle(body, 5, (0, 0))
shp.friction = 0.5
shp.elasticity = 1
shapes.append(shp)
space.add(body, shp)
for shp in shapes:
no_stroke()
x, y = shp.body.position
circle(x, y, 10)
space.step(0.02)