diff --git a/assets-cg/items.png b/assets-cg/items.png index 3730ee2..08ed2c2 100644 Binary files a/assets-cg/items.png and b/assets-cg/items.png differ diff --git a/assets/converters.py b/assets/converters.py index 2d267f9..c3ddc50 100644 --- a/assets/converters.py +++ b/assets/converters.py @@ -142,7 +142,7 @@ def convert_map(input: str, output: str, params: dict, target): indoor = int(input_map.get_property("indoor")) except Exception as e: # Show a warning - print(f"WARNING: Indoor property not found.\n") + print(f"WARNING: Indoor property not found.") if indoor: # Get the indoor tileset diff --git a/src/config.h b/src/config.h index 67e0b3a..2176fa1 100644 --- a/src/config.h +++ b/src/config.h @@ -25,9 +25,15 @@ /* The size of the player */ #define P_WIDTH 16 #define P_HEIGHT 16 -/*Max number of dynamic NPCs.*/ +/* Max number of dynamic NPCs. */ #define NPC_STACK_SIZE 256 - +/* The position of the slots in the inventory */ +#define SLOT_Y 87 +#define SLOT_X_EQUIPPED 222 +#define SLOT_X 272 +#define SLOT_W 28 +#define SLOT_H 27 +#define SLOT_SPACING 32 #else /* The tile size */ #define T_HEIGHT 8 @@ -38,9 +44,15 @@ /* The player size */ #define P_WIDTH 8 #define P_HEIGHT 8 -/*Max number of "dynamic" NPCs. We are starved for static ram on fx !*/ +/* Max number of "dynamic" NPCs. We are starved for static ram on fx ! */ #define NPC_STACK_SIZE 32 - +/* The position of the slots in the inventory */ +#define SLOT_Y 24 +#define SLOT_X_EQUIPPED 72 +#define SLOT_X 88 +#define SLOT_W 8 +#define SLOT_H 8 +#define SLOT_SPACING 12 #endif /* SPEED should NOT be 8 or bigger: it may cause bugs when handling diff --git a/src/game.h b/src/game.h index a58a438..be88cd4 100644 --- a/src/game.h +++ b/src/game.h @@ -33,15 +33,17 @@ typedef enum { } Item; typedef struct { - Item i; + Item i : 4; unsigned char durability; } Slot; typedef struct { + /* Backpack slots. */ Slot slots[SLOT_NUM]; - Slot talisman; - Slot armor; - Slot weapon; + /* Equipped items: first slot: talisman, second slot: armor, last slot: + weapon. */ + Slot equipped[3]; + /* 1 if the inventory is open. */ char open : 1; } Inventory; diff --git a/src/inventory.c b/src/inventory.c index 1e135d7..b2a1145 100644 --- a/src/inventory.c +++ b/src/inventory.c @@ -9,40 +9,21 @@ extern bopti_image_t player_female_inv_img; void inventory_draw(Game *game, Inventory *inventory) { size_t i; - /* TODO: Cleanup! */ - inventory->slots[5].i = I_GLOVE; - inventory->armor.i = I_ARMOR; - inventory->talisman.i = I_TALISMAN; - inventory->weapon.i = I_SWORD; if(inventory->open) { dimage(0, 0, &inventory_img); for(i = 0; i < SLOT_NUM; i++) { -#if GINT_RENDER_RGB - dsubimage(272 + (i % SLOT_COLUMNS) * 32, - 87 + (i / SLOT_COLUMNS) * 32, &items_img, - inventory->slots[i].i * 28, 0, 28, 27, DIMAGE_NONE); -#else - dsubimage(88 + (i % SLOT_COLUMNS) * 12, - 24 + (i / SLOT_COLUMNS) * 12, &items_img, - inventory->slots[i].i * 8, 0, 8, 8, DIMAGE_NONE); -#endif + dsubimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING, + SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, &items_img, + inventory->slots[i].i * SLOT_W, 0, SLOT_W, SLOT_H, + DIMAGE_NONE); + } + for(i = 0; i < 3; i++) { + dsubimage(SLOT_X_EQUIPPED, SLOT_Y + i * SLOT_SPACING, &items_img, + inventory->equipped[i].i * SLOT_W, 0, SLOT_W, SLOT_H, + DIMAGE_NONE); } #if GINT_RENDER_RGB - dsubimage(222, 87, &items_img, inventory->talisman.i * 28, 0, 28, 27, - DIMAGE_NONE); - dsubimage(222, 87 + 32, &items_img, inventory->armor.i * 28, 0, 28, 27, - DIMAGE_NONE); - dsubimage(222, 87 + 64, &items_img, inventory->weapon.i * 28, 0, 28, 27, - DIMAGE_NONE); -#else - dsubimage(72, 24, &items_img, inventory->talisman.i * 8, 0, 8, 8, - DIMAGE_NONE); - dsubimage(72, 24 + 12, &items_img, inventory->armor.i * 8, 0, 8, 8, - DIMAGE_NONE); - dsubimage(72, 24 + 24, &items_img, inventory->weapon.i * 8, 0, 8, 8, - DIMAGE_NONE); -#endif -#if GINT_RENDER_RGB + /* Render the player between the two swords if we are on cg. */ dimage(183, 20, game->player.is_male ? &player_male_inv_img : &player_female_inv_img);