Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Corentin MIMEAU
PolyDefense
Commits
1a9288db
Commit
1a9288db
authored
Dec 04, 2015
by
Vincent BRULE
Browse files
up
parent
b4e3f797
Changes
1
Hide whitespace changes
Inline
Side-by-side
carte.py
View file @
1a9288db
...
...
@@ -8,7 +8,7 @@ from carteStruct import *
from
constante
import
Constante
from
base
import
*
from
joueur
import
*
from
tour
import
*
#ctrl+Q utile pour commenter
...
...
@@ -184,16 +184,17 @@ def ecran_regle (ecran):
if
Constante
.
largeur
/
2.3
<=
x
<=
Constante
.
largeur
/
1.8
and
Constante
.
hauteur
/
2.6
<=
y
<=
Constante
.
hauteur
/
1.6
:
return
def
maj_affichage_tourelle
(
ecran
,
liste
,
image
,
verif_tour
):
for
i
in
liste
:
# Parcours la liste comportant la position de l'herbe
if
verif_tour
==
1
:
if
i
[
0
]
<
16
:
ecran
.
blit
(
image
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
elif
verif_tour
==
2
:
if
i
[
0
]
>=
16
:
ecran
.
blit
(
image
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
else
:
ecran
.
blit
(
image
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
def
maj_affichage_tour
(
ecran
,
liste_1
,
liste_2
,
image_herbe
,
verif_tour
):
if
verif_tour
==
1
:
for
i
in
liste_1
:
ecran
.
blit
(
image_herbe
,
(
i
.
position
[
0
]
*
Constante
.
taille_rel
,
i
.
position
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
i
.
afficher
(
ecran
)
# Met l'image dans le fond
elif
verif_tour
==
2
:
for
i
in
liste_2
:
ecran
.
blit
(
image_herbe
,
(
i
.
position
[
0
]
*
Constante
.
taille_rel
,
i
.
position
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
i
.
afficher
(
ecran
)
# Met l'image dans le fond
def
maj_affichage_argent
(
ecran
,
base_joueur
,
joueur
):
argent_joueur
=
Constante
.
type_ecriture
.
render
(
str
(
base_joueur
.
argent
)
+
" euros"
,
True
,
Constante
.
ORANGE
,
(
0
,
0
,
0
))
...
...
@@ -208,8 +209,9 @@ def maj_affichage_argent(ecran, base_joueur, joueur):
def
maj_affichage_liste
(
ecran
,
liste
,
image
):
for
i
in
liste
:
ecran
.
blit
(
image
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
def
verif_pose_tourelle
(
ecran
,
carte
,
(
i
,
j
)):
def
verif_pose_tour
(
ecran
,
carte
,
(
i
,
j
)):
if
(
i
,
j
)
in
carte
.
liste_herbe
and
(
i
,
j
)
not
in
carte
.
liste_herbe_obstacle
and
(
i
,
j
)
not
in
carte
.
liste_route
:
return
True
...
...
@@ -248,8 +250,9 @@ def ecran_principal(ecran, j1, j2, verif_tour, base_1, base_2):
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
()
tourelle_1_image
=
image
.
load
(
"tourelle_1.png"
)
choix_case_image
=
image
.
load
(
"choix_case.png"
)
tour_1_image
=
image
.
load
(
"tour_1_avec_fond.png"
)
tour_2_image
=
image
.
load
(
"tour_2_avec_fond.png"
)
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
))
...
...
@@ -260,10 +263,10 @@ def ecran_principal(ecran, j1, j2, verif_tour, base_1, base_2):
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
))
tourelle_1_choix
=
transform
.
scale
(
tourelle_1_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
tourelle_1_finale
=
transform
.
scale
(
tourelle_1_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
choix_case_finale
=
transform
.
scale
(
choix_case_image
,(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
tour_1_finale
=
transform
.
scale
(
tour_1_image
,
(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
tour_2_finale
=
transform
.
scale
(
tour_2_image
,
(
Constante
.
taille_rel
,
Constante
.
taille_rel
))
if
Constante
.
verif_carte
==
0
:
global
carte
carte
=
Carte
()
...
...
@@ -306,17 +309,22 @@ def ecran_principal(ecran, j1, j2, verif_tour, base_1, base_2):
for
i
in
carte
.
liste_sortie_ennemie
:
ecran
.
blit
(
herbe_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
ecran
.
blit
(
sortie_ennemie_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
for
i
in
carte
.
liste_tourelle_1
:
# Parcours la liste comportant la position de l'herbe
ecran
.
blit
(
herbe_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
if
verif_tour
==
1
:
if
i
[
0
]
<
16
:
ecran
.
blit
(
tourelle_1_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
if
verif_tour
==
2
:
if
i
[
0
]
>=
16
:
ecran
.
blit
(
tourelle_1_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
else
:
ecran
.
blit
(
tourelle_1_finale
,
(
i
[
0
]
*
Constante
.
taille_rel
,
i
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
if
verif_tour
==
1
:
for
i
in
base_1
.
liste_tour
:
ecran
.
blit
(
herbe_finale
,
(
i
.
position
[
0
]
*
Constante
.
taille_rel
,
i
.
position
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
i
.
afficher
(
ecran
)
# Met l'image dans le fond
elif
verif_tour
==
2
:
for
i
in
base_2
.
liste_tour
:
ecran
.
blit
(
herbe_finale
,
(
i
.
position
[
0
]
*
Constante
.
taille_rel
,
i
.
position
[
1
]
*
Constante
.
taille_rel
))
# Met l'image dans le fond
i
.
afficher
(
ecran
)
# Met l'image dans le fond
else
:
for
i
in
base_1
.
liste_tour
:
i
.
afficher
(
ecran
)
for
i
in
base_2
.
liste_tour
:
i
.
afficher
(
ecran
)
couvrir_ecran_ennemie
(
ecran
,
verif_tour
)
...
...
@@ -360,14 +368,14 @@ def ecran_principal(ecran, j1, j2, verif_tour, base_1, base_2):
(
u
,
v
)
=
(
x
/
Constante
.
taille_rel
,
y
/
Constante
.
taille_rel
)
(
g
,
b
)
=
(
Constante
.
position
[
0
]
*
Constante
.
taille_rel
,
Constante
.
position
[
1
]
*
Constante
.
taille_rel
)
if
(
u
,
v
)
in
carte
.
liste_tour
elle
_1
:
if
(
u
,
v
)
in
carte
.
liste_tour_1
:
if
verif_tour
==
1
:
if
Constante
.
position
[
0
]
<
16
:
if
verif_pose_tour
elle
(
ecran
,
carte
,
(
Constante
.
position
[
0
],
Constante
.
position
[
1
]))
==
True
:
if
verif_pose_tour
(
ecran
,
carte
,
(
Constante
.
position
[
0
],
Constante
.
position
[
1
]))
==
True
:
ecran
.
blit
(
herbe_finale
,
(
g
,
b
))
else
:
if
Constante
.
position
[
0
]
>=
16
:
if
verif_pose_tour
elle
(
ecran
,
carte
,
(
Constante
.
position
[
0
],
Constante
.
position
[
1
]))
==
True
:
if
verif_pose_tour
(
ecran
,
carte
,
(
Constante
.
position
[
0
],
Constante
.
position
[
1
]))
==
True
:
ecran
.
blit
(
herbe_finale
,
(
g
,
b
))
Constante
.
verif_cadre_rouge
=
0
...
...
@@ -377,51 +385,79 @@ def ecran_principal(ecran, j1, j2, verif_tour, base_1, base_2):
if
Constante
.
verif_cadre_rouge
==
1
:
if
Constante
.
position
in
carte
.
liste_tour
elle
_1
:
ecran
.
blit
(
tour
elle
_1_finale
,
(
g
,
b
))
if
Constante
.
position
in
carte
.
liste_tour_1
:
ecran
.
blit
(
tour_1_finale
,
(
g
,
b
))
else
:
ecran
.
blit
(
herbe_finale
,
(
g
,
b
))
Constante
.
verif_cadre_rouge
=
0
if
(
u
,
v
)
==
(
18
,
3
):
if
verif_tour
==
1
:
if
verif_pose_tour
elle
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
if
verif_tour
==
1
:
if
(
u
,
v
)
==
(
18
,
3
)
:
if
verif_pose_tour
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
couvrir_ecran_ennemie
(
ecran
,
verif_tour
)
if
base_1
.
depenser_argent
(
10
)
!=
"NON"
:
carte
.
liste_tourelle_1
.
append
(
Constante
.
position
)
carte
.
liste_tour_1
.
append
(
Constante
.
position
)
tour
=
Tour_feu
(
Constante
.
position
,
verif_tour
)
base_1
.
liste_tour
.
append
(
tour
)
carte
.
liste_herbe_obstacle
.
append
(
Constante
.
position
)
maj_affichage_tour
elle
(
ecran
,
carte
.
liste_tour
elle_1
,
tourelle_1
_finale
,
verif_tour
)
maj_affichage_tour
(
ecran
,
base_1
.
liste_tour
,
base_2
.
liste_tour
,
herbe
_finale
,
verif_tour
)
maj_affichage_argent
(
ecran
,
base_1
,
j1
)
elif
(
u
,
v
)
==
(
12
,
3
):
if
verif_tour
==
2
:
if
verif_pose_tourelle
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
elif
(
u
,
v
)
==
(
22
,
3
):
if
verif_pose_tour
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
couvrir_ecran_ennemie
(
ecran
,
verif_tour
)
if
base_1
.
depenser_argent
(
20
)
!=
"NON"
:
carte
.
liste_tour_1
.
append
(
Constante
.
position
)
tour
=
Tour_glace
(
Constante
.
position
,
verif_tour
)
base_1
.
liste_tour
.
append
(
tour
)
carte
.
liste_herbe_obstacle
.
append
(
Constante
.
position
)
maj_affichage_tour
(
ecran
,
base_1
.
liste_tour
,
base_2
.
liste_tour
,
herbe_finale
,
verif_tour
)
maj_affichage_argent
(
ecran
,
base_1
,
j1
)
elif
verif_tour
==
2
:
if
(
u
,
v
)
==
(
8
,
3
):
if
verif_pose_tour
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
couvrir_ecran_ennemie
(
ecran
,
verif_tour
)
if
base_2
.
depenser_argent
(
20
)
!=
"NON"
:
carte
.
liste_tour_1
.
append
(
Constante
.
position
)
tour
=
Tour_glace
(
Constante
.
position
,
verif_tour
)
base_2
.
liste_tour
.
append
(
tour
)
carte
.
liste_herbe_obstacle
.
append
(
Constante
.
position
)
maj_affichage_tour
(
ecran
,
base_1
.
liste_tour
,
base_2
.
liste_tour
,
herbe_finale
,
verif_tour
)
maj_affichage_argent
(
ecran
,
base_2
,
j2
)
elif
(
u
,
v
)
==
(
12
,
3
):
if
verif_pose_tour
(
ecran
,
carte
,
Constante
.
position
)
==
True
:
couvrir_ecran_ennemie
(
ecran
,
verif_tour
)
if
base_2
.
depenser_argent
(
10
)
!=
"NON"
:
carte
.
liste_tourelle_1
.
append
(
Constante
.
position
)
carte
.
liste_tour_1
.
append
(
Constante
.
position
)
tour
=
Tour_feu
(
Constante
.
position
,
verif_tour
)
base_2
.
liste_tour
.
append
(
tour
)
carte
.
liste_herbe_obstacle
.
append
(
Constante
.
position
)
maj_affichage_tour
elle
(
ecran
,
carte
.
liste_tour
elle_1
,
tourelle_1
_finale
,
verif_tour
)
maj_affichage_tour
(
ecran
,
base_1
.
liste_tour
,
base_2
.
liste_tour
,
herbe
_finale
,
verif_tour
)
maj_affichage_argent
(
ecran
,
base_2
,
j2
)
for
(
i
,
j
)
in
carte
.
liste_herbe
:
if
u
==
i
and
v
==
j
:
if
verif_tour
==
1
:
if
i
<
16
:
if
verif_pose_tourelle
(
ecran
,
carte
,
(
i
,
j
))
==
True
:
ecran
.
blit
(
tourelle_1_choix
,
(
18
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
if
verif_pose_tour
(
ecran
,
carte
,
(
i
,
j
))
==
True
:
ecran
.
blit
(
tour_1_finale
,
(
18
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
ecran
.
blit
(
tour_2_finale
,
(
22
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
ecran
.
blit
(
choix_case_finale
,
(
i
*
Constante
.
taille_rel
,
j
*
Constante
.
taille_rel
))
Constante
.
verif_cadre_rouge
=
1
if
verif_tour
==
2
:
if
i
>=
16
:
if
verif_pose_tourelle
(
ecran
,
carte
,
(
i
,
j
))
==
True
:
ecran
.
blit
(
tourelle_1_choix
,
(
12
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
if
verif_pose_tour
(
ecran
,
carte
,
(
i
,
j
))
==
True
:
ecran
.
blit
(
tour_1_finale
,
(
12
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
ecran
.
blit
(
tour_2_finale
,
(
8
*
Constante
.
taille_rel
,
3
*
Constante
.
taille_rel
))
ecran
.
blit
(
choix_case_finale
,
(
i
*
Constante
.
taille_rel
,
j
*
Constante
.
taille_rel
))
Constante
.
verif_cadre_rouge
=
1
Constante
.
position
=
(
u
,
v
)
affichage_chronometre
(
ecran
,
temps_passe
,
temps_depart
)
display
.
flip
()
temps_passe
=
time
.
time
()
...
...
Write
Preview
Markdown
is supported
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