Starting to add the inventory.

This commit is contained in:
mibi88 2024-08-01 19:08:47 +02:00
parent 755ed1a1a8
commit cce7209221
7 changed files with 43 additions and 2 deletions

BIN
assets-fx/1b/inventory.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 608 B

View file

@ -12,6 +12,8 @@
#define GRAYMODEOK 1
#endif
#define SLOT_NUM 9
#if GINT_RENDER_RGB
/* The tile size */
#define T_HEIGHT 16

View file

@ -48,7 +48,7 @@ int (*_operations[OP_AMOUNT])(int, int) = {_op_null, _op_set, _op_add, _op_sub,
#define MIN(a, b) a < b ? a : b
char _message_buffer[MESSAGE_BUFFER_SZ];
char *_message_buffer;
char *events_parse_string(EventHandler *handler, char *message) {
size_t message_pos = 0;
char in_token = 0;

View file

@ -12,10 +12,28 @@ typedef enum { D_UP, D_DOWN, D_LEFT, D_RIGHT } Direction;
typedef enum { P_LEFTUP = -1, P_CENTER = 0, P_RIGHTDOWN = 1 } Checkpos;
typedef enum {
I_NONE,
I_ARMOR,
I_GLOVE,
I_BEER,
I_MILK,
I_TALISMAN,
I_AMOUNT
} Item;
typedef struct {
Item i;
unsigned char durability;
} Slot;
typedef struct {
Slot slots[SLOT_NUM];
} Inventory;
typedef struct {
uint32_t x1, y1;
uint32_t x2, y2;
} Collider;
/* Struct that define player parameters */

1
src/inventory.c Normal file
View file

@ -0,0 +1 @@
#include "inventory.h"

9
src/inventory.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef INVENTORY_H
#define INVENTORY_H
/* The structs related to the inventory are defined in game.h */
#include "game.h"
#endif

View file

@ -117,6 +117,16 @@ int main(void) {
}
timer_start(timer);
extern char *_message_buffer;
_message_buffer = NULL;
_message_buffer = malloc(MESSAGE_BUFFER_SZ);
if(!_message_buffer){
dtext(64, 64, C_BLACK, "Failed to allocate the message buffer: not "
"enough RAM available. Press any key to quit.");
dupdate();
getkey();
return 0;
}
game_init(&game);
#if USB_FEATURE
@ -213,5 +223,6 @@ int main(void) {
#endif
timer_stop(timer);
free(_message_buffer);
return 1;
}