mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-05-28 08:57:52 +00:00
adding inventory pictures
This commit is contained in:
+1
-1
@@ -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/player_utilities.c include/player_utilities.h src/systems/inventory.c include/systems/inventory.h)
|
||||
|
||||
add_compile_options(-W -Wall -Wextra -Wshadow)
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 821 B |
Binary file not shown.
|
After Width: | Height: | Size: 889 B |
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 968 B |
Binary file not shown.
|
After Width: | Height: | Size: 927 B |
@@ -12,7 +12,11 @@ typedef enum display_type
|
||||
SELECT_TILE_DISPLAY,
|
||||
XP_DISPLAY,
|
||||
HEALTH_DISPLAY,
|
||||
HEALTH_DISPLAY_ENNEMY
|
||||
HEALTH_DISPLAY_ENNEMY,
|
||||
INVENTORY_SLOT_1,
|
||||
INVENTORY_SLOT_2,
|
||||
INVENTORY_SLOT_3,
|
||||
INVENTORY_SLOT_4
|
||||
} display_type_enum;
|
||||
|
||||
struct game_display
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** My3D
|
||||
** File description:
|
||||
** inventory
|
||||
*/
|
||||
|
||||
#ifndef MY_RPG_INVENTORY_H
|
||||
#define MY_RPG_INVENTORY_H
|
||||
|
||||
#include "engine.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
void display_inventory_object(gc_scene *scene, struct renderer *rend, int nb);
|
||||
bool toggle_inventory(gc_engine *engine);
|
||||
|
||||
#endif //MY_RPG_INVENTORY_H
|
||||
@@ -120,6 +120,13 @@
|
||||
<sprite name="item_rock_1" src="assets/sprites/items/generic-rpg-rock04.png" />
|
||||
<sprite name="item_rock_2" src="assets/sprites/items/generic-rpg-rock05.png" />
|
||||
|
||||
|
||||
<sprite name="empty_slot" src="assets/sprites/inventory/empty.png" />
|
||||
<sprite name="slot_1" src="assets/sprites/inventory/fireball_upgrade.png" />
|
||||
<sprite name="slot_2" src="assets/sprites/inventory/water_jet_upgrade.png" />
|
||||
<sprite name="slot_3" src="assets/sprites/inventory/uppercut_upgrade.png" />
|
||||
<sprite name="slot_4" src="assets/sprites/inventory/shield_upgrade.png" />
|
||||
|
||||
<sprite name="main_ui_game" src="assets/ui/health_and_xp.png" />
|
||||
<music src="assets/musics/windless_slopes.ogg"/>
|
||||
<font src="assets/fonts/roboto.ttf" />
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
<panel src="panel" x="50%" y="50%" width="40%" height="60%" tag="inventory" />
|
||||
<text text="Inventory" x="50%" y="30%" tag="inventory" />
|
||||
<button text="Go back" x="50%" y="71%" click="toggle_inventory" color="black" width="200" resize="false" tag="inventory" />
|
||||
<button sprite="texture" x="40%" y="40%" width="%" height="10%" tooltip="Object 1" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="selected_tile" />
|
||||
<button sprite="texture" x="40%" y="40%" width="%" height="10%" tooltip="Fireball upgrade" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="inventory_1" />
|
||||
</button>
|
||||
<button sprite="texture" x="60%" y="40%" width="%" height="10%" tooltip="Object 2" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="selected_tile" />
|
||||
<button sprite="texture" x="60%" y="40%" width="%" height="10%" tooltip="Water Jet upgrade" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="inventory_2" />
|
||||
</button>
|
||||
<button sprite="texture" x="40%" y="60%" width="%" height="10%" tooltip="Object 3" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="selected_tile" />
|
||||
<button sprite="texture" x="40%" y="60%" width="%" height="10%" tooltip="Uppercut upgrade" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="inventory_3" />
|
||||
</button>
|
||||
<button sprite="texture" x="60%" y="60%" width="%" height="10%" tooltip="Object 4" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="selected_tile" />
|
||||
<button sprite="texture" x="60%" y="60%" width="%" height="10%" tooltip="Shield upgrade" tooltip_y="-7" size="15" tag="inventory">
|
||||
<game_display stats="inventory_4" />
|
||||
</button>
|
||||
</gc_entities>
|
||||
@@ -41,6 +41,14 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
||||
} if (!my_strcmp(display_type, "health")) {
|
||||
cmp->type = HEALTH_DISPLAY;
|
||||
rend->destroy = &text_safe_destroy;
|
||||
} if (!my_strcmp(display_type, "inventory_1")) {
|
||||
cmp->type = INVENTORY_SLOT_1;
|
||||
}if (!my_strcmp(display_type, "inventory_2")) {
|
||||
cmp->type = INVENTORY_SLOT_2;
|
||||
}if (!my_strcmp(display_type, "inventory_3")) {
|
||||
cmp->type = INVENTORY_SLOT_3;
|
||||
}if (!my_strcmp(display_type, "inventory_4")) {
|
||||
cmp->type = INVENTORY_SLOT_4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <malloc.h>
|
||||
#include "components/health_component.h"
|
||||
#include "sprite.h"
|
||||
#include "systems/inventory.h"
|
||||
|
||||
void display_current_texture(gc_scene *scene, struct renderer *rend)
|
||||
{
|
||||
@@ -77,6 +78,10 @@ float dtime)
|
||||
display_current_texture(scene, rend);
|
||||
return;
|
||||
}
|
||||
if (disp->type >= INVENTORY_SLOT_1 && disp->type <= INVENTORY_SLOT_4 && rend->type == GC_TEXTUREREND) {
|
||||
display_inventory_object(scene, rend, disp->type - INVENTORY_SLOT_1 + 1);
|
||||
return;
|
||||
}
|
||||
if (disp->type == XP_DISPLAY && rend->type == GC_TXTREND) {
|
||||
display_current_xp(scene, rend);
|
||||
return;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "system.h"
|
||||
#include "components/game_manager.h"
|
||||
#include "systems/game_manager_system.h"
|
||||
#include "systems/inventory.h"
|
||||
|
||||
bool toggle_pause(gc_engine *engine)
|
||||
{
|
||||
@@ -21,7 +22,7 @@ bool toggle_pause(gc_engine *engine)
|
||||
|
||||
scene->is_paused = !scene->is_paused;
|
||||
if (scene->is_paused) {
|
||||
prefab_load(engine, "prefabs/pause.gcprefab");
|
||||
prefab_load(engine,"prefabs/pause.gcprefab");
|
||||
return (true);
|
||||
}
|
||||
list = scene->get_entity_by_cmp(scene, "tag_component");
|
||||
@@ -32,24 +33,6 @@ bool toggle_pause(gc_engine *engine)
|
||||
return (true);
|
||||
}
|
||||
|
||||
bool toggle_inventory(gc_engine *engine)
|
||||
{
|
||||
gc_scene *scene = engine->scene;
|
||||
gc_list *list;
|
||||
|
||||
scene->is_paused = !scene->is_paused;
|
||||
if (scene->is_paused) {
|
||||
prefab_load(engine, "prefabs/inventory.gcprefab");
|
||||
return (true);
|
||||
}
|
||||
list = scene->get_entity_by_cmp(scene, "tag_component");
|
||||
for (gc_list *li = list; li; li = li->next) {
|
||||
if (!my_strcmp(GETCMP(li->data, tag_component)->tag, "inventory"))
|
||||
((gc_entity *)li->data)->destroy(li->data, scene);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
|
||||
static void key_pressed(gc_engine *engine, va_list args)
|
||||
{
|
||||
gc_keybindings key = va_arg(args, gc_keybindings);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** My3D
|
||||
** File description:
|
||||
** inventory
|
||||
*/
|
||||
|
||||
#include "list.h"
|
||||
#include "scene.h"
|
||||
#include "sprite.h"
|
||||
#include "prefab.h"
|
||||
#include "components/renderer.h"
|
||||
#include "components/tag_component.h"
|
||||
#include "my.h"
|
||||
|
||||
void display_inventory_object(gc_scene *scene, struct renderer *rend, int nb)
|
||||
{
|
||||
char *textures[5] = {"empty_slot", "slot_1", "slot_2", "slot_3", "slot_4"};
|
||||
if (false)
|
||||
nb = 0;
|
||||
((gc_sprite *)rend->data)->texture = scene->get_data(scene, "sprite", textures[nb]);
|
||||
}
|
||||
|
||||
bool toggle_inventory(gc_engine *engine)
|
||||
{
|
||||
gc_scene *scene = engine->scene;
|
||||
gc_list *list;
|
||||
|
||||
scene->is_paused = !scene->is_paused;
|
||||
if (scene->is_paused) {
|
||||
prefab_load(engine, "prefabs/inventory.gcprefab");
|
||||
return (true);
|
||||
}
|
||||
list = scene->get_entity_by_cmp(scene, "tag_component");
|
||||
for (gc_list *li = list; li; li = li->next) {
|
||||
if (!my_strcmp(GETCMP(li->data, tag_component)->tag, "inventory"))
|
||||
((gc_entity *)li->data)->destroy(li->data, scene);
|
||||
}
|
||||
return (true);
|
||||
}
|
||||
Reference in New Issue
Block a user