S
Smallmak
Guest
Hello, I am working on creating an inventory system/spell system where players can drag their skills or items into 1 of 12 slots slots 1-3 are mouse buttons while the rest would correspond to number pad buttons. here is what I have so far
Create event ("tal" standing for "talents" or "spells");
under the step event I have this
and under the draw GUI event i have this
I am not really sure how to finish the system though. I already have it so I can drag the talent icons around but how to I make it so I can drop them in an equipment slot and how do I make it so each slot has a different button associated with it?
here are the sprites I have made and am working with. the equipment slots would be the 9 on the bottom of the one on the right hand side. if it would work better to have a separate sprite for the equipment slots I could make new sprites
Create event ("tal" standing for "talents" or "spells");
Code:
depth = -1;
scale = 2;
showTalents = false;
talSlots = 9
talRows = 6;
talColumns = 8;
selected_tal = 0;
pickedUpTalent = -1;
m_slotx = 0;
m_sloty = 0;
x_buffer = 3;
y_buffer = 3;
cellSize = 32;
tal_UI_width = sprite_get_width(sprite5)-32;
tal_UI_height = sprite_get_height(sprite5) -32;
spr_tal_UI = sprite5;
spr_tal_columns = sprite_get_width(sprite6)/cellSize;
spr_tal_rows = sprite_get_height(sprite6)/cellSize;
gui_width = display_get_gui_width();
gui_height = display_get_gui_height()
tal_UI_x = (gui_width/2)-(tal_UI_width/2 * scale);
tal_UI_y =(gui_height/2)-(tal_UI_height/2 * scale);
slotsX = tal_UI_x +(4*scale);
slotsY = tal_UI_y +(3*scale);
ds_Tal = ds_grid_create(1,talSlots);
ds_Tal[# 0, 0] = 1;
ds_Tal[# 0, 1] = 2;
ds_Tal[# 0, 2] = 3;
ds_Tal[# 0, 3] = 0;
ds_Tal[# 0, 4] = 0;
ds_Tal[# 0, 5] = 2;
ds_Tal[# 0, 6] = 0;
ds_Tal[# 0, 7] = 0;
ds_Tal[# 0, 8] = 2;
Code:
if(keyboard_check_pressed(ord("T"))){ showTalents = !showTalents};
if(!showTalents) exit;
#region MOUSE IN TALENT MENU
mousex = device_mouse_x_to_gui(0);
mousey = device_mouse_y_to_gui(0);
var cell_xbuff = (cellSize+x_buffer)*scale;
var cell_ybuff = (cellSize+y_buffer)*scale;
var i_mousex = mousex - slotsX;
var i_mousey = mousey - slotsY;
var nx = i_mousex div cell_xbuff;
var ny = i_mousey div cell_ybuff;
var mouse_in_tal = true;
if(nx >= 0 and nx < talColumns and ny >=0 and ny < talRows ){
var sx = i_mousex - (nx*cell_xbuff) ;
var sy = i_mousey - (ny*cell_ybuff) ;
if(sx < cellSize*scale and sy < cellSize*scale){
m_slotx = nx;
m_sloty =ny;
}
}else{mouse_in_tal = false;}
selected_tal = min(talSlots -1, m_slotx + (m_sloty * talColumns));
#endregion
if(pickedUpTalent != -1){
}
if(mouse_check_button(mb_right)) {
pickedUpTalent = selected_tal;
}
Code:
if(!showTalents) exit;
var c = c_white;
draw_sprite_part_ext(sprite5,0,cellSize,0,tal_UI_width,tal_UI_height,tal_UI_x,tal_UI_y,scale,scale, c,1)
var ii, ix, iy, xx, yy, sx, sy, sTalent, tal_grid,
ii = 0; ix = 0; iy = 0; xx = 0; yy = 0; sTalent = 0; tal_grid = ds_Tal
repeat(talSlots){
xx = slotsX + ((cellSize+x_buffer) * ix * scale);
yy = slotsY + ((cellSize+y_buffer) * iy * scale);
//x,y,location
sTalent = ds_Tal[# 0, ii]
sx = (sTalent mod talColumns) *cellSize;
sy = (sTalent div talColumns) *cellSize;
draw_sprite_part_ext(
sprite6, 0, sx, sy, cellSize,cellSize,
xx,yy, scale, scale, c_white,1);
switch(ii){
case selected_tal:
if(sTalent > 0){
gpu_set_blendmode(bm_add);
draw_sprite_part_ext(sprite6,0,sx,sy,cellSize,cellSize,xx,yy,
scale,scale,c_white,0.5);
gpu_set_blendmode(bm_normal);
break; }
case pickedUpTalent : if(sTalent > 0) draw_sprite_part_ext(
sprite6, 0, sx, sy, cellSize,cellSize,
xx,yy, scale, scale, c_white, 0.2
);
break;
}
ii += 1;
ix = ii mod talColumns;
iy = ii div talColumns;
}
if (pickedUpTalent != -1){
//Item
sTalent = ds_Tal[# 0, pickedUpTalent];
sx = (sTalent mod spr_tal_columns)*cellSize;
sy = (sTalent div spr_tal_columns)*cellSize;
draw_sprite_part_ext(sprite6, 0, sx, sy, cellSize,cellSize, mousex,mousey, scale, scale, c_white, 0.5
);
}
here are the sprites I have made and am working with. the equipment slots would be the 9 on the bottom of the one on the right hand side. if it would work better to have a separate sprite for the equipment slots I could make new sprites
Last edited by a moderator: