Browse Source

Je crois que c'est fini

master
BARRAUX Arthur 3 years ago
parent
commit
063d96181e
  1. BIN
      img/faute.png
  2. BIN
      img/lance_rate.png
  3. BIN
      img/lance_reussi.png
  4. BIN
      img/passe_dec.png
  5. BIN
      img/rebond_def.png
  6. BIN
      img/rebond_off.png
  7. BIN
      img/tir_rate.png
  8. BIN
      img/tir_reussi.png
  9. 120
      main.py
  10. 37
      stat.bbm

BIN
img/faute.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

BIN
img/lance_rate.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

BIN
img/lance_reussi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
img/passe_dec.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 814 B

BIN
img/rebond_def.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
img/rebond_off.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/tir_rate.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

BIN
img/tir_reussi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

120
main.py

@ -1,6 +1,7 @@
import tkinter
from tkinter import filedialog
import os
import math
class Terrain:
def __init__(self):
@ -60,11 +61,22 @@ class Gui:
self.filemenu.add_command(label="exit", command=self.root.quit)
self.menubar.add_cascade(label="file", menu=self.filemenu)
self.action_to_show = []
# topbar
self.root.config(menu=self.menubar)
# image des actions
self.tir_reussi = tkinter.PhotoImage(file='img/tir_reussi.png')
self.tir_rate = tkinter.PhotoImage(file='img/tir_rate.png')
self.lance_reussi = tkinter.PhotoImage(file='img/lance_reussi.png')
self.lance_rate = tkinter.PhotoImage(file='img/lance_rate.png')
self.rebond_def = tkinter.PhotoImage(file='img/rebond_def.png')
self.rebond_off = tkinter.PhotoImage(file='img/rebond_off.png')
self.faute = tkinter.PhotoImage(file='img/faute.png')
self.passe_dec = tkinter.PhotoImage(file='img/passe_dec.png')
self.root.bind("<Control-o>", self.browse_open)
self.root.bind("<Control-n>", self.new)
@ -141,16 +153,29 @@ class Gui:
self.statsubmenu.add_command(label=self.team.players[3], command=lambda: self.draw_player(self.team.players[3]))
self.statsubmenu.add_command(label=self.team.players[4], command=lambda: self.draw_player(self.team.players[4]))
self.statmenu.add_cascade(label="player", menu=self.statsubmenu)
self.statmenu.add_command(label='team', command=self.draw_team)
self.statmenu.add_command(label='team', command=lambda: self.draw_player('*'))
# actions menubar
self.actionmenu = tkinter.Menu(self.menubar, tearoff=0)
self.actionmenu.add_checkbutton(0, label='tirs', background='red')
self.actionmenu.add_checkbutton(0, label='tirs', command=lambda: self.check_action('tirs'))
self.actionmenu.add_checkbutton(0, label='lance', command=lambda: self.check_action('lance'))
self.actionmenu.add_checkbutton(0, label='rebonds', command=lambda: self.check_action('rebond'))
self.actionmenu.add_checkbutton(0, label='passe', command=lambda: self.check_action('passe'))
self.actionmenu.add_checkbutton(0, label='faute', command=lambda: self.check_action('faute'))
for i in range(5):
self.actionmenu.invoke(i)
# menu contextuel des actions
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'))
self.action.add_command(label='tir réussi', command=lambda: self.action_menu('tm'))
self.action.add_command(label='tir raté', command=lambda: self.action_menu('tr'))
self.action.add_command(label='lancé franc réussi', command=lambda: self.action_menu('lfm'))
self.action.add_command(label='lancé franc raté', command=lambda: self.action_menu('lfr'))
self.action.add_command(label='faute', command=lambda: self.action_menu('f'))
self.action.add_command(label='rebond offensif', command=lambda: self.action_menu('ro'))
self.action.add_command(label='rebond défensif', command=lambda: self.action_menu('rd'))
self.action.add_command(label='passe décisive', command=lambda: self.action_menu('pd'))
# Menu contextuel des joueurs
self.menu = tkinter.Menu(self.root, tearoff = 0)
@ -163,13 +188,20 @@ class Gui:
self.bind_click = "<Button-1>"
self.bind_ctrl_s = "<Control-s>"
def check_action(self, action):
if action in self.action_to_show:
self.action_to_show.remove(action)
else:
self.action_to_show.append(action)
def changemode(self, newmode):
if self.mode != newmode:
if newmode == 'stat':
self.menubar.add_cascade(label='stat', menu=self.statmenu)
self.menubar.add_cascade(label='actions', menu=self.actionmenu)
else:
self.menubar.delete(3)
for i in range(2):
self.menubar.delete(3)
self.mode = newmode
items = self.canvas.find_all()
while len(items) > 4:
@ -192,18 +224,40 @@ class Gui:
"""enregistre temporairement l'action"""
self.clean_terrain()
# 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:
score = 2
else:
score = 3
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')
else:
self.canvas.create_oval(self.team.posx-12, self.team.posy-12, self.team.posx+12, self.team.posy+12, fill='red')
if action == 'tm':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.tir_reussi, anchor='nw')
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:
score = 2
else:
score = 3
if action == 'tr':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.tir_rate, anchor='nw')
score = 0
if action == 'lfm':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.lance_reussi, anchor='nw')
score = 1
if action == 'lfr':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.lance_rate, anchor='nw')
score = 0
if action == 'ro':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.rebond_off, anchor='nw')
score = 0
if action == 'rd':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.rebond_def, anchor='nw')
score = 0
if action == 'f':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.faute, anchor='nw')
score = 0
if action == 'pd':
self.canvas.create_image(self.team.posx-20, self.team.posy-20, image=self.passe_dec, anchor='nw')
score = 0
if self.file.temp_data == '':
self.root.title(self.file.name+' *')
self.file.temp_data += self.team.ac_player+' '+action+' '+str(score)+' '+str(self.team.posx)+' '+str(self.team.posy)+'\n'
def clean_terrain(self):
"""Nettoie le terrain"""
items = self.canvas.find_all()
@ -211,28 +265,32 @@ class Gui:
self.canvas.delete(items[-1])
items = self.canvas.find_all()
def draw_team(self, *event):
def draw_player(self, player, *event):
"""dessine les actions de toute l'équipe"""
self.clean_terrain()
for line in self.file.content[2:]:
# forme type: joueur action points x y
params = line.strip().split(' ')
if params[1] == 'marque':
self.canvas.create_oval(int(params[3])-12, int(params[4])-12, int(params[3])+12, int(params[4])+12, fill='green')
else:
self.canvas.create_oval(int(params[3])-12, int(params[4])-12, int(params[3])+12, int(params[4])+12, fill='red')
def draw_player(self, player):
"""dessine les actions d'un joueur"""
self.clean_terrain()
for line in self.file.content[2:]:
# forme type: joueur action points x y
params = line.strip().split(' ')
if params[0] == player: # nom du joueur
if params[1] == 'marque':
self.canvas.create_oval(int(params[3])-12, int(params[4])-12, int(params[3])+12, int(params[4])+12, fill='green')
else:
self.canvas.create_oval(int(params[3])-12, int(params[4])-12, int(params[3])+12, int(params[4])+12, fill='red')
if params[0] == player or player == '*': # nom du joueur
if 'tirs' in self.action_to_show:
if params[1] == 'tm':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.tir_reussi, anchor='nw')
if params[1] == 'tr':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.tir_rate, anchor='nw')
if 'lance' in self.action_to_show:
if params[1] == 'lfm':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.lance_reussi, anchor='nw')
if params[1] == 'lfr':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.lance_rate, anchor='nw')
if 'faute' in self.action_to_show and params[1] == 'f':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.faute, anchor='nw')
if 'rebond' in self.action_to_show:
if params[1] == 'ro':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.rebond_off, anchor='nw')
if params[1] == 'rd':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.rebond_def, anchor='nw')
if 'passe' in self.action_to_show and params[1] == 'pd':
self.canvas.create_image(int(params[3]), int(params[4]), image=self.passe_dec, anchor='nw')
def draw_terrain(self):
"""dessinne les lignes du terrain"""

37
stat.bbm

@ -1,15 +1,26 @@
arthur jl léandre louis alex
arthur rate 3 449 301
léandre marque 2 186 323
arthur marque 2 963 332
arthur rate 3 849 349
arthur marque 3 392 233
jl marque 2 186 283
alex marque 3 393 274
arthur rate 3 359 210
arthur marque 3 416 212
jl rate 3 448 234
alex rate 2 172 357
alex marque 3 269 292
louis marque 2 1043 277
arthur tr 3 449 301
léandre tm 2 186 323
arthur tm 2 963 332
arthur tr 3 849 349
arthur tm 3 392 233
jl tm 2 186 283
alex tm 3 393 274
arthur tr 3 359 210
arthur tm 3 416 212
jl tr 3 448 234
alex tr 2 172 357
alex tm 3 269 292
louis tm 2 1043 277
arthur f 0 464 246
arthur f 0 295 431
léandre f 0 381 407
arthur tm 3 321 264
jl tr 0 340 188
jl f 0 218 302
jl lfm 1 290 205
arthur lfr 0 765 215
alex ro 0 776 228
alex rd 0 570 399
arthur pd 0 228 420

Loading…
Cancel
Save