adding the game_over menu and fonction to continue the game (hide_game_over)

This commit is contained in:
Clément Le Bihan
2020-04-30 16:02:47 +02:00
parent 19ba6bef22
commit 7dd9126045
6 changed files with 63 additions and 8 deletions
+1 -1
View File
@@ -298,7 +298,7 @@ add_executable(my_rpg
include/components/attack_component.h
src/systems/combat_methods.c
src/combat/attacks.c
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h)
src/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h src/systems/game_over.c include/systems/game_over.h)
add_compile_options(-W -Wall -Wextra -Wshadow)
+2 -1
View File
@@ -40,7 +40,8 @@ SRC = src/main.c \
src/enemy_dataloader.c \
src/combat/attacks.c \
src/player_utilities.c \
src/systems/inventory.c
src/systems/inventory.c \
src/systems/game_over.c
OBJ = $(SRC:%.c=%.o)
+17
View File
@@ -0,0 +1,17 @@
/*
** EPITECH PROJECT, 2019
** MUL_my_runner_2019
** File description:
** game_over
*/
#ifndef MY_RPG_GAME_OVER_H
#define MY_RPG_GAME_OVER_H
#include "engine.h"
#include <stdbool.h>
bool hide_game_over(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
enum gc_mousekeys key);
#endif //MY_RPG_GAME_OVER_H
+7 -6
View File
@@ -4,10 +4,11 @@
<font src="assets/fonts/roboto.ttf" />
</data>
<gc_entities>
<camera x="0" y="0" />
<panel src="panel" x="50%" y="45%" width="300" height="69%"/>
<text text="GAME OVER" x="50%" y="25%" resize="false"/>
<button text="Restart Game" x="50%" y="50%" click="start_button" color="black" width="200" resize="false" />
<button text="Quit game" x="50%" y="61%" click="quit" color="black" width="200" resize="false" />
</gc_entities>
<camera x="0" y="0" />
<panel src="background" x="50%" y="50%" width="100%" height="100%" tag="game_over" />
<panel src="panel" x="50%" y="60%" width="50%" height="55%" tag="game_over" />
<button text="Continue" x="50%" y="47%" click="hide_game_over" color="black" width="30%" height="20%" resize="false" tag="game_over" />
<button text="Restart Game" x="50%" y="61%" click="start_button" color="black" width="30%" height="20%" resize="false" tag="game_over" />
<button text="Quit game" x="50%" y="75s%" click="quit" color="black" width="30%" height="20%" resize="false" tag="game_over" />
</gc_entities>
</gc_scene>
+2
View File
@@ -26,6 +26,7 @@
#include "my.h"
#include "map_editor.h"
#include "components/xp_component.h"
#include "systems/game_over.h"
#include <malloc.h>
const struct callback callbacks[] = {
@@ -45,6 +46,7 @@ const struct callback callbacks[] = {
{"action1", &dialog_input1},
{"action2", &dialog_input2},
{"action3", &dialog_input3},
{"hide_game_over", &hide_game_over},
{NULL, NULL}
};
+34
View File
@@ -0,0 +1,34 @@
/*
** EPITECH PROJECT, 2019
** MUL_my_runner_2019
** File description:
** game_over
*/
#include <stdbool.h>
#include "engine.h"
#include "components/health_component.h"
#include "my.h"
#include "components/tag_component.h"
bool hide_game_over(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
enum gc_mousekeys key)
{
gc_scene *scene = engine->scene;
gc_list *list = scene->get_entity_by_cmp(scene, "tag_component");
gc_entity *player = scene->get_entity(scene, 50);
struct health_component *hc;
if (!player)
return (true);
hc = GETCMP(player, health_component);
if (!hc)
return (true);
hc->dead = false;
hc->health = hc->health_max;
for (gc_list *li = list; li; li = li->next) {
if (!my_strcmp(GETCMP(li->data, tag_component)->tag, "game_over"))
((gc_entity *)li->data)->destroy(li->data, scene);
}
return (true);
}