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
e37585e5
Commit
e37585e5
authored
4 years ago
by
vautrin33u
Browse files
Options
Downloads
Patches
Plain Diff
Interactions quasi-finis, reste interaction lorsque les burgers sont complets
parent
fddecdad
No related branches found
No related tags found
No related merge requests found
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Ressources/save.txt
+400
-400
400 additions, 400 deletions
Ressources/save.txt
logique.c
+61
-79
61 additions, 79 deletions
logique.c
logique.h
+4
-22
4 additions, 22 deletions
logique.h
with
465 additions
and
501 deletions
Ressources/save.txt
+
400
−
400
View file @
e37585e5
This diff is collapsed.
Click to expand it.
logique.c
+
61
−
79
View file @
e37585e5
...
...
@@ -285,64 +285,67 @@ void gestion_events(SDL_Event *event, world_t *world){
modif_position
(
&
world
->
joueur
,
-
temp
,
0
);
break
;
case
SDLK_SPACE
:
//Récupération des ingrédients du frigo
case
SDLK_SPACE
:
// POUR POSER DES OBJETS
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
sprite_t
*
ingredient
=
&
world
->
en_cuisine
[
i
];
sprite_t
*
joueur
=
&
world
->
joueur
;
//Interaction avec le frigo (récupérer les éléments un par un)
//Interaction avec le four
/*
if (has_interaction(joueur, &world->four) && has_collided(joueur, ingredient) && return_state(ingredient) == POSE && get_cuisson(ingredient) == CUIT && is_already_carrying(world->en_cuisine)==SDL_FALSE){
//On retire un ingrédient du feu
set_portable(ingredient);
handle_deplacement_ingredient(joueur, ingredient);
break;
}
*/
//Interaction avec le lavabo
/*
if (has_interaction(joueur, &world->lavabo) && has_collided(joueur, ingredient) && return_state(ingredient) == POSE && get_cuisson(ingredient) == PROPRE && is_already_carrying(world->en_cuisine)==SDL_FALSE){
//On retire un ingrédient du lavabo
set_portable(ingredient);
handle_deplacement_ingredient(joueur, ingredient);
break;
}
*/
if
(
has_interaction
(
joueur
,
&
world
->
frigo
)){
interaction_frigo
(
world
->
en_cuisine
,
joueur
,
&
world
->
frigo
);
}
if
(
has_interaction
(
joueur
,
&
world
->
four
)){
interaction_poser_four
(
world
->
en_cuisine
,
joueur
,
&
world
->
four
);
}
if
(
has_interaction
(
joueur
,
&
world
->
poubelle
)){
interaction_poubelle
(
world
->
en_cuisine
,
joueur
,
get_rect
(
&
world
->
frigo
));
//Interaction avec le frigo (récupérer les éléments un par un)
//Interaction avec le four
/*
if (has_interaction(joueur, &world->four) && has_collided(joueur, ingredient) && return_state(ingredient) == POSE && get_cuisson(ingredient) == CUIT && is_already_carrying(world->en_cuisine)==SDL_FALSE){
//On retire un ingrédient du feu
set_portable(ingredient);
handle_deplacement_ingredient(joueur, ingredient);
break;
}
*/
//Interaction avec le lavabo
/*
if (has_interaction(joueur, &world->lavabo) && has_collided(joueur, ingredient) && return_state(ingredient) == POSE && get_cuisson(ingredient) == PROPRE && is_already_carrying(world->en_cuisine)==SDL_FALSE){
//On retire un ingrédient du lavabo
set_portable(ingredient);
handle_deplacement_ingredient(joueur, ingredient);
break;
}
*/
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
frigo
)){
interaction_frigo
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
frigo
);
}
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
four
)){
interaction_poser
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
four
);
}
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
poubelle
)){
interaction_poubelle
(
world
->
en_cuisine
,
&
world
->
joueur
,
get_rect
(
&
world
->
frigo
));
}
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
lavabo
)){
interaction_poser
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
lavabo
);
}
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
envoi
)){
interaction_zone_envoi
(
world
,
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
envoi
);
}
//Interaction avec les comptoirs
for
(
int
i
=
0
;
i
<
NB_COMPT_1
;
i
++
){
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
comptoire
[
i
])){
interaction_poser
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
comptoire
[
i
]);
}
if
(
has_interaction
(
joueur
,
&
world
->
lavabo
)){
interaction_poser_lavabo
(
world
->
en_cuisine
,
joueur
,
&
world
->
lavabo
);
}
break
;
case
SDLK_RETURN
:
// Cas pour récupérer des objets
if
(
is_already_carrying
(
world
->
en_cuisine
)
==
SDL_FALSE
){
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
four
)){
interaction_reprendre
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
four
,
CUIT
);
}
if
(
has_interaction
(
joueur
,
&
world
->
envoi
)){
interaction_
zone_envoi
(
world
,
world
->
en_cuisine
,
joueur
,
&
world
->
envoi
);
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
lavabo
)){
interaction_
reprendre
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
lavabo
,
PROPRE
);
}
//Interaction avec les comptoirs
for
(
int
i
=
0
;
i
<
NB_COMPT_1
;
i
++
){
if
(
has_interaction
(
joueur
,
&
world
->
comptoire
[
i
])
&&
has_collided
(
joueur
,
ingredient
)
&&
return_state
(
ingredient
)
==
POSE
&&
is_already_carrying
(
world
->
en_cuisine
)
==
SDL_FALSE
){
//On retire un ingrédient
set_portable
(
ingredient
);
handle_deplacement_ingredient
(
joueur
,
ingredient
);
break
;
}
if
(
has_interaction
(
joueur
,
&
world
->
comptoire
[
i
])
&&
has_collided
(
joueur
,
ingredient
)
&&
return_state
(
ingredient
)
==
PORTE
){
//On pose un ingrédient
poser_ingredient
(
joueur
,
&
world
->
comptoire
[
i
],
ingredient
);
break
;
if
(
has_interaction
(
&
world
->
joueur
,
&
world
->
comptoire
[
i
])){
interaction_reprendre
(
world
->
en_cuisine
,
&
world
->
joueur
,
&
world
->
comptoire
[
i
],
PROPRE
);
}
}
}
break
;
}
}
}
...
...
@@ -382,43 +385,22 @@ void interaction_zone_envoi (world_t* world, sprite_t* ingredients, sprite_t* jo
}
}
void
interaction_poser_four
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
four
){
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
if
(
has_collided
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
PORTE
&&
get_cuisson
(
&
ingredients
[
i
])
==
CRU
){
//On pose un ingrédient pour le cuire
poser_ingredient
(
joueur
,
four
,
&
ingredients
[
i
]);
set_cuisson
(
&
ingredients
[
i
],
CUIT
);
break
;
}
}
}
void
interaction_reprendre_four
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
four
){
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
if
(
has_interaction
(
joueur
,
four
)
&&
has_collided
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
POSE
&&
get_cuisson
(
&
ingredients
[
i
])
==
CUIT
&&
is_already_carrying
(
ingredients
)
==
SDL_FALSE
){
set_portable
(
&
ingredients
[
i
]);
handle_deplacement_ingredient
(
joueur
,
&
ingredients
[
i
]);
break
;
}
}
}
void
interaction_poser_lavabo
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
lavabo
){
//Interaction avec le lavabo
void
interaction_poser
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
meuble
){
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
if
(
has_collided
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
PORTE
&&
get_cuisson
(
&
ingredients
[
i
])
==
SALE
){
//On pose un ingrédient pour le laver
poser_ingredient
(
joueur
,
lavabo
,
&
ingredients
[
i
]);
set_cuisson
(
&
ingredients
[
i
],
PROPRE
);
if
(
has_collided
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
PORTE
&&
((
meuble
->
nom
==
NOM_FOUR
&&
get_cuisson
(
&
ingredients
[
i
])
==
CRU
)
||
(
meuble
->
nom
==
NOM_LAVABO
&&
get_cuisson
(
&
ingredients
[
i
])
==
SALE
)
||
(
meuble
->
nom
==
MARQUEUR_COMPT
)))
{
//On pose un ingrédient et on change l'état si nécessaire
poser_ingredient
(
joueur
,
meuble
,
&
ingredients
[
i
]);
if
(
meuble
->
nom
==
NOM_FOUR
)
set_cuisson
(
&
ingredients
[
i
],
CUIT
);
if
(
meuble
->
nom
==
NOM_LAVABO
)
set_cuisson
(
&
ingredients
[
i
],
PROPRE
);
if
(
meuble
->
nom
==
NOM_COMPT
)
set_cuisson
(
&
ingredients
[
i
],
get_cuisson
(
&
ingredients
[
i
]));
break
;
}
}
}
void
interaction_reprendre
_lavabo
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
lavabo
){
void
interaction_reprendre
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
meuble
,
int
cuisson_attendue
){
for
(
int
i
=
0
;
i
<
INGREDIENT_DISPO
;
i
++
){
if
(
has_interaction
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
POSE
&&
get_cuisson
(
&
ingredients
[
i
])
==
PROPRE
&&
is_already_carrying
(
ingredients
)
==
SDL_FALSE
){
//On retire un ingrédient du lavabo
if
(
has_interaction
(
joueur
,
&
ingredients
[
i
])
&&
return_state
(
&
ingredients
[
i
])
==
POSE
&&
(
get_cuisson
(
&
ingredients
[
i
])
==
cuisson_attendue
||
meuble
->
nom
==
MARQUEUR_COMPT
)){
set_portable
(
&
ingredients
[
i
]);
handle_deplacement_ingredient
(
joueur
,
&
ingredients
[
i
]);
break
;
...
...
This diff is collapsed.
Click to expand it.
logique.h
+
4
−
22
View file @
e37585e5
...
...
@@ -84,31 +84,13 @@ int aleatoire (int a, int b);
void
interaction_poubelle
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
SDL_Rect
zone_reset
);
/**
* @brief Poser un objet sur le lavabo
*
* @param ingredients Tous les ingrédients disponibles sur le jeu
* @param joueur
* @param lavabo
*/
void
interaction_poser_lavabo
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
lavabo
);
/**
* @brief Reprendre un ingrédient du lavabo
*
* @param ingredients Tous les ingrédients dispo sur le jeu
* @param joueur
* @param lavabo
*/
void
interaction_reprendre_lavabo
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
lavabo
);
/**
* @brief Reprendre les ingrédients du four
* @brief Reprends l'objet posé sur un sprite, limité par son état de cuisson
*
* @param ingredients
* @param joueur
* @param
four
* @param
cuisson_attendue cuisson attendue avant de pouvoir récupérer l'objet
*/
void
interaction_reprendre
_four
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
four
);
void
interaction_reprendre
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
meuble
,
int
cuisson_attendue
);
/**
* @brief Poser dans le four un ingrédient
...
...
@@ -117,7 +99,7 @@ void interaction_reprendre_four(sprite_t* ingredients, sprite_t* joueur, sprite_
* @param joueur
* @param four
*/
void
interaction_poser
_four
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
four
);
void
interaction_poser
(
sprite_t
*
ingredients
,
sprite_t
*
joueur
,
sprite_t
*
meuble
);
/**
* @brief Envoie le plat, génère le score et reset les ingrédients
...
...
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