mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2025-04-15 23:47:22 +02:00
Cleaner inventory rendering
This commit is contained in:
parent
311b7f27df
commit
5dab7f9f18
5 changed files with 33 additions and 38 deletions
Binary file not shown.
Before Width: | Height: | Size: 666 B After Width: | Height: | Size: 684 B |
|
@ -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
|
||||
|
|
20
src/config.h
20
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
|
||||
|
|
10
src/game.h
10
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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue