-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcoin.py
32 lines (27 loc) · 938 Bytes
/
coin.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
import os
COLOR_YELLOW = "yellow"
class Coin:
def __init__(self, fichier_coin):
self.tab_coins = []
self.fichier_coin = fichier_coin
self.load_coins()
def load_coins(self):
all_coins = list()
dir_path = os.path.dirname(os.path.realpath(__file__))
path_file = os.path.join(dir_path, self.fichier_coin)
with open(path_file, 'r') as f:
content = f.readlines()
content = content[1:]
for line in content:
if line.strip() == '':
continue
t = [int(x) for x in line.strip().split(',')]
all_coins.append(t)
self.tab_coins = all_coins
def draw(self, canvas):
tab_id = list()
for line in self.tab_coins:
x, y= line
id = canvas.create_oval(x,y,x+15,y+15,fill=COLOR_YELLOW)
tab_id.append(id)
return tab_id