Salut !!

J'aurai besoin d'aide svp. J'ai un projet en progra (python)qui est de créer un jeu à partir d'un squelette (le jeu c'est flood) mais j'ai énormément de mal étant donné que j'e n'ai pas un très très bon niveau et que je suis à peine en L1.

Y'aurait-il une âme charitable qui accepterait de m'aider afin de venir à bout de ce projet ?

Merci d'avance, je compte sur vous !!

flood1.0.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# ==============================================================================
"""FLOOD : 2-player implementation of the 'Flood' game"""
# ==============================================================================
__author__  = "Flood"
__version__ = "1.0" #  version
__date__    = "2022-05-08"
# ==============================================================================
from ezTK import *
from random import randrange as rr
# ------------------------------------------------------------------------------
def config(rows=18, cols=12, colors=6, nameA='Player A', nameB='Player B'):
  """create the config window and pack the widgets"""
  global win,row,col; fontA, fontB = 'Arial 12', 'Arial 20 bold'
  row=rows
  col=cols
  win=Win(title='FLOOD', border=1, op=1)
 
  Label(win,text='CONFIGURATION',font=fontB, grow=False, border=5, bg='black', fg= 'white')
  frame=Frame(win,fold=2)
 
 
  lA=Label(frame,text='Name of player A :',grow=False)
  win.nameA=Entry(frame, width=10); win.nameA.state=nameA
 
  lB=Label(frame,text='Name of player B :',grow=False)
  win.nameB=Entry(frame, width=10); win.nameB.state=nameB
 
  lR=Label(frame,text='Number of rows :',grow=False,width=15 )
  win.rowscale = Scale(frame, scale=(1,36), length=200, flow='E',state=rows)
 
  lC=Label(frame,text='Number of cols :',grow=False,width=15)
  win.colscale = Scale(frame, scale=(1,54), length=200, flow='E',state=cols)
 
  lc=Label(frame,text='Number of colors :',grow=False,width=15)
  win.colorscale = Scale(frame, scale=(1,8), length=200, flow='E',state=colors)
 
  Button(win,text='START',font=fontB, grow=False, border=5, bg='black', fg= 'white', command=game)
 
 
# ------------------------------------------------------------------------------
def game():
  """create the game window and pack the widgets"""
  global win,row,col; fontA, fontB = 'Arial 16 bold', 'Arial 36 bold'
  rows, cols, colors, nameA, nameB = win.rowscale.state, win.colscale.state, win.colorscale.state, win.nameA.state, win.nameB.state
  win.exit()
  colors = ('#F00','#0F0','#00F','yellow','magenta','cyan','orange','grey')
  win = Win(title='FLOOD', bg='white', op=2, grow=False, flow='ES')
  frA=Frame(win, grow=False)
  Label(frA, text=nameA, grow=False, font=fontA)
  frA1=Frame(frA, fold=4, grow=False)
  frA2=Frame(frA)
  frA3=Frame(frA)
  frB=Frame(win, fold=cols)
  lettres = ('A','Z','E','R','Q','S','D','F')
  for n in range (len(colors)):
    Label(frA1, text=lettres[n],bg=colors[n], font=fontA, border=2, width=2)
  Label(frA2, text='Steps :',grow=False, font=fontA, border=2,width=10)
  Label(frA3, text='Score :',grow=False, font=fontA, border=2,width=10)
 
  for loop in range(rows*cols):
    Brick(frB, height=64, width=64, border=2, bg=colors, state=0)
 
 
  states = frB[0][0].states # get number of states for each grid cell
  for r in range(rows):
    for c in range(cols):
      frB[r][c].state = rr(states) # set selected widget to random state
 
 
  frC=Frame(win, grow=False)
  frC1=Frame(frC)
  frC2=Frame(frC)
  frC3=Frame(frC, fold=4, grow=False)
  Label(frC1, text='Score :',grow=False, font=fontA, border=2,width=10)
  Label(frC2, text='Steps :',grow=False, font=fontA, border=2,width=10)
  lettres2=('U','I','O','P','J','K','L','M')
 
  for j in range (len(colors)):
    Label(frC3, text=lettres2[j],bg=colors[j], font=fontA, border=2,width=2)
  Label(frC, text=nameB, grow=False, font=fontA)
 
# ------------------------------------------------------------------------------
def on_key(widget, code, mods):
  """callback function for all keyboard events"""
  if code not in ('A','Z','E','R','Q','S','D','F'): return # wrong key (= not a directional key)
  move(code) # apply move for frog in selected direction
# ------------------------------------------------------------------------------
def move(direction):
  """find empty cell and move its neighboring frog in provided direction"""
  row, col, colors = win.rowscale.state, win.colscale.state, win.colorscale.state # create local shortcuts
 
 
 
 
 
 
  # TODO : get current player and seed cell from code of key pressed
  # TODO : call 'flood' starting with seed cell of current player
  # TODO : update score and steps values on window
  # TODO : call 'victory' if current player fulfils victory condition
# ------------------------------------------------------------------------------
def flood(row, col, old, new):
  """apply recursive flood fill algorithm using (row,col) as seed cell"""
  # TODO : check these web pages to get info about the flood fill algorithm :
  # - https://en.wikipedia.org/wiki/Flood_fill
  # - https://fr.wikipedia.org/wiki/Algorithme_de_remplissage_par_diffusion
# ------------------------------------------------------------------------------
def victory():
  """play victory animation"""
  # TODO : show winner by blinking his score on window
# ==============================================================================
if __name__ == "__main__":
  config()
# ==============================================================================