Browse Source

ajout

master
BARRAUX Arthur 3 years ago
parent
commit
1a96ac7d30
  1. 23
      main.py
  2. 8
      stat.txt

23
main.py

@ -15,28 +15,25 @@ class Team:
self.posx, self.posy = 0,0 # coo de la dernière action
self.ac_player = 0 # dernier joueur
class Gui:
def __init__(self, ):
self.terrain = Terrain()
self.team = Team()
self.list_button_menu = []
self.win = tkinter.Tk()
self.canvas = tkinter.Canvas(self.win, width=self.terrain.width, height=self.terrain.height, background='#bbb')
self.root = tkinter.Tk()
self.canvas = tkinter.Canvas(self.root, width=self.terrain.width, height=self.terrain.height, background='#bbb')
self.canvas.pack()
# menu contextuel des actions
self.action = tkinter.Menu(self.win, tearoff=0)
self.action = tkinter.Menu(self.root, tearoff=0)
self.action.add_command(label='marque', command=lambda: self.action_menu('marque'))
self.action.add_command(label='rate', command=lambda: self.action_menu('rate'))
# Menu contextuel des joueurs
self.menu = tkinter.Menu(self.win, tearoff = 0)
self.menu = tkinter.Menu(self.root, tearoff = 0)
self.menu.add_command(label=self.team.players[0], command=lambda: self.show_sub_menu(self.team.players[0]))
self.menu.add_command(label=self.team.players[1], command=lambda: self.show_sub_menu(self.team.players[1]))
self.menu.add_command(label=self.team.players[2], command=lambda: self.show_sub_menu(self.team.players[2]))
@ -57,12 +54,16 @@ class Gui:
self.action.grab_release()
def action_menu(self, action):
# test si l'action est dans la liste des 3 points
if ((self.team.posx-0)**2) + ((self.team.posy-self.terrain.height/2)**2) <= self.terrain.three_points**2 or ((self.team.posx-self.terrain.width)**2) + ((self.team.posy-self.terrain.height/2)**2) <= self.terrain.three_points**2:
print('dunk')
if action == 'marque':
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='green')
# with open('stat.txt', 'a') as f:
else:
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='red')
with open('stat.txt', 'a') as f:
line = self.team.ac_player+' '+action+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n'
f.write(line) # écriture de l'action dans le fichier
def draw_terrain(self):
# ligne des 3 points
@ -80,6 +81,6 @@ class Gui:
gui = Gui()
gui.draw_terrain()
gui.win.bind("<Button-1>", gui.context_menu)
gui.root.bind("<Button-1>", gui.context_menu)
gui.win.mainloop()
gui.root.mainloop()

8
stat.txt

@ -0,0 +1,8 @@
arthur marque 768 339
léandre rate 819 402
jl rate 637 344arthur rate 439 302
louis marque 185 320
jl marque 192 353
jl rate 299 361
arthur marque 3 559
arthur rate 34 541
Loading…
Cancel
Save