mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2025-04-18 17:07:24 +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"))
|
indoor = int(input_map.get_property("indoor"))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Show a warning
|
# Show a warning
|
||||||
print(f"WARNING: Indoor property not found.\n")
|
print(f"WARNING: Indoor property not found.")
|
||||||
|
|
||||||
if indoor:
|
if indoor:
|
||||||
# Get the indoor tileset
|
# Get the indoor tileset
|
||||||
|
|
16
src/config.h
16
src/config.h
|
@ -27,7 +27,13 @@
|
||||||
#define P_HEIGHT 16
|
#define P_HEIGHT 16
|
||||||
/* Max number of dynamic NPCs. */
|
/* Max number of dynamic NPCs. */
|
||||||
#define NPC_STACK_SIZE 256
|
#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
|
#else
|
||||||
/* The tile size */
|
/* The tile size */
|
||||||
#define T_HEIGHT 8
|
#define T_HEIGHT 8
|
||||||
|
@ -40,7 +46,13 @@
|
||||||
#define P_HEIGHT 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
|
#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
|
#endif
|
||||||
|
|
||||||
/* SPEED should NOT be 8 or bigger: it may cause bugs when handling
|
/* 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;
|
} Item;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Item i;
|
Item i : 4;
|
||||||
unsigned char durability;
|
unsigned char durability;
|
||||||
} Slot;
|
} Slot;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
/* Backpack slots. */
|
||||||
Slot slots[SLOT_NUM];
|
Slot slots[SLOT_NUM];
|
||||||
Slot talisman;
|
/* Equipped items: first slot: talisman, second slot: armor, last slot:
|
||||||
Slot armor;
|
weapon. */
|
||||||
Slot weapon;
|
Slot equipped[3];
|
||||||
|
/* 1 if the inventory is open. */
|
||||||
char open : 1;
|
char open : 1;
|
||||||
} Inventory;
|
} Inventory;
|
||||||
|
|
||||||
|
|
|
@ -9,40 +9,21 @@ extern bopti_image_t player_female_inv_img;
|
||||||
|
|
||||||
void inventory_draw(Game *game, Inventory *inventory) {
|
void inventory_draw(Game *game, Inventory *inventory) {
|
||||||
size_t i;
|
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) {
|
if(inventory->open) {
|
||||||
dimage(0, 0, &inventory_img);
|
dimage(0, 0, &inventory_img);
|
||||||
for(i = 0; i < SLOT_NUM; i++) {
|
for(i = 0; i < SLOT_NUM; i++) {
|
||||||
#if GINT_RENDER_RGB
|
dsubimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING,
|
||||||
dsubimage(272 + (i % SLOT_COLUMNS) * 32,
|
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, &items_img,
|
||||||
87 + (i / SLOT_COLUMNS) * 32, &items_img,
|
inventory->slots[i].i * SLOT_W, 0, SLOT_W, SLOT_H,
|
||||||
inventory->slots[i].i * 28, 0, 28, 27, DIMAGE_NONE);
|
DIMAGE_NONE);
|
||||||
#else
|
}
|
||||||
dsubimage(88 + (i % SLOT_COLUMNS) * 12,
|
for(i = 0; i < 3; i++) {
|
||||||
24 + (i / SLOT_COLUMNS) * 12, &items_img,
|
dsubimage(SLOT_X_EQUIPPED, SLOT_Y + i * SLOT_SPACING, &items_img,
|
||||||
inventory->slots[i].i * 8, 0, 8, 8, DIMAGE_NONE);
|
inventory->equipped[i].i * SLOT_W, 0, SLOT_W, SLOT_H,
|
||||||
#endif
|
DIMAGE_NONE);
|
||||||
}
|
}
|
||||||
#if GINT_RENDER_RGB
|
#if GINT_RENDER_RGB
|
||||||
dsubimage(222, 87, &items_img, inventory->talisman.i * 28, 0, 28, 27,
|
/* Render the player between the two swords if we are on cg. */
|
||||||
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
|
|
||||||
dimage(183, 20,
|
dimage(183, 20,
|
||||||
game->player.is_male ? &player_male_inv_img
|
game->player.is_male ? &player_male_inv_img
|
||||||
: &player_female_inv_img);
|
: &player_female_inv_img);
|
||||||
|
|
Loading…
Add table
Reference in a new issue