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
34e02c9a
Commit
34e02c9a
authored
8 years ago
by
Montjoie Henri
Browse files
Options
Downloads
Patches
Plain Diff
gestion des persos
parent
3a83b377
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/affichage.c
+14
-2
14 additions, 2 deletions
src/affichage.c
src/controleurSDL.c
+0
-128
0 additions, 128 deletions
src/controleurSDL.c
with
14 additions
and
130 deletions
src/affichage.c
+
14
−
2
View file @
34e02c9a
...
...
@@ -65,6 +65,16 @@ int main_affichage()
return
0
;
}
void
perso_suivant
(
int
*
numPerso
){
if
(
*
numPerso
==
NB_PERSO
)
*
numPerso
=
1
;
else
if
(
*
numPerso
==
NB_PERSO
*
2
)
*
numPerso
=
NB_PERSO
+
1
;
else
*
numPerso
++
;
}
void
actualiser_num_perso
(
int
*
numPerso
){
if
(
*
numPerso
<=
NB_PERSO
)
*
numPerso
=
NB_PERSO
+
1
;
else
*
numPerso
=
1
;
}
/*!
* \fn int afficher_cartes_personnalisees()
...
...
@@ -757,11 +767,12 @@ int affichage_carte()
break
;
case
SDL_MOUSEBUTTONDOWN
:
if
(
event
.
button
.
y
>
pos_bouton1
.
y
&&
event
.
button
.
y
<
pos_bouton1
.
y
+
bouton1
->
h
){
//nextPerso(
);
perso_suivant
(
&
perso_select
);
}
if
(
event
.
button
.
y
>
pos_bouton2
.
y
&&
event
.
button
.
y
<
pos_bouton2
.
y
+
bouton2
->
h
){
//
nextJoue
ur();
//
fin_du_to
ur();
//nom_joueur= TTF_RenderText_Shaded(vieille_police, obtenirNomJoueur(), couleurBlanche, couleurNoire);
actualiser_num_perso
(
&
perso_select
);
}
if
(
event
.
button
.
x
<
LARGEUR_CARTE
*
LARGEUR_CASE
){
//deplacement_personnage(event.button.x,event.button.y);
...
...
@@ -839,6 +850,7 @@ int affichage_carte()
SDL_FreeSurface
(
nom_joueur
);
SDL_FreeSurface
(
bouton1
);
SDL_FreeSurface
(
bouton2
);
//SDL_FreeSurface(PV);
TTF_CloseFont
(
vieille_police
);
etat
=
FERMER
;
...
...
This diff is collapsed.
Click to expand it.
src/controleurSDL.c
+
0
−
128
View file @
34e02c9a
...
...
@@ -17,27 +17,6 @@
*/
Carte
Carte_actuelle
;
Personnage
ListePersos
[
NB_PERSO
];
int
perso_actuel
=
0
;
/*!
* \fn void init_controleur(SDL_Rect Position_Case[])
* \brief fonction du controleur appellée par l'affichage et qui initialise le moteur du jeu (création de la carte et des personnages)
*
* \param les coordonnées de toutes les cases
*/
void
init_controleur
(
SDL_Rect
Position_Case
[])
{
int
i
;
for
(
i
=
0
;
i
<
LARGEUR_CARTE
*
HAUTEUR_CARTE
;
i
++
)
{
init_case
(
&
Carte_actuelle
[
i
],
Position_Case
[
i
].
x
,
Position_Case
[
i
].
y
,
NULL
);
}
for
(
i
=
0
;
i
<
NB_PERSO
;
i
++
)
set_personnage
(
&
ListePersos
[
i
],
NULL
);
}
/*!
* \fn int x_case_cliquee(int x_pixel, int y_pixel)
* \brief La fonction retourne la colonne d'une case à partir de sa position en pixels
...
...
@@ -70,110 +49,3 @@ int y_case_cliquee(int x_pixel, int y_pixel)
}
return
y_case
;
}
/*!
* \fn void persosuivant()
* \brief La fonction permet de selectionner le personnage suivant
*/
void
persosuivant
(){
if
(
perso_actuel
<
NB_PERSO
-
1
)
perso_actuel
++
;
else
perso_actuel
=
0
;
}
/*!
* \fn int persoactuel()
* \brief La fonction retourne le numéro du personnage actuellement controlé
*/
int
persoactuel
(){
return
perso_actuel
;
}
/*!
* \fn void deplacement_personnage(int x, int y))
* \brief Cette fonction du controleur appelle la fonction du moteur permettant de déplacer le personnage selectionné
*
* \param les coordonnées (en pixels) de l'endroit ou l'utilisateur a cliqué
*/
void
deplacement_personnage
(
int
x
,
int
y
)
{
if
(
x
<
LARGEUR_CARTE
*
LARGEUR_CASE
&&
y
<
HAUTEUR_CARTE
*
HAUTEUR_CASE
)
{
Case
*
case_cliquee
=
trouverCase
(
Carte_actuelle
,
x_case_cliquee
(
x
,
y
),
y_case_cliquee
(
x
,
y
));
Personnage
*
perso
=
&
ListePersos
[
perso_actuel
];
deplacement_unitaire
(
perso
,
case_cliquee
,
HAUTEUR_CASE
,
LARGEUR_CASE
);
}
}
/*!
* \fn Case* get_case_perso(int num)
* \brief donne la case sur laquelle est située un personnage
*
* \param le numéro d'un personnage
* \return un pointeur vers la case du personnage
*/
Case
*
get_case_perso
(
int
num
)
{
Personnage
*
perso
=
&
ListePersos
[
num
];
return
getPosition
(
perso
);
}
/*!
* \fn int get_position_perso_x(int num)
* \brief donne la coordonnée x en pixels d'un personnage
*
* \param le numéro d'un personnage
* \return la coordonnée x en pixels du personnage
*/
int
get_position_perso_x
(
int
num
)
{
Case
*
case_perso
=
get_case_perso
(
num
);
return
get_x
(
case_perso
);
}
/*!
* \fn int get_position_perso_y(int num)
* \brief donne la coordonnée y en pixels d'un personnage
*
* \param le numéro d'un personnage
* \return la coordonnée y en pixels du personnage
*/
int
get_position_perso_y
(
int
num
)
{
Case
*
case_perso
=
get_case_perso
(
num
);
return
get_y
(
case_perso
);
}
/*!
* \fn Case* deplacement_brillance(int x,int y)
* \brief La fonction retourne un pointeur vers la case de coordonnées x,y
*
* \param les coordonnées x et y d'une case (pas en pixels mais bien en colonne et ligne), ainsi que la carte utilisée
* \return un pointeur vers cette case
*/
Case
*
deplacement_brillance
(
int
x
,
int
y
)
{
if
(
x
<
LARGEUR_CARTE
*
LARGEUR_CASE
&&
y
<
HAUTEUR_CARTE
*
HAUTEUR_CASE
)
{
return
trouverCase
(
Carte_actuelle
,
x_case_cliquee
(
x
,
y
),
y_case_cliquee
(
x
,
y
));
}
return
NULL
;
}
/*!
* \fn int get_position_case_y(Case * Case)
* \brief retourne la coordonnée y d'une case
*
* \param un pointeur vers une case
* \return la coordonnée y de la case
*/
int
get_position_case_y
(
Case
*
Case
){
return
get_y
(
Case
);
}
/*!
* \fn int get_position_case_x(Case * Case)
* \brief retourne la coordonnée x d'une case
*
* \param un pointeur vers une case
* \return la coordonnée x de la case
*/
int
get_position_case_x
(
Case
*
Case
)
{
return
get_x
(
Case
);
}
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