mirror of
https://git.planet-casio.com/Slyvtt/Collab_RPG.git
synced 2025-05-28 22:45:20 +02:00
Ran clang-format
This commit is contained in:
parent
fe824d7340
commit
a27ad9a14f
2 changed files with 68 additions and 73 deletions
50
src/game.c
50
src/game.c
|
@ -169,39 +169,39 @@ void game_get_inputs(Game *game) {
|
|||
} else if(game->inventory.open) {
|
||||
if(keydown(KEY_LEFT))
|
||||
inventory_move_selection(&game->inventory, D_LEFT);
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_LEFT)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_LEFT)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
if(keydown(KEY_RIGHT))
|
||||
inventory_move_selection(&game->inventory, D_RIGHT);
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_RIGHT)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_RIGHT)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
if(keydown(KEY_UP))
|
||||
inventory_move_selection(&game->inventory, D_UP);
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_UP)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_UP)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
if(keydown(KEY_DOWN))
|
||||
inventory_move_selection(&game->inventory, D_DOWN);
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_DOWN)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_DOWN)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
if(keydown(KEY_OPTN))
|
||||
inventory_move_from_selected(&game->inventory);
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_OPTN)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
/* TODO: Make something cleaner */
|
||||
while(keydown(KEY_OPTN)) {
|
||||
clearevents();
|
||||
sleep();
|
||||
}
|
||||
if(keydown(KEY_SQUARE)) {
|
||||
inventory_use(&game->inventory, &game->player);
|
||||
}
|
||||
|
|
|
@ -10,20 +10,13 @@ extern bopti_image_t selected_img;
|
|||
extern bopti_image_t player_male_inv_img;
|
||||
extern bopti_image_t player_female_inv_img;
|
||||
|
||||
char item_types[I_AMOUNT] = {
|
||||
IT_NONE,
|
||||
IT_ARMOR,
|
||||
IT_WEAPON,
|
||||
IT_WEAPON,
|
||||
IT_FOOD,
|
||||
IT_FOOD,
|
||||
IT_TALISMAN
|
||||
};
|
||||
char item_types[I_AMOUNT] = {IT_NONE, IT_ARMOR, IT_WEAPON, IT_WEAPON,
|
||||
IT_FOOD, IT_FOOD, IT_TALISMAN};
|
||||
|
||||
void inventory_init(Inventory *inventory) {
|
||||
inventory->open = 0;
|
||||
memset(inventory->slots, 0, sizeof(Slot)*SLOT_NUM);
|
||||
memset(inventory->equipped, 0, sizeof(Slot)*3);
|
||||
memset(inventory->slots, 0, sizeof(Slot) * SLOT_NUM);
|
||||
memset(inventory->equipped, 0, sizeof(Slot) * 3);
|
||||
inventory->selected = -1;
|
||||
inventory->selection = 0;
|
||||
}
|
||||
|
@ -37,12 +30,12 @@ void inventory_draw(Inventory *inventory, Player *player) {
|
|||
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING, &items_img,
|
||||
inventory->slots[i].i * SLOT_W, 0, SLOT_W, SLOT_H,
|
||||
DIMAGE_NONE);
|
||||
if(i == inventory->selection){
|
||||
if(i == inventory->selection) {
|
||||
dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING,
|
||||
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING,
|
||||
&selection_img);
|
||||
}
|
||||
if(i == inventory->selected){
|
||||
if(i == inventory->selected) {
|
||||
dimage(SLOT_X + (i % SLOT_COLUMNS) * SLOT_SPACING,
|
||||
SLOT_Y + (i / SLOT_COLUMNS) * SLOT_SPACING,
|
||||
&selected_img);
|
||||
|
@ -75,7 +68,8 @@ char inventory_add(Inventory *inventory, Item item) {
|
|||
}
|
||||
|
||||
void inventory_move_from_selected(Inventory *inventory) {
|
||||
if(inventory->selected < 0) return;
|
||||
if(inventory->selected < 0)
|
||||
return;
|
||||
Slot current = inventory->slots[inventory->selection];
|
||||
Slot new = inventory->slots[inventory->selected];
|
||||
inventory->slots[inventory->selection] = new;
|
||||
|
@ -84,46 +78,47 @@ void inventory_move_from_selected(Inventory *inventory) {
|
|||
|
||||
void inventory_use(Inventory *inventory, Player *player) {
|
||||
Item item = inventory->slots[inventory->selection].i;
|
||||
switch(item_types[item]){
|
||||
case IT_TALISMAN:
|
||||
inventory->equipped[0] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_ARMOR:
|
||||
inventory->equipped[1] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_WEAPON:
|
||||
inventory->equipped[2] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_FOOD:
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch(item_types[item]) {
|
||||
case IT_TALISMAN:
|
||||
inventory->equipped[0] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_ARMOR:
|
||||
inventory->equipped[1] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_WEAPON:
|
||||
inventory->equipped[2] = inventory->slots[inventory->selection];
|
||||
break;
|
||||
case IT_FOOD:
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
inventory->slots[inventory->selection].i = I_NONE;
|
||||
inventory->slots[inventory->selection].durability = 255;
|
||||
}
|
||||
|
||||
void inventory_unequip(Inventory *inventory, ItemType type) {
|
||||
if(inventory->slots[inventory->selection].i) return;
|
||||
switch(type){
|
||||
case IT_TALISMAN:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[0];
|
||||
inventory->equipped[0].i = I_NONE;
|
||||
inventory->equipped[0].durability = 255;
|
||||
break;
|
||||
case IT_ARMOR:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[1];
|
||||
inventory->equipped[1].i = I_NONE;
|
||||
inventory->equipped[1].durability = 255;
|
||||
break;
|
||||
case IT_WEAPON:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[2];
|
||||
inventory->equipped[2].i = I_NONE;
|
||||
inventory->equipped[2].durability = 255;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if(inventory->slots[inventory->selection].i)
|
||||
return;
|
||||
switch(type) {
|
||||
case IT_TALISMAN:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[0];
|
||||
inventory->equipped[0].i = I_NONE;
|
||||
inventory->equipped[0].durability = 255;
|
||||
break;
|
||||
case IT_ARMOR:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[1];
|
||||
inventory->equipped[1].i = I_NONE;
|
||||
inventory->equipped[1].durability = 255;
|
||||
break;
|
||||
case IT_WEAPON:
|
||||
inventory->slots[inventory->selection] = inventory->equipped[2];
|
||||
inventory->equipped[2].i = I_NONE;
|
||||
inventory->equipped[2].durability = 255;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue