N
Newbie Gamemaker
Guest
hi everyone, i'm newbie. i'm doing the inventory in my first project. i got the trouble with the inventory that i create 9 slots in inventory and it is working but now i want to create more slots (adding 18 slots -same backpack that means when backpack open, it will shows more 18 slots) and the trouble is backpack open, i can not dragging item (move item form slots of inventory into backpack).i will adding the images that will show more detail. Here, the code is:
Code:
// Drag inventory
if mouse_check_button_pressed(mb_left) && !dragging {
for(i=0;i<=8;i++) {
if global.opentab = 0{ // backpack open:
ix = view_wview/2-4*36+i*36;
iy = view_hview-22 || iy =view_yview+300 || iy =view_yview+260;
mx = mouse_x;
my = mouse_y;
if point_distance(ix,iy,mx,my) < 20 && oPlayer.inv[i] != -1 {
oPlayer.clickedInv = true;
dragging = true;
dragID = i;
onlyPress = true;
pressX = mx;
pressY = my;
}
}else
{
ix = view_wview/2-4*36+i*36;
iy = view_hview-22;
mx = mouse_x-view_xview;
my = mouse_y-view_yview;
if point_distance(ix,iy,mx,my) < 20 && oPlayer.inv[i] != -1 {
oPlayer.clickedInv = true;
dragging = true;
dragID = i;
onlyPress = true;
pressX = mx;
pressY = my;
}
}
}
}
if mouse_check_button(mb_left) {
mx = mouse_x-view_xview;
my = mouse_y-view_yview;
if point_distance(pressX,pressY,mx,my) > 4 {
onlyPress = false;
}
}
if mouse_check_button_released(mb_left) && dragging && !onlyPress {
release_on_inv = false;
for(i=0;i<=28;i++) {
if global.opentab = 0{ //backpack open
ix = view_wview/2-4*36+i*36;
iy = view_hview-22 || view_yview+300 || view_yview+260;
mx = mouse_x-view_xview;
my = mouse_y-view_yview;
if point_distance(ix,iy,mx,my) < 20 {
release_on_inv = true;
invID = i;
}
} else
{
ix = view_wview/2-4*36+i*36;
iy = view_hview-22;
mx = mouse_x-view_xview;
my = mouse_y-view_yview;
if point_distance(ix,iy,mx,my) < 20 {
release_on_inv = true;
invID = i;
}
}
}
if release_on_inv {
if invID != dragID {
if oPlayer.inv[invID] = oPlayer.inv[dragID] && stackable[oPlayer.inv[invID]] {
while(oPlayer.invNum[invID] < 50 && oPlayer.invNum[dragID] > 0) {//10
oPlayer.invNum[invID] += 1;
oPlayer.invNum[dragID] -= 1;
}
if oPlayer.invNum[dragID] <= 0 {
oPlayer.inv[dragID] = -1;
}
}
else {
tmpInv = oPlayer.inv[invID];
tmpInvNum = oPlayer.invNum[invID];
tmpInvDurability = oPlayer.invDurability[invID];
oPlayer.inv[invID] = oPlayer.inv[dragID];
oPlayer.inv[dragID] = tmpInv;
oPlayer.invNum[invID] = oPlayer.invNum[dragID];
oPlayer.invNum[dragID] = tmpInvNum;
oPlayer.invDurability[invID] = oPlayer.invDurability[dragID];
oPlayer.invDurability[dragID] = tmpInvDurability;
}
}
}
else {
repeat(oPlayer.invNum[dragID]) {
drop_item(oPlayer.x+irandom_range(-6,6),oPlayer.y+irandom_range(-6,6),oPlayer.inv[dragID],oPlayer.invDurability[dragID]);
}
oPlayer.inv[dragID] = -1;
oPlayer.invNum[dragID] = 0;
oPlayer.invDurability[dragID] = -1;
}
dragging = false;
dragID = -1;
}
Attachments
-
32.9 KB Views: 9
-
39.6 KB Views: 8