-
Notifications
You must be signed in to change notification settings - Fork 5
/
carre_joueur.py
48 lines (41 loc) · 1.01 KB
/
carre_joueur.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
48
class CarreJoueur:
def __init__(self, x0, y0, x1, y1, tag="joueur", couleur="red"):
self.x0 = x0
self.y0 = y0
self.x1 = x1
self.y1 = y1
self.tag = tag
self.couleur = couleur
def go_down(self):
x = 0
y = 10
m = (self.tag, x, y)
self.y0 += y
self.y1 += y
return m
def go_up(self):
x = 0
y = -10
m = (self.tag, x, y)
self.y0 += y
self.y1 += y
return m
def go_left(self):
x = -10
y = 0
m = (self.tag, x, y)
self.x0 += x
self.x1 += x
return m
def go_right(self):
x = 10
y = 0
m = (self.tag, x, y)
self.x0 += x
self.x1 += x
return m
def display(self):
print(self.x0, self.y1, self.x1, self.y1)
def draw(self, canvas):
id = canvas.create_rectangle(self.x0, self.y0, self.x1, self.y1, fill=self.couleur, tags=(self.tag))
return id