-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
55 lines (37 loc) Β· 1.2 KB
/
test.py
File metadata and controls
55 lines (37 loc) Β· 1.2 KB
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
48
49
50
51
52
53
54
55
"""
licenced under the GNU Affero General Public License v3.0 (AGPL3)
This file is used for testing the PyDraw Library.
"""
from pydraw import *
pen = PyPen("square chaos")
pen.initialise("white", 2, Speed.INSTANT, "black")
# ββ squares βββββββββββββββββββββββββββββ
s1 = Square(50)
s1.move_to(-100, -50)
s2 = Square(40)
s2.move_to(80, 60)
s3 = Square(70)
s3.move_to(0, 0)
# ββ motion ββββββββββββββββββββββββββββββ
m1 = Motion(s1, pen, vx=3, vy=2)
m2 = Motion(s2, pen, vx=-2, vy=3.5)
m3 = Motion(s3, pen, vx=1.5, vy=-2.5)
# ββ loop ββββββββββββββββββββββββββββββββ
while True:
pen.clear()
pen.draw(s1, color="white", fill=True)
pen.draw(s2, color="red", fill=True)
pen.draw(s3, color="blue", fill=True)
m1.update()
m2.update()
m3.update()
# bounce logic
if not m1.is_on_screen():
m1.vx *= -1
m1.vy *= -1
if not m2.is_on_screen():
m2.vx *= -1
m2.vy *= -1
if not m3.is_on_screen():
m3.vx *= -1
m3.vy *= -1