Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lemeilleurjeudumonde
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tacticalrpg
lemeilleurjeudumonde
Commits
bc0da7be
Commit
bc0da7be
authored
8 years ago
by
Lénaïg Le Moigne
Browse files
Options
Downloads
Patches
Plain Diff
Ajout du nom du personnage en jeu
parent
607c2988
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/affichage.c
+90
-23
90 additions, 23 deletions
src/affichage.c
with
90 additions
and
23 deletions
src/affichage.c
+
90
−
23
View file @
bc0da7be
...
@@ -65,14 +65,16 @@ int main_affichage()
...
@@ -65,14 +65,16 @@ int main_affichage()
return
0
;
return
0
;
}
}
int
perso_suivant
(
int
numPerso
){
int
perso_suivant
(
int
numPerso
)
{
if
(
numPerso
==
NB_PERSO
)
numPerso
=
1
;
if
(
numPerso
==
NB_PERSO
)
numPerso
=
1
;
else
if
(
numPerso
==
NB_PERSO
*
2
)
numPerso
=
NB_PERSO
+
1
;
else
if
(
numPerso
==
NB_PERSO
*
2
)
numPerso
=
NB_PERSO
+
1
;
else
numPerso
++
;
else
numPerso
++
;
return
numPerso
;
return
numPerso
;
}
}
int
actualiser_num_perso
(
int
numPerso
){
int
actualiser_num_perso
(
int
numPerso
)
{
if
(
numPerso
<=
NB_PERSO
)
numPerso
=
NB_PERSO
+
1
;
if
(
numPerso
<=
NB_PERSO
)
numPerso
=
NB_PERSO
+
1
;
else
numPerso
=
1
;
else
numPerso
=
1
;
return
numPerso
;
return
numPerso
;
...
@@ -556,9 +558,12 @@ int affichage_menu_configuration()
...
@@ -556,9 +558,12 @@ int affichage_menu_configuration()
else
else
{
{
c
=
afficher_cartes_personnalisees
();
c
=
afficher_cartes_personnalisees
();
if
(
c
==-
2
){
if
(
c
==-
2
)
{
c
=-
1
;
c
=-
1
;
}
else
{
}
else
{
selectionnerCarte
(
obtenirNomsCartes
()[
c
]);
selectionnerCarte
(
obtenirNomsCartes
()[
c
]);
}
}
ecran
=
SDL_SetVideoMode
(
LARGEUR_CARTE
*
(
LARGEUR_CASE
+
1
),
HAUTEUR_CARTE
*
(
HAUTEUR_CASE
+
2
),
32
,
SDL_HWSURFACE
|
SDL_DOUBLEBUF
);
ecran
=
SDL_SetVideoMode
(
LARGEUR_CARTE
*
(
LARGEUR_CASE
+
1
),
HAUTEUR_CARTE
*
(
HAUTEUR_CASE
+
2
),
32
,
SDL_HWSURFACE
|
SDL_DOUBLEBUF
);
...
@@ -661,6 +666,7 @@ int affichage_carte()
...
@@ -661,6 +666,7 @@ int affichage_carte()
SDL_Surface
*
ecran
=
SDL_SetVideoMode
(
LARGEUR_CARTE
*
(
LARGEUR_CASE
)
+
LARGEUR_BORDURE
,
HAUTEUR_CARTE
*
(
HAUTEUR_CASE
+
2
),
32
,
SDL_HWSURFACE
|
SDL_DOUBLEBUF
);;
SDL_Surface
*
ecran
=
SDL_SetVideoMode
(
LARGEUR_CARTE
*
(
LARGEUR_CASE
)
+
LARGEUR_BORDURE
,
HAUTEUR_CARTE
*
(
HAUTEUR_CASE
+
2
),
32
,
SDL_HWSURFACE
|
SDL_DOUBLEBUF
);;
SDL_Surface
*
cases
[
HAUTEUR_CARTE
][
LARGEUR_CARTE
];
SDL_Surface
*
cases
[
HAUTEUR_CARTE
][
LARGEUR_CARTE
];
SDL_Surface
*
persos
[
NB_PERSO
*
NB_JOUEURS
];
SDL_Surface
*
persos
[
NB_PERSO
*
NB_JOUEURS
];
SDL_Surface
*
perso
[
NB_PERSO
*
NB_JOUEURS
];
SDL_Surface
*
Case_brillante
=
NULL
;
SDL_Surface
*
Case_brillante
=
NULL
;
SDL_Surface
*
perso_select
=
NULL
;
SDL_Surface
*
perso_select
=
NULL
;
SDL_Rect
Position_Case
[
HAUTEUR_CARTE
][
LARGEUR_CARTE
];
SDL_Rect
Position_Case
[
HAUTEUR_CARTE
][
LARGEUR_CARTE
];
...
@@ -673,30 +679,37 @@ int affichage_carte()
...
@@ -673,30 +679,37 @@ int affichage_carte()
SDL_Surface
*
nom_joueur
=
NULL
;
SDL_Surface
*
nom_joueur
=
NULL
;
SDL_Surface
*
bouton1
=
NULL
;
SDL_Surface
*
bouton1
=
NULL
;
SDL_Surface
*
bouton2
=
NULL
;
SDL_Surface
*
bouton2
=
NULL
;
SDL_Surface
*
perso_x
=
NULL
;
SDL_Rect
pos_PV
;
SDL_Rect
pos_PV
;
SDL_Rect
pos_mana
;
SDL_Rect
pos_mana
;
SDL_Rect
pos_texte
;
SDL_Rect
pos_texte
;
SDL_Rect
pos_nom_joueur
;
SDL_Rect
pos_nom_joueur
;
SDL_Rect
pos_bouton1
;
SDL_Rect
pos_bouton1
;
SDL_Rect
pos_bouton2
;
SDL_Rect
pos_bouton2
;
SDL_Rect
pos_perso
;
SDL_Rect
pos_perso_x
;
TTF_Font
*
vieille_police
=
NULL
;
TTF_Font
*
vieille_police
=
NULL
;
TTF_Font
*
police_arial
=
NULL
;
SDL_Color
couleurNoire
=
{
0
,
0
,
0
};
SDL_Color
couleurNoire
=
{
0
,
0
,
0
};
SDL_Color
couleurBlanche
=
{
255
,
255
,
255
};
SDL_Color
couleurBlanche
=
{
255
,
255
,
255
};
SDL_Color
couleurBleue
=
{
10
,
30
,
80
};
SDL_Color
couleurBleue
=
{
10
,
30
,
80
};
SDL_Color
couleurDoree
=
{
190
,
190
,
120
};
SDL_Color
couleurDoree
=
{
190
,
190
,
120
};
vieille_police
=
TTF_OpenFont
(
"../resources/fonts/OLDENGL.ttf"
,
30
);
vieille_police
=
TTF_OpenFont
(
"../resources/fonts/OLDENGL.ttf"
,
30
);
police_arial
=
TTF_OpenFont
(
"../resources/fonts/arial.ttf"
,
26
);
texte
=
TTF_RenderText_Shaded
(
vieille_police
,
"Joueur actuel :"
,
couleurBlanche
,
couleurNoire
);
texte
=
TTF_RenderText_Shaded
(
vieille_police
,
"Joueur actuel :"
,
couleurBlanche
,
couleurNoire
);
nom_joueur
=
TTF_RenderText_Shaded
(
vieille_police
,
nom_1
,
couleurBlanche
,
couleurNoire
);
nom_joueur
=
TTF_RenderText_Shaded
(
vieille_police
,
nom_1
,
couleurBlanche
,
couleurNoire
);
bouton1
=
TTF_RenderText_Shaded
(
vieille_police
,
"Perso suivant"
,
couleurDoree
,
couleurBleue
);
bouton1
=
TTF_RenderText_Shaded
(
vieille_police
,
"Perso suivant"
,
couleurDoree
,
couleurBleue
);
bouton2
=
TTF_RenderText_Shaded
(
vieille_police
,
"Joueur suivant"
,
couleurDoree
,
couleurBleue
);
bouton2
=
TTF_RenderText_Shaded
(
vieille_police
,
"Joueur suivant"
,
couleurDoree
,
couleurBleue
);
char
buffer_PV
[
2
0
];
char
buffer_PV
[
3
0
];
sprintf
(
buffer_PV
,
"PV: %d/%d"
,
obtenirPVPersonnage
(
perso_actuel
),
obtenirPVMaxPersonnage
(
perso_actuel
));
sprintf
(
buffer_PV
,
"PV: %d/%d"
,
obtenirPVPersonnage
(
perso_actuel
),
obtenirPVMaxPersonnage
(
perso_actuel
));
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
sprintf
(
buffer_PV
,
"Personnage %d"
,
perso_actuel
);
perso_x
=
TTF_RenderText_Shaded
(
police_arial
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
pos_texte
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
texte
->
w
)
/
2
;
pos_texte
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
texte
->
w
)
/
2
;
pos_texte
.
y
=
20
;
pos_texte
.
y
=
20
;
...
@@ -711,6 +724,12 @@ int affichage_carte()
...
@@ -711,6 +724,12 @@ int affichage_carte()
pos_mana
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
mana
->
w
)
/
2
;
pos_mana
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
mana
->
w
)
/
2
;
pos_mana
.
y
=
pos_PV
.
y
+
(
2
*
PV
->
h
);
pos_mana
.
y
=
pos_PV
.
y
+
(
2
*
PV
->
h
);
pos_perso
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
texte
->
w
)
/
2
.
7
;
pos_perso
.
y
=
pos_mana
.
y
+
(
2
*
mana
->
h
);
pos_perso_x
.
x
=
ecran
->
w
-
(
LARGEUR_BORDURE
+
mana
->
w
)
/
2
.
2
;
pos_perso_x
.
y
=
pos_perso
.
y
+
(
2
*
PV
->
h
);
for
(
i
=
0
;
i
<
LARGEUR_CARTE
;
i
++
)
for
(
i
=
0
;
i
<
LARGEUR_CARTE
;
i
++
)
{
{
for
(
j
=
0
;
j
<
HAUTEUR_CARTE
;
j
++
)
for
(
j
=
0
;
j
<
HAUTEUR_CARTE
;
j
++
)
...
@@ -726,15 +745,15 @@ int affichage_carte()
...
@@ -726,15 +745,15 @@ int affichage_carte()
}
}
for
(
i
=
0
;
i
<
NB_JOUEURS
*
NB_PERSO
;
i
++
)
for
(
i
=
0
;
i
<
NB_JOUEURS
*
NB_PERSO
;
i
++
)
{
{
persos
[
i
]
=
SDL_LoadBMP
(
obtenirRessourcePersonnageNum
(
i
+
1
));
persos
[
i
]
=
SDL_LoadBMP
(
obtenirRessourcePersonnageNum
(
i
+
1
));
if
(
!
persos
[
i
])
if
(
!
persos
[
i
])
{
{
printf
(
"Unable to load bitmap: %s
\n
"
,
SDL_GetError
());
printf
(
"Unable to load bitmap: %s
\n
"
,
SDL_GetError
());
return
1
;
return
1
;
}
}
SDL_SetColorKey
(
persos
[
i
],
SDL_SRCCOLORKEY
,
SDL_MapRGB
(
persos
[
i
]
->
format
,
0
,
0
,
255
));
SDL_SetColorKey
(
persos
[
i
],
SDL_SRCCOLORKEY
,
SDL_MapRGB
(
persos
[
i
]
->
format
,
0
,
0
,
255
));
}
}
perso_select
=
SDL_LoadBMP
(
"../resources/Skins/guerrier_select.bmp"
);
perso_select
=
SDL_LoadBMP
(
"../resources/Skins/guerrier_select.bmp"
);
if
(
!
perso_select
)
if
(
!
perso_select
)
...
@@ -765,6 +784,17 @@ int affichage_carte()
...
@@ -765,6 +784,17 @@ int affichage_carte()
}
}
}
}
Position_Case_brillante
=
Position_Case
[
0
][
0
];
Position_Case_brillante
=
Position_Case
[
0
][
0
];
perso
[
perso_actuel
]
=
SDL_LoadBMP
(
obtenirRessourcePersonnageNum
(
perso_actuel
));
if
(
!
perso
[
perso_actuel
])
{
printf
(
"Unable to load bitmap: %s
\n
"
,
SDL_GetError
());
return
1
;
}
SDL_SetColorKey
(
perso
[
perso_actuel
],
SDL_SRCCOLORKEY
,
SDL_MapRGB
(
perso
[
perso_actuel
]
->
format
,
0
,
0
,
255
));
while
(
etat
!=
FERMER
)
while
(
etat
!=
FERMER
)
{
{
SDL_WaitEvent
(
&
event
);
SDL_WaitEvent
(
&
event
);
...
@@ -774,14 +804,30 @@ int affichage_carte()
...
@@ -774,14 +804,30 @@ int affichage_carte()
etat
=
FERMER
;
etat
=
FERMER
;
break
;
break
;
case
SDL_MOUSEBUTTONDOWN
:
case
SDL_MOUSEBUTTONDOWN
:
if
(
event
.
button
.
y
>
pos_bouton1
.
y
&&
event
.
button
.
y
<
pos_bouton1
.
y
+
bouton1
->
h
){
if
(
event
.
button
.
y
>
pos_bouton1
.
y
&&
event
.
button
.
y
<
pos_bouton1
.
y
+
bouton1
->
h
)
{
perso_actuel
=
perso_suivant
(
perso_actuel
);
perso_actuel
=
perso_suivant
(
perso_actuel
);
sprintf
(
buffer_PV
,
"PV: %d/%d"
,
obtenirPVPersonnage
(
perso_actuel
),
obtenirPVMaxPersonnage
(
perso_actuel
));
sprintf
(
buffer_PV
,
"PV: %d/%d"
,
obtenirPVPersonnage
(
perso_actuel
),
obtenirPVMaxPersonnage
(
perso_actuel
));
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
if
(
perso_actuel
<=
3
){
sprintf
(
buffer_PV
,
"Personnage %d"
,
perso_actuel
);
perso_x
=
TTF_RenderText_Shaded
(
police_arial
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
}
else
{
sprintf
(
buffer_PV
,
"Personnage %d"
,
perso_actuel
-
NB_PERSO
);
perso_x
=
TTF_RenderText_Shaded
(
police_arial
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
}
perso
[
perso_actuel
]
=
SDL_LoadBMP
(
obtenirRessourcePersonnageNum
(
perso_actuel
));
if
(
!
perso
[
perso_actuel
])
{
printf
(
"Unable to load bitmap: %s
\n
"
,
SDL_GetError
());
return
1
;
}
SDL_SetColorKey
(
perso
[
perso_actuel
],
SDL_SRCCOLORKEY
,
SDL_MapRGB
(
perso
[
perso_actuel
]
->
format
,
0
,
0
,
255
));
}
}
if
(
event
.
button
.
y
>
pos_bouton2
.
y
&&
event
.
button
.
y
<
pos_bouton2
.
y
+
bouton2
->
h
){
if
(
event
.
button
.
y
>
pos_bouton2
.
y
&&
event
.
button
.
y
<
pos_bouton2
.
y
+
bouton2
->
h
)
{
finDuTour
();
finDuTour
();
debutDuTour
();
debutDuTour
();
nom_joueur
=
TTF_RenderText_Shaded
(
vieille_police
,
obtenirNomJoueurCourant
(),
couleurBlanche
,
couleurNoire
);
nom_joueur
=
TTF_RenderText_Shaded
(
vieille_police
,
obtenirNomJoueurCourant
(),
couleurBlanche
,
couleurNoire
);
...
@@ -790,8 +836,24 @@ int affichage_carte()
...
@@ -790,8 +836,24 @@ int affichage_carte()
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
PV
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
sprintf
(
buffer_PV
,
"mana: %d/%d"
,
obtenirManaPersonnage
(
perso_actuel
),
obtenirManaMaxPersonnage
(
perso_actuel
));
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
mana
=
TTF_RenderText_Shaded
(
vieille_police
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
if
(
perso_actuel
<=
3
){
sprintf
(
buffer_PV
,
"Personnage %d"
,
perso_actuel
);
perso_x
=
TTF_RenderText_Shaded
(
police_arial
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
}
else
{
sprintf
(
buffer_PV
,
"Personnage %d"
,
perso_actuel
-
NB_PERSO
);
perso_x
=
TTF_RenderText_Shaded
(
police_arial
,
buffer_PV
,
couleurBlanche
,
couleurNoire
);
}
perso
[
perso_actuel
]
=
SDL_LoadBMP
(
obtenirRessourcePersonnageNum
(
perso_actuel
));
if
(
!
perso
[
perso_actuel
])
{
printf
(
"Unable to load bitmap: %s
\n
"
,
SDL_GetError
());
return
1
;
}
SDL_SetColorKey
(
perso
[
perso_actuel
],
SDL_SRCCOLORKEY
,
SDL_MapRGB
(
perso
[
perso_actuel
]
->
format
,
0
,
0
,
255
));
}
}
if
(
event
.
button
.
x
<
LARGEUR_CARTE
*
LARGEUR_CASE
){
if
(
event
.
button
.
x
<
LARGEUR_CARTE
*
LARGEUR_CASE
)
{
//deplacement_personnage(event.button.x,event.button.y);
//deplacement_personnage(event.button.x,event.button.y);
}
}
break
;
break
;
...
@@ -812,7 +874,7 @@ int affichage_carte()
...
@@ -812,7 +874,7 @@ int affichage_carte()
}
}
break
;
break
;
}
}
for
(
i
=
0
;
i
<
NB_PERSO
*
NB_JOUEURS
;
i
++
)
for
(
i
=
0
;
i
<
NB_PERSO
*
NB_JOUEURS
;
i
++
)
{
{
obtenirPositionPersonnage
(
i
+
1
,
&
x
,
&
y
);
obtenirPositionPersonnage
(
i
+
1
,
&
x
,
&
y
);
Position_Perso
[
i
].
x
=
x
*
LARGEUR_CASE
;
Position_Perso
[
i
].
x
=
x
*
LARGEUR_CASE
;
...
@@ -847,16 +909,21 @@ int affichage_carte()
...
@@ -847,16 +909,21 @@ int affichage_carte()
SDL_BlitSurface
(
bouton1
,
NULL
,
ecran
,
&
pos_bouton1
);
SDL_BlitSurface
(
bouton1
,
NULL
,
ecran
,
&
pos_bouton1
);
SDL_BlitSurface
(
bouton2
,
NULL
,
ecran
,
&
pos_bouton2
);
SDL_BlitSurface
(
bouton2
,
NULL
,
ecran
,
&
pos_bouton2
);
SDL_BlitSurface
(
mana
,
NULL
,
ecran
,
&
pos_mana
);
SDL_BlitSurface
(
mana
,
NULL
,
ecran
,
&
pos_mana
);
SDL_BlitSurface
(
perso
[
perso_actuel
],
NULL
,
ecran
,
&
pos_perso
);
SDL_BlitSurface
(
perso_x
,
NULL
,
ecran
,
&
pos_perso_x
);
SDL_Flip
(
ecran
);
SDL_Flip
(
ecran
);
}
}
for
(
i
=
0
;
i
<
HAUTEUR_CARTE
;
i
++
){
for
(
i
=
0
;
i
<
HAUTEUR_CARTE
;
i
++
)
for
(
j
=
0
;
j
<
LARGEUR_CARTE
;
j
++
){
{
SDL_FreeSurface
(
cases
[
i
][
j
]);
for
(
j
=
0
;
j
<
LARGEUR_CARTE
;
j
++
)
}
{
SDL_FreeSurface
(
cases
[
i
][
j
]);
}
}
}
for
(
i
=
0
;
i
<
NB_PERSO
*
NB_JOUEURS
;
i
++
){
for
(
i
=
0
;
i
<
NB_PERSO
*
NB_JOUEURS
;
i
++
)
{
SDL_FreeSurface
(
persos
[
i
]);
SDL_FreeSurface
(
persos
[
i
]);
}
}
SDL_FreeSurface
(
Case_brillante
);
SDL_FreeSurface
(
Case_brillante
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment