Premier jet piege.py

This commit is contained in:
neox 2023-12-21 10:00:35 +01:00
parent f6c4a36bad
commit e2e60d4d28
No known key found for this signature in database
GPG Key ID: 2974E1D5F25DFCC8
2 changed files with 108 additions and 8 deletions

View File

@ -1,4 +1,4 @@
#/usr/bin/env python3
#!/usr/bin/env python3
##### Principes généraux du jeu de piege:
# Partie preliminaire:
@ -44,7 +44,6 @@
# | | | | | | |
# ▬ ▬ ▬ ▬ ▬ ▬ ▬
import fltk
import random
DIM = 7
@ -148,9 +147,3 @@ class Joueur:
self.plateau.billes.append((x,y))
return True
return False
def main():
main

107
piege.py Normal file
View File

@ -0,0 +1,107 @@
#!/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()