N
nlolotte
Guest
Hello,
I am looking for some help improving and in some parts, re-doing my inventory system. I made the inventory in the early stages of developing my game. Since then, It doesn't really seem fit for purpose and also has a few flaws.
This is a video fo the inventory thus far:
This is how my inventory is set up presently.
I'd like to make a scrollable grid inventory, how can I approach this?
Thank you.
I am looking for some help improving and in some parts, re-doing my inventory system. I made the inventory in the early stages of developing my game. Since then, It doesn't really seem fit for purpose and also has a few flaws.
- The way I am controlling the cursor is completely wrong.
Code:
/// @description Check Position
if global.cursor_pos = 1
{
x = obj_inventory_cell_1.x;
y = obj_inventory_cell_1.y;
}
if global.cursor_pos = 2
{
x = obj_inventory_cell_2.x;
y = obj_inventory_cell_2.y;
}
if global.cursor_pos = 3
{
x = obj_inventory_cell_3.x;
y = obj_inventory_cell_3.y;
}
if global.cursor_pos = 4
{
x = obj_inventory_cell_4.x;
y = obj_inventory_cell_4.y;
}
Etc...
//Get Input
scr_input();
//Left
if leftkeypressed
{
if global.cursor_pos = 1
{
global.cursor_pos = 48;
exit;
}
if global.cursor_pos = 2
{
global.cursor_pos = 1;
exit;
}
if global.cursor_pos = 3
{
global.cursor_pos = 2;
exit;
}
Etc.....
- The way I have created the inventory is poorly optimized and uses alot of resources. 48 different boxes to contain the items. This also allows for the cursor to move accross a space that doesnt have an item in it.
This is a video fo the inventory thus far:
This is how my inventory is set up presently.
Code:
//Initialize Variables
global.weapon_in_inv = 0;
globalvar max_weapon_slots;
max_weapon_slots = 50;
//Create Inventory Slots
var i;
for(i = 0; i <= max_weapon_slots; i ++)
{
global.weapon_inventory[i,0] = ""; //Name
global.weapon_inventory[i,1] = ""; //Description
global.weapon_inventory[i,2] = ""; //Stackable?
global.weapon_inventory[i,3] = ""; //Quantity
global.weapon_inventory[i,4] = ""; //Inventory Sprite
global.weapon_inventory[i,5] = ""; //Weapon ID
global.weapon_inventory[i,6] = ""; //Added STR
global.weapon_inventory[i,7] = ""; //Added CON
global.weapon_inventory[i,8] = ""; //Added INT
global.weapon_inventory[i,9] = ""; //Added LCK
global.weapon_inventory[i,10] = ""; //Attack Power
global.weapon_inventory[i,11] = ""; //Type: 0 - Empty, 1 - Stab, 2 - Slash, 3 - Swing
global.weapon_inventory[i,12] = ""; //Atrribute: 0 - Nothing, 1 - Poison, 2 - Burn
global.weapon_inventory[i,13] = ""; //Atrribute Chance
global.weapon_inventory[i,14] = ""; //Attack Speed
}
//Define Weapons Inventory
global.weapon[0,0] = "EMPTY HAND";
global.weapon[0,1] = "----";
global.weapon[0,2] = false;
global.weapon[0,3] = 1;
global.weapon[0,4] = spr_inventory_empty_hand;
global.weapon[0,5] = 1;
global.weapon[0,6] = 0;
global.weapon[0,7] = 0;
global.weapon[0,8] = 0;
global.weapon[0,9] = 0;
global.weapon[0,10] = 0;
global.weapon[0,11] = 0;
global.weapon[0,12] = 0;
global.weapon[0,13] = 0;
global.weapon[0,14] = 18;
global.weapon[1,0] = "BASIC WEAPON";
global.weapon[1,1] = "THIS WEAPON SWINGS.";
global.weapon[1,2] = false;
global.weapon[1,3] = 1;
global.weapon[1,4] = spr_inventory_basic_weapon;
global.weapon[1,5] = 2;
global.weapon[1,6] = 3;
global.weapon[1,7] = 0;
global.weapon[1,8] = 0;
global.weapon[1,9] = 0;
global.weapon[1,10] = 32;
global.weapon[1,11] = 3;
global.weapon[1,12] = 0;
global.weapon[1,13] = 0;
global.weapon[1,14] = 14;
global.weapon[2,0] = "TEST WEAPON 1";
global.weapon[2,1] = "THIS WEAPON SLASHES.";
global.weapon[2,2] = false;
global.weapon[2,3] = 2;
global.weapon[2,4] = spr_inventory_test_weapon_1;
global.weapon[2,5] = 3;
global.weapon[2,6] = 7;
global.weapon[2,7] = 4;
global.weapon[2,8] = 3;
global.weapon[2,9] = 0;
global.weapon[2,10] = 15;
global.weapon[2,11] = 2;
global.weapon[2,12] = 0;
global.weapon[2,13] = 0;
global.weapon[2,14] = 15;
global.weapon[3,0] = "TEST WEAPON 2";
global.weapon[3,1] = "THIS WEAPON STABS.";
global.weapon[3,2] = false;
global.weapon[3,3] = 1;
global.weapon[3,4] = spr_inventory_test_weapon_2;
global.weapon[3,5] = 4;
global.weapon[3,6] = 1;
global.weapon[3,7] = 2;
global.weapon[3,8] = 4;
global.weapon[3,9] = 6;
global.weapon[3,10] = 5;
global.weapon[3,11] = 1;
global.weapon[3,12] = 0;
global.weapon[3,13] = 0;
global.weapon[3,14] = 16;
Etc...
Code:
//Add Weapon To Inventory
var i;
for(i = 0; i < max_weapon_slots; i += 1)
{
if(global.weapon_inventory[i,0] == "")
{
global.weapon_inventory[i,0] = argument0;
global.weapon_inventory[i,1] = argument1;
global.weapon_inventory[i,2] = argument2;
global.weapon_inventory[i,3] = argument3;
global.weapon_inventory[i,4] = argument4;
global.weapon_inventory[i,5] = argument5;
global.weapon_inventory[i,6] = argument6;
global.weapon_inventory[i,7] = argument7;
global.weapon_inventory[i,8] = argument8;
global.weapon_inventory[i,9] = argument9;
global.weapon_inventory[i,10] = argument10;
global.weapon_inventory[i,11] = argument11;
global.weapon_inventory[i,12] = argument12;
global.weapon_inventory[i,13] = argument13;
global.weapon_inventory[i,14] = argument14;
global.weapon_in_inv += 1;
i = max_weapon_slots;
}
if(global.weapon_inventory[i,0] == argument0 && global.weapon_inventory[i,2] == true)
{
global.weapon_inventory[i,3] += argument3;
global.weapon_in_inv += 1;
i = max_weapon_slots;
}
}
I'd like to make a scrollable grid inventory, how can I approach this?
Thank you.
Last edited: