Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Projet l2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
VAUTRIN Guillaume
Projet l2
Commits
79410c1d
Commit
79410c1d
authored
4 years ago
by
vautrin33u
Browse files
Options
Downloads
Patches
Plain Diff
Erreur dans la gestion du déplaçement des ingrédients
parent
05685cd6
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Ressources/save.txt
+250
-250
250 additions, 250 deletions
Ressources/save.txt
constantes.h
+1
-1
1 addition, 1 deletion
constantes.h
logique.c
+51
-16
51 additions, 16 deletions
logique.c
logique.h
+21
-7
21 additions, 7 deletions
logique.h
with
323 additions
and
274 deletions
Ressources/save.txt
+
250
−
250
View file @
79410c1d
Source diff could not be displayed: it is too large. Options to address this:
view the blob
.
This diff is collapsed.
Click to expand it.
constantes.h
+
1
−
1
View file @
79410c1d
...
...
@@ -127,7 +127,7 @@ enum cuisson {INCONCERNE, FRIGO, FRAIS, SALE, PROPRE, CUIT, JETE};
* @brief Quantité de chaque ingrédient dans les stocks
*
*/
#define QTE_STOCK
10
#define QTE_STOCK
5
/**
* \brief taille joueur
...
...
This diff is collapsed.
Click to expand it.
logique.c
+
51
−
16
View file @
79410c1d
...
...
@@ -49,21 +49,24 @@ void init_stocks(stock_t* stocks, sprite_t* zone_stockage){
stocks
->
score
=
0
;
SDL_Rect
temp
=
get_rect
(
zone_stockage
);
for
(
int
i
=
0
;
i
<
2
;
i
++
){
init_ingre
(
&
stocks
->
stock_pain
[
i
],
NOM_PAIN
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_ingre
(
&
stocks
->
stock_pain
[
i
],
NOM_PAIN
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
}
for
(
int
i
=
0
;
i
<
QTE_STOCK
;
i
++
){
init_ingre
(
&
stocks
->
stock_tomate
[
i
],
NOM_TOMATE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
init_ingre
(
&
stocks
->
stock_steak
[
i
],
NOM_STEAK
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
init_ingre
(
&
stocks
->
stock_salade
[
i
],
NOM_SALADE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
init_ingre
(
&
stocks
->
stock_fromage
[
i
],
NOM_SALADE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
init_ingre
(
&
stocks
->
stock_cornichon
[
i
],
NOM_CORNICHON
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
POSE
);
}
init_ingre
(
&
stocks
->
stock_tomate
,
NOM_TOMATE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_ingre
(
&
stocks
->
stock_steak
,
NOM_STEAK
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_ingre
(
&
stocks
->
stock_salade
,
NOM_SALADE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_ingre
(
&
stocks
->
stock_fromage
,
NOM_SALADE
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_ingre
(
&
stocks
->
stock_cornichon
,
NOM_CORNICHON
,
temp
.
x
,
temp
.
y
,
PLAT_SIZE
,
PLAT_SIZE
,
0
,
BAS
);
init_commande
(
stocks
);
}
void
init_commande
(
stock_t
*
stocks
){
//Initialise le tableau afin de générer une commande:
//Initialise le tableau afin de générer une commande
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
//Parcours du tableau
switch
(
aleatoire
(
0
,
5
)){
switch
(
aleatoire
(
0
,
NB_INGREDIENT
-
1
)){
case
0
:
stocks
->
commande
[
i
]
=
NOM_TOMATE
;
break
;
...
...
@@ -81,7 +84,7 @@ void init_commande(stock_t *stocks){
break
;
}
// Tranche de pain
if
(
i
==
0
||
i
==
4
){
if
(
i
==
0
||
i
==
INGREDIENT_DISPO
-
1
){
stocks
->
commande
[
i
]
=
NOM_PAIN
;
}
}
...
...
@@ -89,24 +92,35 @@ void init_commande(stock_t *stocks){
void
init_ingredient_cuisine
(
world_t
*
world
,
stock_t
*
stocks
){
//initialisation des ingrédients mise à disposition en cuisine, selon la commande du client
int
compt_tomate
=
0
;
int
compt_salade
=
0
;
int
compt_steak
=
0
;
int
compt_cornichon
=
0
;
int
compt_fromage
=
0
;
world
->
en_cuisine
[
0
]
=
stocks
->
stock_pain
[
0
];
world
->
en_cuisine
[
INGREDIENT_DISPO
-
1
]
=
stocks
->
stock_pain
[
1
];
for
(
int
i
=
1
;
i
<
INGREDIENT_DISPO
-
1
;
i
++
){
switch
(
stocks
->
commande
[
i
]){
case
NOM_TOMATE
:
world
->
en_cuisine
[
i
]
=
stocks
->
stock_tomate
;
world
->
en_cuisine
[
i
]
=
stocks
->
stock_tomate
[
compt_tomate
];
compt_tomate
++
;
break
;
case
NOM_SALADE
:
world
->
en_cuisine
[
i
]
=
stocks
->
stock_salade
;
world
->
en_cuisine
[
i
]
=
stocks
->
stock_salade
[
compt_salade
];
compt_salade
++
;
break
;
case
NOM_STEAK
:
world
->
en_cuisine
[
i
]
=
stocks
->
stock_steak
;
world
->
en_cuisine
[
i
]
=
stocks
->
stock_steak
[
compt_steak
];
compt_steak
++
;
break
;
case
NOM_CORNICHON
:
world
->
en_cuisine
[
i
]
=
stocks
->
stock_cornichon
;
world
->
en_cuisine
[
i
]
=
stocks
->
stock_cornichon
[
compt_cornichon
];
compt_cornichon
++
;
break
;
default:
world
->
en_cuisine
[
i
]
=
stocks
->
stock_fromage
;
world
->
en_cuisine
[
i
]
=
stocks
->
stock_fromage
[
compt_fromage
];
compt_fromage
++
;
break
;
}
}
...
...
@@ -215,7 +229,7 @@ void modif_position (sprite_t *sprite, int x_move, int y_move){
sprite
->
rect
.
y
+=
y_move
;
}
int
has_collided
(
sprite_t
*
spr1
,
sprite_t
*
spr2
){
SDL_bool
has_collided
(
sprite_t
*
spr1
,
sprite_t
*
spr2
){
return
SDL_HasIntersection
(
&
spr1
->
rect
,
&
spr2
->
rect
);
}
...
...
@@ -328,6 +342,16 @@ int estFini(world_t *world){
return
world
->
gameover
;
}
void
set_portable
(
sprite_t
*
ingredient
){
//Signale que l'ingredient est portée
ingredient
->
etat
=
PORTE
;
}
void
set_posee
(
sprite_t
*
ingredient
){
//Signale que l'ingrédient est posée
ingredient
->
etat
=
POSE
;
}
void
limites_externes
(
sprite_t
*
sprite
){
//Défini les limites selon les murs
if
(
sprite
->
rect
.
x
+
sprite
->
rect
.
w
>
SCREEN_WIDTH
-
SIZE_MUR
){
...
...
@@ -417,7 +441,18 @@ void gestion_events(SDL_Event *event, world_t *world){
set_gauche
(
&
world
->
joueur
);
modif_position
(
&
world
->
joueur
,
-
temp
,
0
);
break
;
//case SDLK_SPACE:
case
SDLK_SPACE
:
//Récupération des ingrédients du frigo
if
(
has_collided
(
&
world
->
frigo
,
&
world
->
joueur
)
==
SDL_TRUE
){
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
SDL_bool
collision
=
has_collided
(
&
world
->
frigo
,
&
world
->
en_cuisine
[
i
]);
if
(
collision
==
SDL_TRUE
){
set_portable
(
&
world
->
en_cuisine
[
i
]);
handle_deplacement_ingredient
(
&
world
->
joueur
,
&
world
->
en_cuisine
[
i
]);
}
}
}
break
;
}
}
}
...
...
This diff is collapsed.
Click to expand it.
logique.h
+
21
−
7
View file @
79410c1d
...
...
@@ -43,12 +43,12 @@ typedef struct sprite_s sprite_t;
* \brief Representation des stocks, du menu commandé par le client, et du score.
*/
struct
stock_s
{
sprite_t
stock_tomate
;
/*!< stock de tomates*/
sprite_t
stock_tomate
[
QTE_STOCK
]
;
/*!< stock de tomates*/
sprite_t
stock_pain
[
2
];
/*!< stock de pains*/
sprite_t
stock_steak
;
/*!< stock de steaks*/
sprite_t
stock_salade
;
/*!< stock de salade*/
sprite_t
stock_fromage
;
/*!< stock de fromage*/
sprite_t
stock_cornichon
;
/*!< stock de cornichon*/
sprite_t
stock_steak
[
QTE_STOCK
]
;
/*!< stock de steaks*/
sprite_t
stock_salade
[
QTE_STOCK
]
;
/*!< stock de salade*/
sprite_t
stock_fromage
[
QTE_STOCK
]
;
/*!< stock de fromage*/
sprite_t
stock_cornichon
[
QTE_STOCK
]
;
/*!< stock de cornichon*/
int
score
;
/*!< Score actuel*/
char
commande
[
5
];
/*!< tableau correspondant à un plat à faire*/
};
...
...
@@ -188,6 +188,20 @@ int get_cuisson (sprite_t *ingre);
*/
void
set_cuisson
(
sprite_t
*
ingre
,
int
cuisson
);
/**
* @brief signale que l'ingrédient est posée
*
* @param ingredient
*/
void
set_posee
(
sprite_t
*
ingredient
);
/**
* @brief Signale que l'ingrédient est portée
*
* @param ingredient
*/
void
set_portable
(
sprite_t
*
ingredient
);
/**
* @brief Ajoute à la position du sprite les valeurs indiquées
*
...
...
@@ -201,9 +215,9 @@ void modif_position (sprite_t *sprite, int x_move, int y_move);
* \brief Vérifie si deux sprites sont en collisions
* \param spr1 Sprite
* \param spr2 Sprite
* \param
int
0 si faux, 1 si vrai
* \param
SDL_bool
0 si faux, 1 si vrai
*/
int
has_collided
(
sprite_t
*
spr1
,
sprite_t
*
spr2
);
SDL_bool
has_collided
(
sprite_t
*
spr1
,
sprite_t
*
spr2
);
/**
...
...
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