Avancement du projet 21 mai 2023

This commit is contained in:
Adrien Bourmault 2023-05-21 16:45:56 +02:00
parent d75020a4a6
commit 3015c8c998
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
25 changed files with 128 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,6 +2,11 @@
import random, time
N = 0
E = 1
S = 2
O = 3
## Gestion de partie
def créer_salle_random():

12
maps.py
View File

@ -4,6 +4,8 @@ import random, time
## Gestion des maps
NOM_MAP = ""
def créer_salle(forme_salle):
"""
Créer une salle aléatoire (N,E,S,O)
@ -42,10 +44,14 @@ def charger(fichier, donjon, dragons, aventurier):
@params fichier, chemin d'accès à un fichier
@return 1 ou None
"""
global NOM_MAP
donjon.clear()
dragons.clear()
# Lecture fichier brut
NOM_MAP = fichier
# Lecture fichier brut
contenu = ""
with open(fichier, 'r') as fichier:
contenu = fichier.read()
@ -67,13 +73,13 @@ def charger(fichier, donjon, dragons, aventurier):
# Déclaration de l'aventurier
if "A" in declaration:
cible, x, y = declaration.split(" ")
aventurier["position"] = (x,y)
aventurier["position"] = (int(x),int(y))
aventurier["niveau"] = 1
# Déclaration d'un dragon
elif "D" in declaration:
cible, x, y, niveau = declaration.split(" ")
dragons.append({ 'position' : (x,y), 'niveau' : niveau })
dragons.append({ 'position' : (int(x),int(y)), 'niveau' : int(niveau) })
return 1
except Exception as e:

BIN
media/salle_0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
media/salle_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
media/salle_1_E.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
media/salle_1_N.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
media/salle_1_O.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
media/salle_1_S.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
media/salle_2_E_S.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_2_N_E.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_2_N_S.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_2_O_E.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_2_O_N.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_2_S_O.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
media/salle_3_E_S_O.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
media/salle_3_N_E_S.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
media/salle_3_O_N_E.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
media/salle_3_S_O_N.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
media/salle_4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -9,7 +9,7 @@
# - Intention : cible le dragon le plus fort accessible (orgueil)
#
# Doc FLTK : https://antoinemeyer.frama.io/fltk/
import random, time, fltk, os
import random, fltk, time, os, importlib
import maps
import game
@ -95,10 +95,12 @@ def selection_menu():
event = fltk.attend_ev()
if "Quitte" in fltk.type_ev(event):
fltk.efface_tout()
fltk.ferme_fenetre()
return None
if "Touche" in fltk.type_ev(event) and "Escape" in fltk.touche(event):
fltk.efface_tout()
fltk.ferme_fenetre()
return None
@ -116,6 +118,7 @@ def selection_menu():
if x_n+y_n*4 < 0 or x_n+y_n*4 >= len(list_maps):
continue
fltk.efface_tout()
fltk.ferme_fenetre()
return "./maps/" + list_maps[x_n+y_n*4]
@ -128,10 +131,118 @@ def run_game():
@params void
@return void
"""
pass
LARGEUR_FENETRE = 800
HAUTEUR_FENETRE = 800
fltk.cree_fenetre(LARGEUR_FENETRE, HAUTEUR_FENETRE)
fltk.texte(LARGEUR_FENETRE/2, HAUTEUR_FENETRE/20,
"Wall is You : map {}".format(maps.NOM_MAP),
couleur="black",
taille=30,
ancrage='center')
fltk.texte(LARGEUR_FENETRE/2, HAUTEUR_FENETRE/10,
"Cliquez sur une salle pour entraîner sa rotation. "
"Appuyez sur Entrée pour valider votre tour.",
couleur="black",
taille=10,
ancrage='center')
fltk.texte(LARGEUR_FENETRE/2, HAUTEUR_FENETRE/8,
"Tapez Echap pour quitter le jeu",
couleur="green",
taille=10,
ancrage='center')
modeles = {
(True,)*4 : "salle_4",
(False, False, False, True) : "salle_1_O",
(False, True, False, False) : "salle_1_E",
(False, False, True, False) : "salle_1_S",
(True, False, False, False) : "salle_1_N",
(False, True, True, False) : "salle_2_E_S",
(False, False, True, True) : "salle_2_S_O",
(True, False, False, True) : "salle_2_O_N",
(True, True, False, False) : "salle_2_N_E",
(True, False, True, False) : "salle_2_N_S",
(False, True, False, True) : "salle_2_O_E",
(False, True, True, True) : "salle_3_E_S_O",
(True, True, False, True) : "salle_3_O_N_E",
(True, True, True, False) : "salle_3_N_E_S",
(True, False, True, True) : "salle_3_S_O_N"
}
while True:
fltk.mise_a_jour()
# Affichage donjon
for i in range(6):
for j in range(6):
fltk.image( 100+i*100,
150+j*100,
'media/{}.png'.format(modeles[donjon[i][j]]),
ancrage = "nw",
largeur=100,
hauteur=100,
tag="{},{}".format(i,j))
# Affichage aventurier
fltk.image( 110+aventurier["position"][0]*100,
170+aventurier["position"][1]*100,
'media/Knight_s.png',
ancrage = "nw",
largeur=39,
hauteur=50)
# Affichage dragon
for dragon in dragons:
fltk.image( 143+dragon["position"][0]*100,
170+dragon["position"][1]*100,
'media/Dragon_s.png',
ancrage = "nw",
largeur=39,
hauteur=50)
event = fltk.attend_ev()
if "Quitte" in fltk.type_ev(event):
for i in range(6):
for j in range(6):
fltk.efface("{},{}".format(i,j))
fltk.ferme_fenetre()
return None
if "Touche" in fltk.type_ev(event) and "Escape" in fltk.touche(event):
for i in range(6):
for j in range(6):
fltk.efface("{},{}".format(i,j))
fltk.ferme_fenetre()
fltk.ferme_fenetre()
return None
if "Touche" in fltk.type_ev(event) and "Return" in fltk.touche(event):
print("Validation tour")
intent = game.intention(donjon, aventurier["position"], dragons)
print(intent)
if "ClicGauche" in fltk.type_ev(event):
# XXX à améliorer
x = fltk.abscisse(event)
y = fltk.ordonnee(event)
print("Clic sur coords ({},{})".format(x,y))
if x > 100 and y > 150 and x < 700 and y < 750:
x_n = int((x - 100) / 100)
y_n = int((y - 150) / 100)
print("Rotation de salle ({},{}) demandée".format(x_n, y_n))
game.pivoter_donjon(donjon, (x_n, y_n))
## Fonction principale
def main():
while True:
importlib.reload(fltk) # corrige un bug sérieux de fltk avec les images
map_choice = selection_menu()
if not map_choice:
break
@ -140,6 +251,7 @@ def main():
if maps.charger(map_choice, donjon, dragons, aventurier):
run_game()
else:
print("Erreur de chargement de la map : {}".format(map_choice))
return 1
return 0