Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Corentin MIMEAU
PolyDefense
Commits
78721d59
Commit
78721d59
authored
Nov 25, 2015
by
Vincent BRULE
Browse files
ecran 16:10 prise en charge
parent
89b6d0d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
carte.py
View file @
78721d59
...
...
@@ -9,7 +9,6 @@ from constante import Constante
#Jeu Fonctionne que sur un ratio 16:9
#ctrl+Q utile pour commenter
...
...
@@ -60,26 +59,26 @@ def lecture_carte (fichier, carte): # Permet de lire le .txt contenant la carte
numColonne
=
0
for
trouve_lettre
in
ligne
:
if
trouve_lettre
==
"X"
:
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"O"
:
carte
.
liste_route
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_route
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"A"
:
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_arbre
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
carte
.
liste_arbre
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"C"
:
carte
.
liste_contour
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_contour
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"B"
:
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_base
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
carte
.
liste_base
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"D"
:
carte
.
liste_contour_sortie_ennemie
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_contour_sortie_ennemie
.
append
((
numColonne
,
numLigne
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"E"
:
carte
.
liste_contour_sortie_ennemie_2
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_contour_sortie_ennemie_2
.
append
((
numColonne
,
numLigne
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
if
trouve_lettre
==
"S"
:
carte
.
liste_herbe
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_sortie_ennemie
.
append
((
numColonne
*
Constante
.
taille_rel
,
numLigne
*
Constante
.
taille_rel
))
carte
.
liste_herbe
.
append
((
numColonne
,
numLigne
))
carte
.
liste_sortie_ennemie
.
append
((
numColonne
,
numLigne
))
numColonne
=
numColonne
+
1
numLigne
=
numLigne
+
1
...
...
@@ -193,39 +192,44 @@ def ecran_principal(ecran, j1, j2):
sortie_ennemie_image
=
image
.
load
(
"milieu_soldat.png"
).
convert_alpha
()
base_image
=
image
.
load
(
"base.png"
).
convert_alpha
()
base2_image
=
image
.
load
(
"base2.png"
).
convert_alpha
()
contour_milieu_soldat_finale
=
transform
.
scale
(
contour_milieu_soldat_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
contour_milieu_soldat_finale_2
=
transform
.
scale
(
contour_milieu_soldat_image_2
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
terre_finale
=
transform
.
scale
(
terre_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
route_finale
=
transform
.
scale
(
route_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
arbre_finale
=
transform
.
scale
(
arbre_image
,(
2
*
Constante
.
taille_rel
,
2
*
Constante
.
taille_rel
))
contour_finale
=
transform
.
scale
(
contour_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
base_finale
=
transform
.
scale
(
base_image
,(
3
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
base2_finale
=
transform
.
scale
(
base2_image
,(
3
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
sortie_ennemie_finale
=
transform
.
scale
(
sortie_ennemie_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
carte
=
Carte
()
lecture_carte
(
"dico_carte.txt"
,
carte
)
# Lis le dictionnaire contenant la carte
if
Constante
.
ratio
==
1.6
:
lecture_carte
(
"dico_carte_ratio_16_10.txt"
,
carte
)
# Lis le dictionnaire contenant la carte en fonction du ratio
else
:
lecture_carte
(
"dico_carte_ratio_16_9.txt"
,
carte
)
for
i
in
carte
.
liste_herbe
:
# Parcours la liste comportant la position de l'herbe
ecran
.
blit
(
terre_finale
,
i
)
# Met l'image dans le fond
for
v
in
carte
.
liste_route
:
# Parcours la liste comportant la position de la route
ecran
.
blit
(
route_finale
,
v
)
# Met l'image dans le fond
for
p
in
carte
.
liste_arbre
:
# Parcours la liste comportant la position des arbres
ecran
.
blit
(
arbre_finale
,
p
)
# Met l'image dans le fond
for
c
in
carte
.
liste_contour
:
ecran
.
blit
(
contour_finale
,
c
)
for
d
in
carte
.
liste_contour_sortie_ennemie
:
ecran
.
blit
(
contour_milieu_soldat_finale
,
d
)
for
e
in
carte
.
liste_contour_sortie_ennemie_2
:
ecran
.
blit
(
contour_milieu_soldat_finale_2
,
e
)
for
b
in
carte
.
liste_base
:
ecran
.
blit
(
terre_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
# Met l'image dans le fond
for
i
in
carte
.
liste_route
:
# Parcours la liste comportant la position de la route
ecran
.
blit
(
route_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
# Met l'image dans le fond
for
i
in
carte
.
liste_arbre
:
# Parcours la liste comportant la position des arbres
ecran
.
blit
(
arbre_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
# Met l'image dans le fond
for
i
in
carte
.
liste_contour
:
ecran
.
blit
(
contour_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
for
i
in
carte
.
liste_contour_sortie_ennemie
:
ecran
.
blit
(
contour_milieu_soldat_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
for
i
in
carte
.
liste_contour_sortie_ennemie_2
:
ecran
.
blit
(
contour_milieu_soldat_finale_2
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
for
i
in
carte
.
liste_base
:
if
verif_base
==
0
:
ecran
.
blit
(
base_finale
,
b
)
ecran
.
blit
(
base_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
verif_base
=
verif_base
+
1
else
:
ecran
.
blit
(
base2_finale
,
b
)
for
s
in
carte
.
liste_sortie_ennemie
:
ecran
.
blit
(
sortie_ennemie_finale
,
s
)
ecran
.
blit
(
base2_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
for
i
in
carte
.
liste_sortie_ennemie
:
ecran
.
blit
(
sortie_ennemie_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
)
)
texte_joueur
=
Constante
.
type_ecriture
.
render
(
j1
.
nom
,
True
,
Constante
.
ORANGE
,
(
255
,
255
,
255
))
texte_joueur2
=
Constante
.
type_ecriture
.
render
(
j2
.
nom
,
True
,
Constante
.
ORANGE
,
(
255
,
255
,
255
))
...
...
@@ -247,11 +251,18 @@ def ecran_principal(ecran, j1, j2):
verif_son
=
verif_son
+
1
son_fond
(
3
)
if
evenement_joueur
.
type
==
MOUSEBUTTONDOWN
:
x
,
y
=
evenement_joueur
.
pos
for
(
i
,
u
)
in
carte
.
liste_route
:
if
x
>=
i
and
y
>=
u
:
if
x
<=
(
i
+
(
Constante
.
taille_tuile
*
(
Constante
.
largeur
/
Constante
.
largeur_ref
)))
and
y
<=
(
u
+
(
Constante
.
taille_tuile
*
Constante
.
largeur
/
Constante
.
largeur_ref
)):
ecran
.
blit
(
sortie_ennemie_finale
,
(
i
,
u
))
display
.
flip
()
(
x
,
y
)
=
evenement_joueur
.
pos
(
u
,
v
)
=
(
x
/
Constante
.
taille_rel
,
y
/
Constante
.
taille_rel
)
for
(
i
,
j
)
in
carte
.
liste_route
:
if
u
==
i
and
v
==
j
:
ecran
.
blit
(
sortie_ennemie_finale
,
(
i
*
Constante
.
taille_rel
,
j
*
Constante
.
taille_rel
))
display
.
flip
()
# carte.liste_sortie_ennemie.append((i, j))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment