108 lines
2.9 KiB
Python
108 lines
2.9 KiB
Python
#!/usr/bin/env python3
|
||
|
||
# Concept :
|
||
# - Donjon : action par tour, manipule des salles
|
||
# - Salles : passages vers des directions cardinales, contiennent des dragons
|
||
# - Dragons : plusieurs niveaux, tous différents
|
||
#
|
||
# - Aventurier : déplacement tour par tour de salle en salle vers l'intention
|
||
# - Intention : cible le dragon le plus fort accessible (orgueil)
|
||
#
|
||
# Doc FLTK : https://antoinemeyer.frama.io/fltk/
|
||
import random, fltk, time, os, importlib
|
||
import game
|
||
|
||
## VARIABLES DE CONFIGURATION
|
||
LARGEUR_FENETRE = 800
|
||
HAUTEUR_FENETRE = 800
|
||
|
||
DIM = 7
|
||
VERTICAL = 0
|
||
HORIZONTAL = 1
|
||
|
||
def run_game():
|
||
"""
|
||
Running game
|
||
@params void
|
||
@return void
|
||
"""
|
||
|
||
fltk.cree_fenetre(LARGEUR_FENETRE, HAUTEUR_FENETRE)
|
||
fltk.texte(LARGEUR_FENETRE/2, HAUTEUR_FENETRE/20,
|
||
"Pièges",
|
||
couleur="black",
|
||
taille=30,
|
||
ancrage='center')
|
||
|
||
fltk.texte(LARGEUR_FENETRE/2, HAUTEUR_FENETRE/8,
|
||
"Tapez Echap pour quitter le jeu",
|
||
couleur="green",
|
||
taille=10,
|
||
ancrage='center')
|
||
|
||
modeles = {
|
||
"tirette_horiz":"",
|
||
"tirette_vert":"",
|
||
"bille":"",
|
||
"cases"":""
|
||
}
|
||
|
||
while True:
|
||
fltk.mise_a_jour()
|
||
# Affichage plateau
|
||
for i in range(DIM):
|
||
for j in range(DIM):
|
||
fltk.image( 100+i*100,
|
||
150+j*100,
|
||
'media/{}.png'.format(modeles[type_modele]), #XXX déterminer type
|
||
ancrage = "nw",
|
||
largeur=100,
|
||
hauteur=100,
|
||
tag="{},{}".format(i,j))
|
||
|
||
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 "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))
|
||
réaliser_action()) #XXX
|
||
|
||
|
||
## Fonction principale
|
||
def main():
|
||
while True:
|
||
importlib.reload(fltk) # corrige un bug sérieux de fltk avec les images
|
||
|
||
#XXX créer joueurs
|
||
|
||
run_game()
|
||
|
||
#XXX vérifier condition de sortie
|
||
|
||
return 0
|
||
|
||
main()
|